2021-05-13 13:05:02
In object-oriented computer programming,
- Single-responsibility principle: "There should never be more than one reason for a class to change."
In other words, every class should have only one responsibility. Open–closed principle: "Software entities ... should be open for extension, but closed for modification."
public class TextConverter { private readonly
Func_a_m_p_;_lt;string, string_a_m_p_;_gt; _convertion ; public TextConverter(Func_a_m_p_;_lt;string, string_a_m_p_;_gt; convertion ) { _convertion = convertion; } public string ConvertText(string inputText) { return _convertion(inputText); } }String conversion is a parameter - Liskov substitution principle: "Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it".
This means that derived class should be substitutable for their base class. - Interface segregation principle: "Many client-specific interfaces are better than one general-purpose interface."
A client should never be forced to implement an interface that it doesn’t use, or clients shouldn’t be forced to depend on methods they do not use. - Dependency inversion principle: "Depend upon abstractions, [not] concretions."
Entities must depend on abstractions, not on concretions. It states that the high-level module must not depend on the low-level module, but they should depend on abstractions.