[DUG] Uses
Brian Wrigley
bswrigley at xtra.co.nz
Tue Apr 3 16:52:20 NZST 2007
Hi John,
Rather than mess around with the paths to different text files and making
sure the right version gets compiled into each application, I'd be inclined
to write the standard thingy as an actual component if it's not already,
then either:
a. have it raise custom events when you want it to invoke the functions that
vary, and write event handlers for them in each application; or
b. split the varying behaviour into a new class of component and include a
component of this class as a property of the shared-stuff object. Code this
separate component as an abstract, which you then subclass and implement as
a different component in each application.
Brian
----- Original Message -----
From: "John Bird" <johnkbird at paradise.net.nz>
To: "'NZ Borland Developers Group - Delphi List'" <delphi at ns3.123.net.nz>
Sent: Tuesday, April 03, 2007 3:51 PM
Subject: [DUG] Uses
> I have a standard component thingy from which I want to be able to call
> routines that are specific to one project.
>
> My aim is to centralise some complex functions like data editing or
printing
> as much as possible in one powerful unit, but still have the shared unit
> able to call functionality specific to this project.
>
> I presume the best way to do this is to vary the uses clause for the
> project, using the same function names that exist in different units.
> However the standard component thingy has to have a fixed unit name in its
> "uses" clause.
>
> Say the component thingy is called StandardEdit, and calls some functions
> called
>
> GeneralLoadData and GeneralSaveData
>
> The StandardEdit unit would have
>
> "Uses GeneralFunctions" in its uses clause.
>
> I could have several units called GeneralFunctions (in various folders)
with
> functions called
>
> GeneralLoadData and GeneralSaveData in each of them,
>
> One could be in a folder called DummyGeneral, and each function just does
> nothing. This would be used in cases where the StandardEdit is being used
> (but no special functionality is needed in these functions) just to
satisfy
> the linker.
>
> And others specific to the project could be in the project folder for a
> specific program, with code in each function specific to that project - eg
> for project Fred1
>
> "Uses GeneralFunctions in "\src\Fred1\GeneralFunctions.pas"
>
> Which one gets linked in to a particular program depends on the DPR which
> defines which SharedFunctions unit is actually included in this project.
>
> Question - is this the best way to call specific tailored routines from a
> standard shared unit, or is there another better way I have missed?
>
>
> John
>
>
> _______________________________________________
> Delphi mailing list
> Delphi at ns3.123.net.nz
> http://ns3.123.co.nz/mailman/listinfo/delphi
>
More information about the Delphi
mailing list