'don't ask,tell' speration of concerns
(although it was posted in a spring forum, for it's special usage, i
felt it may need larger mind meld for this design question).
i keep reading in mock artible how one should not use getters for
objetcs like for example instead of
dog.getBody.getTail();
one should do
dog.wagTheTail
however it occurs to me this the is a wrong seperation of concerns
here, becouse as i see it, you have a division of model beans
(dog,body etc..) and a division of services performing actions on said
beans, such services, that are maybe created by spring, and that
wagTheTail method should actually belong to K9Activties class, a
buisness services class.
another issue with a mock article i read, also states that creational
activities should not appear in the method performing buisness logic,
but should be seperated into a single metod (which could be overidden
later for mock tests) rather then being transfered for factory object
which may complicates matters.
while i agree that they should not appear in the method itself, i
believe that they SHOULD appear in factory objects, as i see them as
infrastructure usage, not logic.
just as there CRUD for data, there is CRUD for objects, we allready
have DAO patterns performing abstractions for persistence, and
basically what we do with object persistence is that we tell the
application to either save, load or delete it, how and to where is not
an issue, we could save it to db/file/xml or load it from a file
etc..,doesn't matter. what is creational stuff if not basically making
room in memory for objects, how we would it shouldn't matter, it's
just another CRUD operation, so like a DAO class collabrator which
handles objects into data, a factory objects should be treated the
same.
a pure businsess method should in my view be something like :
public void Process(DataInteface interParamter){
Model model= inter.getrelvantData
if (model.shouldCreateNew)
newObject= creationalCollabrator.createNewObject();
newObject.setName=model.getName();
persistenceCollabrator.save(newObject)
}