Delphi
SOL[I]D - Articles, Examples and Codes in Delphi
The SOLID principles were introduced by a Software Engineering expert named Robert C. Martin , or “Uncle Bob,” who is well known for writing the books “ Clean Code ”, “ Clean Coder ” and “ Clean Archicteture ” . These principles are closely associated with Object Oriented program...
Description
The SOLID principles were introduced by a Software Engineering expert named Robert C. Martin , or “Uncle Bob,” who is well known for writing the books “ Clean Code ”, “ Clean Coder ” and “ Clean Archicteture ” . These principles are closely associated with Object Oriented programming and present a number of techniques and mechanisms for building a more flexible and sustainable class architecture. The term SOLID, although it is an English word with translation of "solid", in this context is an acronym. Each letter corresponds to one of the principles, requiring every term to be capitalized.
The Open / Closed Principle - or OCP - may seem a little contradictory at first, but it's quite simple to understand. The principle states that “software entities should be open for extension but closed for modification” in order to reduce conditional structures and hence cyclomatic complexity. The purpose, in fact, is to allow entities to be able to receive new behavior without necessarily undergoing excessive code changes.
Abstraction and Inheritance represent two of the four pillars of Object Orientation. These two concepts must be carefully worked out to define a lightweight and flexible architecture for software design. However, the search for the “perfect level” of abstraction can bring inaccuracies in architecture. In this article, we will identify an abstraction misconception that promotes unexpected behavior in a file reading routine.
The Segregation Principle Interface (PSI) is closely connected to the abstraction and guides the proper identification and definition of interfaces. The goal is to prevent the architecture from being compromised as new modules, components, or classes are added to the project. See, therefore, that we are referring to the sustainability of architecture.
Much is said about high coupling in programming. This term refers to the strong dependencies between classes, resulting in a very common situation: a simple change in one class impacts several adjacent classes. The Dependency Inversion Principle - or DIP - guides a way to reverse the dependencies (as the name implies), raising the level of abstraction in an architecture. The goal is to modify it so that dependencies are represented by abstractions, reducing coupling. Before continuing, it an important observation: Dependency Inversion and Dependency Injection are different concepts, okay? The latter will still be addressed here on the blog.