 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Rainer Krug Guest
|
Posted: Thu Jan 20, 2005 10:19 am Post subject: Design Question |
|
|
Hi
I want to write a picture database and want to follow OOP. I.e., I want
to use business objects which hold the data and objects which save and
load these from a database and handle all the IO stuff.
My question: I have thought of having one busines object called
TPicture which holds different other business objects, like TSubject
containing the infos about the subject, TTechnical containing the
technical infos about the equipment used, where TTechnical consists of
other objects like TCamera, TFilm, etc.
Is this a reasonable design? In addition: I wan to use Interfaces and
defined all the interfaces for the business objects. Should TPicture
hold as reference to TSubject, or simply and ID which references to the
data of TSubject - if TSubject is needed (e.g. display), Icould simply
load it from the database through the IO objects.
Thanks for any input?
Rainer
|
|
| Back to top |
|
 |
Jim Cooper Guest
|
Posted: Thu Jan 20, 2005 1:04 pm Post subject: Re: Design Question |
|
|
| Quote: | Is this a reasonable design?
|
Possibly In principle composition and aggregation are good things.
| Quote: | Should TPicture hold as reference to TSubject
|
Depends. Leaving aside the question of whether interface use is required
here <vbg>, you have two choices. Either you have an object of type
TSubject created inside TPicture, ie the TSubject will have the same
lifetime as the TPicture, or you have two objects with different
lifetimes, and TPicture only has a reference to the TSubject.
The way to pick basically is down to lifetimes and references. Could
many TPictures reference the same TSubject? If you delete the TPicture,
should the TSubject get deleted or not?
| Quote: | or simply and ID which references to the data of TSubject
|
I wouldn't do that in your objects (although you will do something of
the sort in your database probably). Hold a reference to an object
always. You can do lazy loading and only load those composite/aggregate
objects when required though.
Does that help?
Cheers,
Jim Cooper
_______________________________________________
Jim Cooper [email]jim (AT) falafelsoft (DOT) com[/email]
Falafel Software http://www.falafelsoft.com
_______________________________________________
|
|
| Back to top |
|
 |
Rainer Krug Guest
|
Posted: Fri Jan 21, 2005 7:51 am Post subject: Re: Design Question |
|
|
Jim Cooper wrote:
| Quote: |
Is this a reasonable design?
Possibly In principle composition and aggregation are good things.
Should TPicture hold as reference to TSubject
Depends. Leaving aside the question of whether interface use is
required here <vbg>, you have two choices. Either you have an object
|
Well, I agree - Interfaces are not necessary for TPicture, but I don't
have to free them...
But, ISubject can be of type TLandscape, TBird, TMammal, TPlant, .. so
for this i need interfaces or they have to have the same ancestor.
| Quote: | of type TSubject created inside TPicture, ie the TSubject will have
the same lifetime as the TPicture, or you have two objects with
different lifetimes, and TPicture only has a reference to the
TSubject.
The way to pick basically is down to lifetimes and references. Could
many TPictures reference the same TSubject? If you delete the
TPicture, should the TSubject get deleted or not?
|
On the busines model, I think I would prefer to have the same lifetmine
for TPicture and TSubject. A different story is TCamera, where I only
have a limited number of. :-(
| Quote: |
or simply and ID which references to the data of TSubject
I wouldn't do that in your objects (although you will do something of
the sort in your database probably). Hold a reference to an object
always. You can do lazy loading and only load those
composite/aggregate objects when required though.
Does that help?
It definitely does - I will come back to it as soon as I managed to |
warp my brain around the difference in database structure and busines
model.
| Quote: |
Cheers,
Jim Cooper
_______________________________________________
Jim Cooper [email]jim (AT) falafelsoft (DOT) com[/email]
Falafel Software http://www.falafelsoft.com
_______________________________________________
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|