Understanding the SOLID Principles

The article is about the “SOLID principles”, which are five important principles of object-oriented programming and design and which recurring theme is the dependency’s avoidance, these are:

Single Responsibility Principle: this statement says that a class should have just one responsibility, and that it might be just changed if there’s exactly one reason

Open/Closed Principle: here we talk about that a class or function should be open for extension but closed for modification

Liskov Substitution Principle: ability to work with a child class inside a function that is expecting the base class

Interface Segregation Principle: avoid writing giant interfaces that classes may not need or want

Dependency Inversion Principle: instead of writing code that refers to actual classes, better write code that refers to interfaces or abstract classes

These practices are interesting as the refactoring or pattern practices, the reason makes sense after you read the description and imagine the times you were involved in a situation that required you to do something similar. I’m impress because I think these practices are obvious in certain way but underestimated, yes, it makes a lot of sense to apply them.  The practice that was weird to me was the “open/close principle” because before I was told at “programming fundamentals and POO” to try to implement inheritance in every oportunity, but with this I think I comprehend that this is not the best practice.

Something interesting is that “Uncle Bob” the protagonist of our previous entry was acknowledged as the first person who identify these principles, but the acronym was introduced later by Michael Feathers. In other hand, other thing that surprised me was the C# code, which one I’ve used previously, but without certain functionality (the var keyword) before. I hope to apply some of these practices in some exercises to help me fully understand the application.

Comentarios

Entradas populares de este blog

WarGames

First Entrance

Ethical Reflection on Ready Player One