A helper class that contains only the logic to fill the object
is called a Factory Class. It seems that this is what you need.
Also, take a look at Dependency Injection.
bruno conde
2009-12-16 14:04:34
A helper class that contains only the logic to fill the object
is called a Factory Class. It seems that this is what you need.
Also, take a look at Dependency Injection.
Where does this information come from? Is it hardcoded/consistent? Use the Object's constructor. Is it variable or does it come from a datastore? Use the DAO pattern.
Joshua Bloch discusses Static Factories and the Builder pattern in this excerpt from the second edition of his book Effective Java.
Regarding your last phrase: 'So I can call it a factory, but would it really be what they called "A Factory pattern"?'
IMHO, patterns are just food for thought. Don't worry too much if whatever you're doing fits the exact textbook definition (which is disputed anyway) or not. :-)