Hello, Polu. Thanks for your comments
I prefer a separated factory generating collections or objects. Factory will generate a collection (method findByCityOfResidence) or a simple object (method findByID), so I disagree with the idea of having collections as factories.
I don't fully understand this. think you mean that you have extracted the object creation into a separate class?
Also, I prefer a separated class to manage cache, rather than having this functionality coupled with factories.
I would like to extract a good deal of functionality from my "lazy collections" into other classes (and I am doing so for some database functions). However, I am running into the problem of not wanting too general classes for specific solutions. I could store the objects is a standard collection, for instance. But then I'd lose a great deal of compiler type checking and cause my application to do a huge lot of casting.
It's a bit like the collections framework in Java. I still wonder why somebody would write a strongly-type language and then force everybody to use only generic types.
DAO approach seems to be right for me to add new records to our table's
I like the idea too, especially because DAO is one of the examples I encountered that does use the collection/member approach. However, it was not clear the first time I used it, that the create method did not add the member to the collection itself. This is a situation where I would have liked a separate factory myself. Hey! I am learning as I type this!
Please, tell me more about why is needed/not needed OnDeletion events. I would like to read why is/isn't needed notify to every user-class that the record was deleted as soon as it occurs.
The truth is that I did not need to delete persistent objects in my work. It is just my idea of keeping both the database representation and the object model consistent. It probably is a not so much of a problem in the real world: If you have a reason to delete the object from the database, your application (if it is consistent) will not have any reason to anything else with it.
One issue I a can imagine is that the application wants an inventory of what's still there.
In visual Basic, not every user class has to respond to events. Only if you write an event routine, you respond to the event.
I'm not really happy with this solution but I use to write 'updates' inside the .Add method; if record previously exists is an update, if not is an insert.
I did not encounter an example where I do not know if the record is present beforehand in my work. I did encounter a "last changes" table. For that table, I have my collection pass an appropriate NullObject, which causes itself to insert, rather than modify an existing record.
I don't like intermediate classes, but I have not found a clever solution
Too bad. I couldn't come up with something better as well ;-)
Best regards