From the course: Expert Domain-Driven Design (DDD) Implementation in .NET
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Avoiding the primitive obsession anti-pattern - .NET Tutorial
From the course: Expert Domain-Driven Design (DDD) Implementation in .NET
Avoiding the primitive obsession anti-pattern
- [Instructor] When we develop software using object-oriented programming, it's very common to define classes with properties that use the data types provided by the development platform we're working with. In this case, .NET and the common type system. Give us all these data types such as int, bool, daytime, string, decimal, double, and so on. So here, let's add other properties to the Pet class. So for example, let's add color, and you can see that I'm using string and let's add weight. I'm using decimal. Sometimes we also use enums to model our classes. Let's create a new enum called sex of pet. So public enum SexOfPet, and let's add Male, Female, and let's add a new property, SexOfPet with the same name. Just like this. This is fine. However, an enum is basically just a list of named integers, right? The problem with basic data types is that they're general purpose and don't convey any business logic or intent. If we rely on them to model our classes, we risk falling into the trap…
Contents
-
-
-
Creating the initial project for the Management domain model1m 36s
-
Implementing an entity6m 27s
-
(Locked)
Refactoring the logic into an entity base class2m 7s
-
(Locked)
Encapsulating and protecting entity state3m 39s
-
(Locked)
Avoiding the primitive obsession anti-pattern1m 52s
-
(Locked)
Implementing a value object for a pet's weight7m
-
(Locked)
Implementing a second entity for pet breeds4m 6s
-
(Locked)
Invoking a domain service in a value object8m 8s
-
(Locked)
Implementing business rules in the Pet entity7m 43s
-
(Locked)
Implementing implicit operators in value objects2m 9s
-
-
-
-
-
-
-