Hi Rohit. I understand your frustration with the TTable design, but you
don't have to follow that design in its descendants. You can achieve
the effect you desire with the following hierarchy:
type
TTableCmn = class(TTable)
procedure DoOnNewRecord; override;
procedure NewRecordStuff; virtual;
end;
TTable1 = class(TTableCmn)
procedure NewRecordStuff; override;
end;
implementation
procedure TTableCmn.DoOnNewRecord;
begin
NewRecordStuff;
inherited; // OnNewRecord will run here
end;
procedure TTableCmn.NewRecordStuff;
begin
FieldByName ('CommonField').AsInteger := 1;
end;
procedure TTable1.NewRecordStuff;
begin
inherited; // As per "normal"
FieldByName ('MyField').AsText := 'blah';
end;
Of course if you needed to have your descendant code execute amidst the
TTable.DoOnNewRecord code then this wouldn't help you, but while that
might be shortsightedness on the part of whoever wrote the
TTable.DoOnNewRecord code, it wouldn't be an intrinsic OOP model flaw.
Cheers,
Carl Reynolds Ph: +64-9-4154790
CJN Technologies Ltd. Fax: +64-9-4154791
[EMAIL PROTECTED] DDI: +64-9-4154795
PO Box 302-278, North Harbour, Auckland, New Zealand
12 Piermark Drive, North Harbour Estate, Auckland, NZ
Visit our website at http://www.cjntech.co.nz/
> -----Original Message-----
> From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, May 13, 1999 10:52 PM
> To: Multiple recipients of list delphi
> Subject: [DUG]: Another Axe thru the OOP model
>
> I hesitated posting this message, lest I be seen bashing Borland
> again. But really, some of you need to know this (if you havent been
> hit by it by now).
>
> At first glance this should work fine, just the perfect hook for
> initalising fields in a new record......
>
> type
> TTableCmn = class(TTable)
> procedure DoOnNewRecord; override;
> end;
>
> TTable1 = class(TTableCmn)
> procedure DoOnNewRecord; override;
> end;
>
> implementation
>
> procedure TTableCmn.DoOnNewRecord;
> begin
> inherited; /// the normal thing to do
> FieldByName ('CommonField').AsInteger := 1;
> end;
>
> procedure TTable1.DoOnNewRecord;
> begin
> inherited; /// let the parent initialise common stuff
> FieldByName ('MyField').AsText := 'blah';
> end;
>
>
> But, the dratted DoOnNewRecord in TTable/TDataSet calls the forms
> OnNewRecord event. If this is assigned, it gets executed first, but
> surely, normally I want this executed last.
>
> And no, you cant call inherited last in the overridden methods. You
> have to redo all the code on ever overridden method. That is, the
> prime concept of building up behaviour neatly falls down.
>
> It would appear that this applies to all the Onxxxxx events in the
> VCL. So beware when writing families of components.
>
> Regards
>
> Rohit
>
> ======================================================================
> CFL - Computer Fanatics Ltd. 21 Barry's Point Road, AKL, New Zealand
> PH (649) 489-2280
> FX (649) 489-2290
> email [EMAIL PROTECTED] or [EMAIL PROTECTED]
> ======================================================================
>
> ----------------------------------------------------------------------
> -----
> New Zealand Delphi Users group - Delphi List -
> [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
application/ms-tnef