How nahidulhasan/solid-principles works
This project is a repository composed of a series of examples that demonstrate the SOLID principles with a clear “good design vs. bad design” comparison for each principle. In other words, it isn’t a full-fledged enterprise application but rather an educational resource or reference implementation aimed at explaining how to correctly (and incorrectly) apply each SOLID principle in PHP.
Main Components
– Single Responsibility Principle (SRP)
– Open-Closed Principle (OCP)
– Liskov Substitution Principle (LSP)
– Interface Segregation Principle (ISP)
– Dependency Inversion Principle (DIP)
• Within several of these, the design is split between “GoodDesign” and “BadDesign” examples. Represent these as subcomponents or branches where applicable.
File Structure as Architectural Modules
• For Single Responsibility Principle:
– Show two distinct modules: one for “BadDesign” (which contains code that combines responsibilities), and one for “GoodDesign” (which refactors responsibilities into separate classes, plus a repository component).
• For Open-Closed Principle:
– Create a module with branches for “BadDesign” and “GoodDesign”.
• For Interface Segregation Principle:
• For Liskov Substitution Principle:
– Represent this module with its multiple example files that demonstrate correct and sometimes incorrect subtype behavior.
• For Dependency Inversion Principle:
– Exhibit a module that highlights the move from tightly coupled dependencies (e.g., instantiating a MySQLConnection directly) to working with an abstraction (a ConnectionInterface).
– Show how the “OrdersReport” component in SRP interacts with both the “OrdersRepository” (for data access) and the output formatter (for presentation), highlighting the decoupling achieved.
– In OCP, show how the CostManager depends on the abstraction (AreaInterface) rather than concrete implementations.
• If appropriate, include connections between good and bad design modules to emphasize improvements from violating to adhering to a principle.
Architectural Patterns and Design Principles
• Separation of concerns evident in the “GoodDesign” versions.
• Use of interfaces in both the Open-Closed and Dependency Inversion examples.
• Strategy of splitting responsibilities (for SRP) and segregating interfaces (for ISP).
Technologies and Concepts
• You may also annotate that the repository is structured to illustrate the SOLID principles as a set of best practices rather than an integrated full-stack system.