P.S. By the way, Rod Johnson also said persistent objects that contain only
getters and setters are evil too (same page as dto, 27). In my understanding
it means hibernate and ibatis which use such objects are at least as evil?
How are you supposed to represent data anyway then?

the issue is not the getters and setters per se. it's the "anemic domain model" antipattern where domain logic that *should* have gone in persistent domain objects is written procedurally, not fully leveraging the OOP facilities to uphold the DRY principle. The tangible symptom is copy-pasted logic, or frequent calls to a static helper method that takes a domain object as a parameter.

EJB entity beans forces you into the anemic domain antipattern because all your getters/setters have to be public, preventing you from enforcing invariants on the bean itself. Hibernate gives you more flexibility by allowing private getters/setters, so you can enforce some business logic in the domain object itself.

[1] http://www.theserverside.com/news/thread.tss?thread_id=31010

-- Bill

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to