Welcome to the SOLID Principles repository 🤟 This repository is dedicated to providing examples, explanations, and resources related to the SOLID principles of object-oriented design. Whether you are a beginner looking to learn about these principles or an experienced developer seeking to refine your skills, this repository has something for you.
The SOLID principles are a set of five design principles intended to make software designs more understandable, flexible, and maintainable. The principles were introduced by Robert C. Martin, also known as Uncle Bob, and have since become a fundamental part of object-oriented design.
Goal of this principle is that a class should only have one repsonsibility, only single reason to change. You may think why this principle is improtant? By apply this principle in our code, we can improve the ability of team working and reduce conflices.
A class or method, should be open for extension and close to modification. That mean, we can always come back and add new functionality, but never change the previous code base.Why this rule is important? When we modify a code base which is stable and test by end users, we take the risk of making new bugs!By help of interfaces and abstract class we can achive to this goal.
Sub classes should be sustitutable for their base classes without facing to abnormal behavior of thier base classes.
In simple word, keep the interfaces seprated.Our classes should not force to implement interface contracts which is irrelevent to them.
Main reason which DIP introduce is to reduce classes from it's dependencies. Instead, we depend on contracts and abstraction.By applying DIP in our code, our class will focus on his own responsibility.
Note
Remember that, to deeply understad this principles, you should keep reading about them and try to implement them in your code bases.
Now, you can go and see the code which I write down at this repo.Every dll is assign to signle principle. There are two class, one of them violate principle and in another one, I write down the code base on the principle.
Here are some recomended resources to learn more about solid principles:
SOLID: The First 5 Principles of Object Oriented Design
The SOLID Principles of Object-Oriented Programming Explained in Plain English
SOLID Principles in Programming: Understand With Real Life Examples
I wellcom contributions from the community! If you have another examples or resources to share, please submit a pull request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository.
- Create new branch(git checkout -b example/newExample)
- Make your changes.
- Commit your changes.(git commit -m "example: your example"
- Push the branch.(git push origin example/newExample)
- Open a pull request.
This repository is licensed under the MIT License. See the LICENSE file for more information.