Dear Hibernate experts,
I am facing a unnatural feeling of an emerging application currently consisting of 8 POJOs.
It seams to me that the POJOs end up to be state carrying objects. Lots of getters, lots of setters, no logic. The logic (model logic not business logic!) resides within a type called CoreModel.
After realizing that there is doublication of responsibility going on - POJOs know how to alter it's own state but CoreModel does so too. The question is how to solve it.
First approach: Melt down the POJOs to a bunch of getters / readable attributes and put all setter logic in CoreModel completely. Again this would render the POJOs to violate the Don't Ask Prinziple.
Second approach: Move all basic logic from CoreModel to POJOs. So let the POJOs know how to add its childs, create new childs and instances and do only let the complex model logic reside in CoreModel. This would add some more value to the POJOs and will solve the responsibility problem.
So the main question remains: Are there any advised cuts in responsibility between POJOs and the more complex model logic?
Bye,
Martin (Kersten)
PS: I used POJOs to refer to persistent classes/objects.
|