Only 6 hours?!  Luxury!  :)

Having to update multiple forms is my pet hate.  That reminds me of a
story...  :)

The last time I was in this position we decided to modify _every_ form
in our application to inherit from a common ancestor (which would handle
saving user size and positioning among other things).  Anyway, I
_definitely_ couldn't be bothered to go through opening umpteen million
forms, changing the "TMyForm = class(TForm)" to "TMyForm =
class(TOurForm)" and sticking "inherited;" at the start of all our
methods, so I wrote a Delphi program to do it, using
ObjectResourceToText and ObjectTextToResource to handle the change to
the forms.  Result: it worked extremely well!  I strongly recommend
doing this to anyone who finds themselves in a similar unfortunate
situation.

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: Friday, May 14, 1999 5:01 AM
> To:   Multiple recipients of list delphi
> Subject:      RE: [DUG]:        Another Axe thru the OOP model
> 
> Carl,
> 
> thats what I did last night.  It just took about 6 hrs to wade through
> 
> all 92 odd table components and retest.  :-(
> 
> 
> On 13 May 99 at 12:00, Carl Reynolds wrote:
> 
> > 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.
>
> > > -----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]
> > >
> ======================================================================

application/ms-tnef

Reply via email to