M
Matthias S.
Hi,
I have to write an application which extensively uses an SQL Database.
For a simple example say I have the following tables with the
appropriate fields.
1. Company (ID, Name, AddresseInfoID)
2. AddresseInfo (ID, Street, City, Zip)
(Those two obviously have a relationship)
Now I'd go and create an object called Company and one for the
AddresseInfo. AddresseInfo would be a public member of Company.
Usually you'll have more than one company to manage so I create a
strongly typed collection called CompanyCollection.
Now on to the questions:
1. Should each individual object be responsible of loading and saving
it's data from and to the database or should the CompanyCollection take
care of it (which IMHO seems a lot less coding to me on first sight)?
2. Assumed the Collection takes care of the data-fetching, how should
then the data changes whithin the individual objects be handled? What
comes in mind is either a IsDirty property of each of the
BusinessObjects (Company and AddresseInfo) (which can be checked by the
collection) or an event (say DataChanged) to which the collection would
hook up.
The problem I see with this approach is the following. Say my MDI GUI
displays a list of all Companies in a TreeView on the lefthandside. On
DoubleClick the selected BusinessObject gets displayed in a new
"Document Window" which hosts a PropertyGrid control. Now my user opens
3 Companies and changes the data of all of them. How would I then handle
the situation when he only wants to save to of those documents?
Here is some additional information which I feel might be usefull:
a. The amount of BusinessObject loaded from the Database is never really
huge. Say a maximum of 2000 objects.
b. BusinessObjects might contain collections of other BusinessObjects,
e.g. the Company object will contain a EmployeeCollection.
c. The amount of different BusinessObjects will probably not exceed 20.
d. Performance issues are not a knock out criteria.
e. The solution that I'm after is simple to code and maintain. I don't
actually want to create a huge Framework with hundrets of classes which
provide for unlimited scalability and the forth. We are talking about an
application which is used by 10 people and new versions can be installed
at any time if required.
I hope someone can give me some advice on how to design this properly.
Thanks in advance,
Matthias
I have to write an application which extensively uses an SQL Database.
For a simple example say I have the following tables with the
appropriate fields.
1. Company (ID, Name, AddresseInfoID)
2. AddresseInfo (ID, Street, City, Zip)
(Those two obviously have a relationship)
Now I'd go and create an object called Company and one for the
AddresseInfo. AddresseInfo would be a public member of Company.
Usually you'll have more than one company to manage so I create a
strongly typed collection called CompanyCollection.
Now on to the questions:
1. Should each individual object be responsible of loading and saving
it's data from and to the database or should the CompanyCollection take
care of it (which IMHO seems a lot less coding to me on first sight)?
2. Assumed the Collection takes care of the data-fetching, how should
then the data changes whithin the individual objects be handled? What
comes in mind is either a IsDirty property of each of the
BusinessObjects (Company and AddresseInfo) (which can be checked by the
collection) or an event (say DataChanged) to which the collection would
hook up.
The problem I see with this approach is the following. Say my MDI GUI
displays a list of all Companies in a TreeView on the lefthandside. On
DoubleClick the selected BusinessObject gets displayed in a new
"Document Window" which hosts a PropertyGrid control. Now my user opens
3 Companies and changes the data of all of them. How would I then handle
the situation when he only wants to save to of those documents?
Here is some additional information which I feel might be usefull:
a. The amount of BusinessObject loaded from the Database is never really
huge. Say a maximum of 2000 objects.
b. BusinessObjects might contain collections of other BusinessObjects,
e.g. the Company object will contain a EmployeeCollection.
c. The amount of different BusinessObjects will probably not exceed 20.
d. Performance issues are not a knock out criteria.
e. The solution that I'm after is simple to code and maintain. I don't
actually want to create a huge Framework with hundrets of classes which
provide for unlimited scalability and the forth. We are talking about an
application which is used by 10 people and new versions can be installed
at any time if required.
I hope someone can give me some advice on how to design this properly.
Thanks in advance,
Matthias