oopzend-frameworkdesign-patternsanemic-domain-model

Is this an anemic domain model?


I'm trying to build my first CRUD application, and I don't understand if I should use an object containing getters and setters separated.

Considering that we have the Zend Framework Quick Start tutorial with a Model structure containing:

If the Domain Object (as presented on Zend Quick Start Tutorial) consists of only getters and setters, is that an anti-pattern? In a sense, we are unecessarily dividing the domain object with a transaction script?

Please advise.


Solution

  • The domain objects are seperated from the business logic of the software. This is an important idea of procedural programming.

    However this pattern is considered to be a candidate for an anti-pattern by some developers which means that it might be a ineffective practice.

    In fact you could consider disadvantages

    I think the most interesting point to consider is that domain model's objects cannot assure their correctness at any time. Because their mutation takes place in seperated layers.

    I worked on a CRUD application with zend framework too. The clear separation between logic and data is really great but when you progress you realize that the amount of layers and mappers gets bigger and bigger. Try to reuse your code as much as you can and avoid dublication.