The relevance of the SOLID principles

SOLID principles were first introduced in 2000 in the article Design Principles and Design Patterns by Robert Martin, also known as Uncle Bob. 





Two decades have passed since then. The question arises - are these principles still relevant? 





This is a translation of Uncle Bob 's article , published in October 2020, in which he discusses the relevance of SOLID principles for modern development.       





I recently received an email with some of the following considerations:





For years, knowledge of SOLID principles has been the standard when hiring. The candidates were expected to be confident in these principles. Later, however, one of our managers, who hardly ever writes code anymore, wondered if this was reasonable. He argued that the open-closed principle has become less important, since for the most part we no longer write code for large monoliths. And making changes to compact microservices is safe and easy.





The Liskov substitution principle has long been outdated, because we no longer pay as much attention to inheritance as we did 20 years ago. I think we should consider Dan North 's position on SOLID - “Write Simple Code”





In response, I wrote the following letter.





The SOLID principles remain as relevant today as they were 20 years ago (and before that). Because software hasn't changed much over the years, which in turn is a consequence of the fact that software hasn't changed much since 1945, when Turing wrote the first lines of code for an electronic computer. Software is still operators if



, loops, while



and assignment operations - Sequence, Selection, Iteration .    





Each new generation likes to think that their world is very different from the world of the previous generation. Every new generation is wrong about this, which they find out about as soon as the next generation comes along to tell them how much things have changed. <laughter>





So, let's go through the principles in order. 





SRP - Single Responsibility Principle .





, . , . 





, . - . SQL- . , , , . , , , .  





. , , . 





, ( , , ). SRP - “ ”. . SRP - .  





OSP - Open-Closed Principle -





, . 





, - , . , , , . , , ? if



, , ?





... ? - , ? !





.





(. , , )





. ó - . , , . - “ ”. . , . .





LSP - Liskov Substitution Principle





, , . 





( ) , . . . , . , , . , if/switch



.





- . .





, . - , .





ISP - Interface Segregation Principle





, .  





- . , , . , - A B , , B A.





, Java, C#, C++, GO, Swift .. , - Maven Leiningen . 





.





(. “ , ” “ !!”)





, , .





(. “ - !”)





, , (SRP). .





DIP - Dependency Inversion Principle





. .





, . - . , , . , , , SQL-, . . , , , , , .





In each case, Den's slides end with the phrase “Write Simple Code”. This is good advice. However, if the years have taught us anything, it is that simplicity requires discipline guided by principles. It is these principles that define simplicity. It is this discipline that drives programmers to write simple code.





The best way to create confusion is to tell everyone “keep it simple” and not give any further instructions. 








All Articles