This repository contains examples demonstrating the SOLID principles in a C# project. Each principle (S, O, L, I, and D) is demonstrated with a simple right and wrong use case. Additionally, you can explore the code to see a correct and incorrect usage as a straightforward example.
This repository is inspired by the SOLID repository created by EduardoPires. You can find the original repository here. It provides a comprehensive collection of SOLID principle examples in C#.
To run the examples, follow the steps below:
- Clone the repository:
git clone https://github.com/MauricioSuporte/SOLID.git
- Open the solution in your preferred IDE.
- Build the solution to ensure all dependencies are resolved.
- Run the program.
Upon running the program, a menu with five options will appear. Each option corresponds to a specific SOLID principle and executes a code snippet showcasing a simple correct usage example.
Option 1: Demonstrates a class with a single responsibility, adhering to the SRP.
Option 2: Illustrates a class that follows the OCP, allowing for extension without modification.
Option 3: Shows a correct implementation of the LSP, where subclasses can be used interchangeably with the superclass.
Option 4: Presents an example of adhering to the ISP by having interfaces specific to the clients needs.
Option 5: Highlights the correct usage of the DIP by depending on abstractions rather than concrete implementations.
Choose an option from the menu to explore the examples and learn more about each SOLID principle.
By understanding and applying the SOLID principles, developers can create maintainable, extensible, and testable code. This repository provides examples of correct and incorrect usage of the SOLID principles, helping developers grasp the concepts and apply them effectively in their projects.
Feel free to explore the examples provided and learn from them!