These books look good. Think I'll walk down to the B&N after work and browse through them before I buy. And yes, I am merging the lines between repository and factory, but that was sort of the point. I don't want any free floating objects around. I want everything to be coming from the DB, since everything in the app comes from the DB.
It is already a good amount of extra work to create this factory class and a criteria class for every object. To create a factory, repository and criteria class would be one extra step. Other developers here find the whole process a waste of time and they just get the PB each time they want to interact with the DB and do .store(). I think that isn't abstract enough and can lead to mistakes and repeating of code. I'm pretty sure I'm in the right on this one though. ;)
Thanks again for the book links. Hopefully they will show me some good pointers.
Charlie
Shane Mingins wrote:
-----Original Message----- From: Charles N. Harvey III [mailto:[EMAIL PROTECTED] Sent: Tuesday, 2 March 2004 8:35 a.m. To: OJB Users List Subject: object factories
Hey all. Currently I don't allow objects to be created with new. They have to go through my Factory class to create a new object. I actually create a bunch of methods like, selectMyObject, insertMyObject, updateMyObect, selectMyObjects (returns collection) and createMyObject. I also create a criteria for each object. So I can do, myObjectCriter.addEmailEqualTo( email ).
Works pretty well so far. The create() method retrieves the next available ID from the DB and then accesses the constructor of the object with the ID.
But, there is always a better way. So I thought I would ask to see what
other people are doing for object creation and object updates. Are most
people using .store() and new()? Or do a lot of users have Factories?
And, if so, what are some of the ideas that work best for you and your
users?
My thoughts:
Grab yourself a copy of Domain-Driven Design - Eric Evans http://www.domaindrivendesign.org and also Patterns of Enterprise Architecture - Martin Fowler http://martinfowler.com/books.html#eaa
You will find good design patterns and ideas for this type of thing.
A Factory should have one purpose ... create/reconstitute an object. It looks like you have a Class that merges a Factory with a Repository.
Cheers Shane
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]