Skip to content

khosrogh/SOLID

Repository files navigation

Python Examples: Violating SOLID Principles

This repository contains Python code examples that demonstrate violations of the SOLID principles in software development. Each principle violation is showcased with code samples, highlighting the consequences and potential issues that arise when these principles are not adhered to.

Principles Covered

1. Single Responsibility Principle (SRP)

Example code showcasing situations where a class or module takes on multiple responsibilities, leading to potential code entanglement and difficulties in maintenance.

2. Open/Closed Principle (OCP)

Code snippets illustrating how failure to design for extension while being closed for modification can result in brittle and hard-to-maintain systems.

3. Liskov Substitution Principle (LSP)

Demonstrations of violations where subclasses are unable to substitute their parent class, causing unexpected behavior or breaking the program's assumptions.

4. Interface Segregation Principle (ISP)

Instances highlighting issues stemming from interfaces that are too broad, leading to unnecessary dependencies and coupling between components.

5. Dependency Inversion Principle (DIP)

Code examples depicting scenarios where high-level modules depend on low-level modules directly, rather than relying on abstractions, resulting in inflexible codebases.

Structure

The repository is organized into folders corresponding to each SOLID principle. Within each folder, you'll find:

  • Code Examples: Python scripts illustrating violations of the specific principle.
  • README.md: Detailed explanations of the principle, its importance, and the showcased violations.

How to Use

You can explore each principle's folder to understand the violations and their implications. Each example is accompanied by comments and explanations to provide clarity.

Feel free to clone or download the repository to examine the code locally.

Contributing

Contributions are welcome! If you have more examples or improvements to the existing code that highlight violations of SOLID principles, feel free to open a pull request.

Resources

For a deeper understanding of SOLID principles and their importance in software development, refer to the following resources:

License

This repository is licensed under the MIT License.

About

SOLID principles examples

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages