> -----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]