The SOLID/STUPID principles
The SOLID principles are a set of five design guidelines that help developers create more maintainable, understandable, flexible, and testable software. Introduced by Robert C. Martin, also known as Uncle Bob, these principles have become a cornerstone of object-oriented programming and design.
SOLID is an acronym, with each letter standing for the first letter of a principle.
The SOLID principles
Single Responsibility
A class should have one, and only one, reason to change. So a class should have only one responsibility.
Note: this definition may vary. Some developers prefer to define it as:
Separate code that supports different actors.
Code should have a reason to change based on the actors involved in the project. Therefore, you should organize the code according to the different actors.
Open/Closed
Objects or entities should be open for extension but closed for modification.
Liskov Substitution
Let q(x) be a property provable about objects of x of type T. Then q(y) should be provable for objects y of type S where S is a subtype of T.
In other words: Subclasses should be able to substitute their parent classes without affecting the behavior of the program.
Interface Segregation
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
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.
The STUPID principles
The STUPID principles are a set of anti-patterns in software design that you should avoid.
Singleton
Ensures a class has only one instance, but overusing it can lead to global state and tight coupling, making testing and maintenance difficult.
Tight Coupling
When modules are highly dependent on each other, changes in one module require changes in another, reducing flexibility and reusability.
It refers to Dependency Inversion from SOLID principle.
Untestability
Code that is hard to test, often due to tight coupling or reliance on global state, making it difficult to write unit tests.
Premature Optimization
Optimizing code before it’s necessary, which can lead to complex and hard-to-maintain code without significant performance benefits.
Indescriptive Naming
Using unclear or ambiguous names for variables, methods, or classes, making the code hard to understand and maintain.
Duplication
Repeating code in multiple places instead of reusing it, leading to more maintenance work and potential inconsistencies.
Other notes
To be a proficient software developer, it’s essential to understand both the SOLID and STUPID principles.
You may encounter other principles such as KISS (Keep It Simple, Stupid) and DRY (Don’t Repeat Yourself), which stem from the SOLID principles.
Happy coding! 😊
Create a Docker Swarm playground
Let's create Docker Swarm playground on your local machine
Setup a Kubernetes cluster with K3S, Traefik, CertManager and Kubernetes Dashboard
Let's setup step by step our own K3S cluster !
Create an Ansible playground with Docker
Let's create an Ansible playground with Docker
Database ACID/BASE - Understanding the CAP Theorem
Learn what is the CAP Theorem in less than 5 minutes !
HashiCorp Vault - Technological watch
Learn what is HashiCorp Vault in less than 5 minutes !
How to internationalize an AstroJS website while maintaining good SEO ?
We will see how to create an implementation of i18n with AstroJS
Remember all the commands of a project with Makefile
We will see how to remember all command of a project & write documentation with Makefile !
LFTP - Deploy an application in command line
Here we will see how to automatically deploy an application with lftp in command line.