Mark,
Working from home this week, so can't post directly to the list... would you
mind forwarding this for me?
> > As an aside, I think you ought to use a strategy class to implement the
> > switch between ADO and BDE. Don't conditional defines for this.
>
>I'm unfamiliar with the term "strategy class", care to explain?
The terminology comes from Design Patterns by Gamma, et al. It is a design
where you have different classes perform different actions, but share the
same interface. In the above example, you would declare an abstract class
(or interface) that contains all the methods and properties to persist the
data to a database. You would then inherit one class that performs writing
data to BDE and another that write data to ADO. These classes can be
swapped in and out as required. The user of the class does not need to know
whether the data is comming from BDE or ADO. The user only needs to know
how to interact with the interface. This is known as the strategy pattern.
The advantage is you abstract out the system dependence to a class, so if
for example, you need to support another database technology, all you need
to do is write another strategy class - all other code is unaffected. You
can take this one step further and have different strategy classes that save
data to database, out to a web server, exports to text files, etc. If you
keep you strategy classes in packages, you can even load different classes
during run-time!
>At the moment we have a large graphing module which was written by a
>contract programmer and tied very deeply to BDE specific controls. I
>initially made a branch of the code in cvs and hacked the references to to
>TQuery to TADOQuery, and Params to Parameters etc. etc. which I'm
>currently merging with conditionals. I'm also looking through the code
>and finding areas I could change to make it more DB generic, i.e. passing
>TDatasets, not using Parameters but filling out the SQL fully.
>
>At the moment I'm mainly wanting to get back to one branch of code than
>can be compiled for either ADO or BDE. No one else here has mentioned
>anything about conditionals, am I the only one using/abusing them?
>
>Whats everyones thoughts on them?
Conditionals are fine, but I think using the strategy pattern is more
flexible, though a bit more work initially. I tend to use conditionals very
minimally, and about the only time is when I need a piece of code to work
with D1. For debugging, I tend to use asserts nowadays.
Regards,
Dennis.
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz