Ehsan Ghanbari

Experience, DotNet, Solutions

Difference between Anemic Domain Model and Rich domain model

There are lots of differences between these to approach. Anemic model is an anti-pattern introduced by martin fowler to encourage developers to duplicate code!  Based on the main idea behind DDD, if you have ubiquitous language then you can have domain model Anemic domain model is the use of a software domain model where the domain objects contain little or no business logic. in a Rich Domain Model behavior is included in the domain object while in Anemic Domain Model behavior is implemented in separate classes.

At some point in the design of the software it is decided to implement certain pieces of logic for a domain entity outside of that domain entity.  This may be as a result of an explicit design decision or some pieces of logic just cannot be implemented in the domain entity because it is a persistent class and has no internal references to external services. 

The fundamental horror anemic model is that it's so contrary to the basic idea of object-oriented designing; which is to combine data and process them together. anemic objects are not real objects, and it's something different from object-oriented design. In anemic model, business logic is typically implemented in separate classes which transform the state of the domain objects. "A domain model in problem solving and of all the topics related to a certain problem. It describes the various entities, their attributes, roles, and relationships, plus the constraints that govern the problem domain. The domain model is created in order to represent the vocabulary and key concepts of the domain problem." ~ wikipedia



Definition of Event Driven Architecture

I'm just gonna define the EDA in a short talk and definitely it's not completed. Based on the definition of Wikipedia "Event-driven architecture, is a software architecture pattern promoting the production, detection, consumption of, and reaction to events. An event can be defined as "a significant change in state". For example, when a consumer purchases a car, the car's state changes from "for sale" to "sold"."

In another definition, EDA is a framework that orchestrates the behavior around the production and consumption of events which consists of event creators and event consumers. The creator only knows that the event has been occurred and the consumers need to know about the creators that if they have been happen or not. And that's the main benefit of event-driven architecture which enables large numbers of creators and consumers to exchange status, messages and responses.

When your system is in real time processing or several part of the applications are processing on an event, you can apply EDA. One of the benefits of EDA is that producer and consumer are decoupled  and Consumers can respond to events immediately.



About Me

Ehsan Ghanbari

Hi! my name is Ehsan. I'm a developer, passionate technologist, and fan of clean code. I'm interested in enterprise and large-scale applications architecture and design patterns. I spend a lot of time on software architecture. Since 2008, I've been as a developer for different companies and organizations and I've been focusing on Microsoft ecosystem all the time. During the past years, Read More

Post Tags
Pending Blog Posts
using Elmah in asp.net MVC4
Using FluentSecurity in MVC
Strategic design
Factory Pattern
time out pattern in ajax
Redis as a cache server
How to use PagedList In asp.net MVC
Multiple submit buttons in asp.net MVC
Domain driven design VS model driven architecture
What's the DDD-lite?