I've studied database design, and am reasonably proficient at it,
however when it comes to building an Objective Framework for
interfacing with the database it seems you can go one of two ways,
and I'd like to know which one is preferable and why if anyone would
care to enlighten me as to the pros and cons, mainly in terms of
design efficiency.
Route 1)
Override each object constructors so that each object initialises
itself.
e.g. myCustomer = new customer(n)
In this case the customer object would query the database and
populate it's own properties
Route 2)
Have a factory module with methods for populating and returning
instances of these ojects
e.g. myCustomer = MyFactory.GetCustomer(n)
In this case the factory would do ALL of the database comms.
I can see the advantages of using a Factory object, but a lot of my
objects contain instances of other minor objects (e.g. an Address is
it's own object in this setup, and each Customer Object has an
Address Property), and the first option makes this easy by allowing
object creation to cascade automatically up the tree simply by
creating the root object.
Any comments are more than welcome,
Tom
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>