Posts

Showing posts from January, 2024

Single Responsibility Principle in .NET Core

Image
  Are you tired of dealing with bloated and confusing code? The Single Responsibility Principle might just be the solution you need! This principle, which is the first in the solid design pattern, emphasizes that each class or module should have a single responsibility. Put simply, a class or module should only be responsible for one thing. So, what exactly does responsibility mean in this context? It refers to the functionality of a class or module, such as adding, updating, deleting, or sending emails. Let’s take an employee class as an example — its responsibility might include Addemployee, UpdateEmployee, DeleteEmployee and SendingEmails. In this article, we’ll explore the Single Responsibility Principle in more depth and discuss how you can implement it in your own code. Trust us, you won’t want to miss this one! Let us Consider the following example public class UserController : ControllerBase { private readonly ICommonRepository<User> _commonRepository...