![]() ![]() As a commonly used definition, "every class should have only one reason to change". ![]() The idea behind the SRP is that every class, module, or function in a program should have one responsibility/purpose in a program. The Single Responsibility Principle (SRP) Single Responsibility Principle follows another principle called Separation of Concerns. Single-responsibility principle: The dependency inversion principle helps to adhere to the single-responsibility principle by allowing you to separate concerns into different modules. Here is what each letter in the acronym stands for: S: Single responsibility principle. Each letter in the acronym SOLID stands for a specific principle. We'll conclude this article by talking about the basics of object oriented design. Low Coupling: Single Responsibility Principle vs Cohesion. The SOLID design principles help us create maintainable, reusable, and flexible software designs. The examples we will use in this article are going to be very basic. In this article, we'll start by defining each principle and then we'll see some examples to help you understand how and why you should use these principles in your code. As I mentioned: Many times you can have duplicate code because business rules are similar amongst different concerns, and have different reasons to change. Side-Note: DRY Doesn't mean there is never duplication. Here is what each letter in the acronym stands for: But Separation of Concerns, Single Responsibility, Cohesion, and DRY (Don't Repeat Yourself) are all separate ideas. The SOLID design principles help us create maintainable, reusable, and flexible software designs. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |