This Is How the Anemic Domain Model Turns Bad

preview_player
Показать описание
Use this link for a 30-day free trial and 20% off of an annual premium subscription.

Anemic domain models might be the culprit, stripping away everything object-oriented programming has to offer.
In this video, I dive deep into how primitive obsession leads to fat service layers and a bloated codebase. Learn how to avoid these pitfalls, embrace rich domain models, and unlock the full potential of OOP.
Don't let outdated practices hold you back. Don't write code like it's 1988!

Watch the entire series:

▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
👨 About Me 👨
Hi, I’m Zoran, I have more than 20 years of experience as a software developer, architect, team lead, and more. I have been programming in C# since its inception in the early 2000s. Since 2017 I have started publishing professional video courses at Pluralsight and Udemy and by this point, there are over 100 hours of the highest-quality videos you can watch on those platforms. On my YouTube channel, you can find shorter video forms focused on clarifying practical issues in coding, design, and architecture of .NET applications.❤️
Рекомендации по теме
Комментарии
Автор

This link gives you a 30-day free trial and 20% off of an annual premium subscription.

zoran-horvat
Автор

“This service could have been an endpoint” has big “this meeting could have been an email” energy.

RickGladwin
Автор

Thank you for publishing an interesting video. Waiting for the second part with the "rich domain" explanation.

alexlo
Автор

Thank you for your videos! They are extremely helpful and the quality is on another level. I'm looking forward to the next video on this topic 👍🏻👍🏻

mocca
Автор

Viewers might see any of your videos as their first. It may be helpful to link related videos in the description. For example, a video of fixing an anemic domain model would be a useful item to link in this video.
One can, of course, search through the channel, but you now have over 100 videos.

CharlesBurnsPrime
Автор

What is the video that you turn this to a rich domain? Did you do it yet or in the future?

vuhoang
Автор

For example, I have a service. A client can query it, then the service itself queries another service via grpc, then it queries redis, makes some data processing, maps the response and returns it to the client.
It is very clear how it can be done using anemic models. But what about OOP-style? How will it look like?

ShowoffFantasy
Автор

How would you design a dto model? How would I map it from the domain model? How would I go about json serialization a polymorphic Edition?

modernkennnern
Автор

I was on board with the idea entire time until 11:07, where you suggested to expose "one update operation" for the entire Book model on the Service. This, on my opinion, belongs to the Repository, that only cares about persistence and not business rules.

The service should orchestrate calls to the book entity methods based on the use-case. By exposing a single update method on the Service, you remove all meaning from the operation - the consumer of the API rarely wants to update everything about the entity. Often, there are rules that prevent updating two pieces of data at once in the same transaction, because those operations may have different business implication (and trigger mutually exclusive actions).

It is also possible that I'm being overly pedantic and what you're showing here as a Service, is what I call a Repository, and all is well in the end.

PapoochCZ
Автор

You could implement just 1 method that receives a struct with the mapping of the changes and with domain logic in the models and you've achieved the same, with faster performance and not dropping the anemic domain model. I don't think this is the main reason why you shouldn't have an anemic model. The APIs are not the best suited for this, except you want to create a very complex service that actually do something inside. 99% of the time you won't be coding anything you've not done before and usually is not that complex.
I like ddd and I tend to respect the norms but I prefer to see the real benefits of it instead of trying to push practices.

pablolocles
Автор

Can't do my homework when my head hurts

handlez
Автор

Anemic model definitions seem like simple data type and layout definition. Just types the data in a way that language used understands (C#, Java, F#, Scala etc. etc.) and nothing else (lacks behavior). Like a data contract only.

Makes no sense in languages such as C# unless unavoidable (i.e using libraries and frameworks with none or basic mapping capabilities). Then it would still be possible to create and use rich domain model with custom in-house mapping (which can be problematic to maintain).

dusanknezevic
Автор

Does't the anemic donation model shares some similarities to functional programming? Mainly the lack of polymorphism?

yanivrubin
Автор

We want a video about clean architecture

MahmoudSaed
Автор

The best word for your videos: seductive. You are dangerous.

vincentvogelaar