Skip to main content

Understanding the SOLID principles


On today’s blog we are going to talk about the SOLID principles, which were discovered by Robert Martin, the famous Uncle Bob from the podcast of the previous entry. This principles are recommended to be used whenever someone wants to create an object oriented program. There are 5 principles where the acronym SOLID comes from which are the following
  • Single Responsibility Principle (SRP) -> it says that any class should only have one responsibility. Yet, the author ends up saying that there might be some classes that have two responsibilities (the invoicing class that has some logging routines). In the end, I didn’t understand this principle well because I found the explanation confusing (as the author said, practice is much more difficult than theory). 

  • Open/Closed Principle (OPC) -> open extension but closed modification Although the author says that if you change a parent class method it might kill another part of the code, I think that this would only reflect your lack of knowledge of your own code, and we should have the capacity of modifying our own code.

  • Liskov Substitution Principle (LSP) -> avoiding inheritance, as we have seen before, is actually a really useful advice. I think that we should try to use composition as much as we can.

  •  Interface Segregation Principle (ISP) -> I had never heard about this principle before, which describes that instead of having a huge interface that has many different methods, we should create a bunch of small interfaces. I find this principle pretty useful, because it is easier to refactor a small and well-organized code.

  • Dependency Inversion Principle (DIP) -> this last principle says that we should code base on abstractions, rather than coding based on concrete objects. I think this is also a great advice. If we code thinking that our objects might changes, and that they should look like this, instead of being like this, it would be easier to modify them and to adapt the future.

Comments

Popular posts from this blog

Ethical Reflection on Ready Player One

Todays blog is the last one!!!!!! It has been quite a journey, but as everything, its time to end this. On today’s blog we are going to talk about a book, Ready Player One, written by Ernest Cline, this is the book that everyone in my class has been reading during the semester, and it was really, really good, I actually enjoyed it a lot. The plot is quite simple, it talks about a kid called Wade Watts, in a world were the actual real world is kind of a huge disaster for not saying other words, but in the book exist another world, a virtual one called the Oasis, were technically everyone plays it, because it was a whole new world, not only a videogame, in there people can have jobs, meet people, study in schools. The creator of the Oasis was James Halliday, and I say was because in the book he is dead, and after his dead he created 3 easter eggs that, when a player has the three, that player will own the oasis, and be the richest person in the world, and that is the goal of our dear...

Is Design Dead?

On today’s entry we are going to talk about the article “Is design dead?”, which talks about how the design has been changing through the years and how the good practices were developed in order to create a good design. Is no lie that for all the people that develops software, is kind of difficult to come up with a good design because of the lack of and standards to create it, other areas may have standards or even a methodology, but not us. Because of these needs, developers have created a bunch of good practices, not to create, but to reach a good design probably in a 85% of success. For example, a good practice is a that the code we create has to be modular in order to make corrections or complete alterations in a easier, this changes may occur for many reasons, manteinance, update the information or just to simply chage the entire code to something more efficient, the same goes to the design, but the problem is that a design is more difficult to modify when is already d...

Software Architecture

On today’s blog we are going to review a chapter from Pete Goodlife’s Code Craft, which is all about the basic theory of software architecture, where among the topics there is like the definition, reasons of why we should use it and lots of characteristics, of course it includes examples. One part of the text talks about the high level view, which is when the details of how was it created or implemented doesn’t appear, the only thing we can see is the essential internal structure of it and the most fundamental and important characteristics of its behaviour, which can come in-handy for many thing like identifying the key modules of all the software, identify and determine the nature of all the most relevant interfaces in the software, identify how and which components communicate with each other and to clarify the correct roles and responsibilities of the subsystems The chapter also talks about other 4 views for the software architecture, one of them is the conceptual view, ...