![]() Dependency inversion principle – the principle states that high-level modules should not depend on low-level modules.Interface segregat i on principle – no class should be forced to implement a method in an interface that it doesn’t use.Liskov substitution principle – base class should be substitutable with subclasses without causing any side effects or compile errors.Open-closed principle – classes and methods should be open for extension but closed for modification.Single responsibility principle – this post covers this SOLID principle.SOLID is an acronym that stands for five simple object-oriented programming principles: The Single Responsibility Principle (or SRP) is one of the first SOLID principles you should learn about in object-oriented programming. It sounds like common sense, but it’s surprisingly easy to violate this principle. or other methods in which contain several hundred lines of code.In other words, a class should focus only on one logical function. ![]() It also says that the class should only have one reason to change. It states that every method, class, or module should have one and only one responsibility. But what methods to move to other classes? The single responsibility principle (SRP) is a rule of thumb that can help you answer this question. Naturally, being a good programmer, you want to make this class smaller. You are working on a software application (captain obvious strikes again).Īnd let’s say you encounter a large class with many methods. What is the single responsibility principle?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |