Is Anemic Domain Model a set of intelligent services and a stupid object with no defined behavior?

I am a little confused about being an anemic area model in OOP. It is a kind of bunch of simple ordinary object X (where X denotes the language you prefer), without behavior (and responsibilities).

class AnemicDomainClass { private $property; public function getProperty() { return $this->property; } public function setProperty($property) { $this->property = $property; } } 

... where is all the logic inside some services?

 class SomeStuffService { public static function doSomething(AnemicDomainClass $class) { $class->setProperty(42); } } 

This appears at the end of AnemicDomainModel by Martin Fowler

In general, the more you find in services, the more likely you are to rob yourself from the benefits of a domain model. If all your logic is in services, you have deprived yourself of a blind person.

What does it mean? It is better to prefer a smart object over smart services.

0
oop anemic-domain-model
Feb 10 '15 at 12:54
source share
1 answer

In general, the more you find in services, the more likely you are to rob yourself from the benefits of a domain model. If all your logic is in services, you have deprived yourself of a blind person.

This means that instead of object code acting on the data, it is worth writing object-oriented code. Object-oriented code means modeling concepts in objects that know their own attributes and behavior and that work together to represent a working solution to the problem.

Using the multi-paradigm language that is used to support OOP does not mean that you are writing object-oriented code.

0
Aug 03 '15 at 6:44
source share



All Articles