back home

Separation of Concerns

[Design Principles]

Separation of Concerns is the idea that each unit of work should focus on it’s own part of the system and not have to take care of everything on its own. This principle is tightly related to [Single Responsibility Principle] and [Interface Segregation Principle].

For example, we have a process in our system which is user registration. When an API request with new user data arrives at an endpoint, the data goes through different layers. Each of them is responsible for one thing and they take care of their own piece of work. We have a controller which accepts the request, then we have a validator which checks password strength and email validity, after that we have a service which creates the user entity by accessing our repository class, which has all of the database connection and ORM logic.