A
Alfred Taylor
I'm testing the waters of n-tier development and I ran into a scenario that
I'm not sure what the best solution would be. I have a Company object which
contains a collection of contacts retrieved from a database.
In the presentation layer, the user will be able to add/delete/modify this
collection in which case it needs to be synced with the database.
The question is basically how best to do this? Aside from overriding the
add/remove methods of the collection, I can't think of any way to maintain a
1:1 correspondence between what's in the collection and what's in the DB.
I would do this, but something tells me it's not a good idea to have the
collection know about database access.
Or am I asking too much to have the collection synced? Should I just
provide methods on the Company object which let me add/delete/edit a
contact? Which means if a developer modifies the collection directly, it
won't occur in the DB.
Thanks,
-A
I'm not sure what the best solution would be. I have a Company object which
contains a collection of contacts retrieved from a database.
In the presentation layer, the user will be able to add/delete/modify this
collection in which case it needs to be synced with the database.
The question is basically how best to do this? Aside from overriding the
add/remove methods of the collection, I can't think of any way to maintain a
1:1 correspondence between what's in the collection and what's in the DB.
I would do this, but something tells me it's not a good idea to have the
collection know about database access.
Or am I asking too much to have the collection synced? Should I just
provide methods on the Company object which let me add/delete/edit a
contact? Which means if a developer modifies the collection directly, it
won't occur in the DB.
Thanks,
-A