-
-
Notifications
You must be signed in to change notification settings - Fork 694
Encapsulation
tanukus edited this page May 18, 2020
·
2 revisions
Given a class, the sum of its members complexity should be less than the sum of its parts in isolation.
Suppose there is a Customer
entity like this:
public class Customer
{
public Guid Id { get; set; }
public string Name { get; set; }
public string SSN { get; set; }
public bool Active { get; set; }
public string ActivatedBy { get; set; }
}
The complexity of the previous class is the same if there were variables like the following:
Guid Id;
string Name;
string SSN;
bool Active;
string ActivatedBy;
Classes that are similar to a bag of data leaks unnecessary complexity. Consider reducing the complexity with something like:
public class Customer
{
public Guid Id { get; protected set; }
public string Name { get; protected set; }
public string SSN { get; protected set; }
public bool Active { get; protected set; }
public string ActivatedBy { get; protected set; }
}
- Value Object
- Entity
- Aggregate Root
- Repository
- Use Case
- Bounded Context
- Entity Factory
- Domain Service
- Application Service
- Single Responsibility Principle
- Open-Closed Principle
- Liskov Substitution Principle
- Interface Segregation Principle
- Dependency Inversion Principle
- Swagger and API Versioning
- Microsoft Extensions
- Feature Flags
- Logging
- Data Annotations
- Authentication
- Authorization