{"id":25284737,"url":"https://github.com/omaralalwi/solid-principles-summary","last_synced_at":"2026-01-21T10:01:55.043Z","repository":{"id":276163085,"uuid":"928401111","full_name":"omaralalwi/solid-principles-summary","owner":"omaralalwi","description":"summarize  and notes for books  about SOLID Principles","archived":false,"fork":false,"pushed_at":"2025-02-06T16:14:35.000Z","size":5,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-06T15:13:56.209Z","etag":null,"topics":["best-practices","clean-architecture","clean-code","code","design","design-pattern","design-systems","software-engineer","software-engineering","solid","solid-principles","uncle-bob"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/omaralalwi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-06T15:22:26.000Z","updated_at":"2025-03-11T19:26:56.000Z","dependencies_parsed_at":"2025-02-06T17:23:31.592Z","dependency_job_id":"3fcafc38-c1d9-4149-b96d-534a87edfcf8","html_url":"https://github.com/omaralalwi/solid-principles-summary","commit_stats":null,"previous_names":["omaralalwi/solid-principles-summary"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/omaralalwi/solid-principles-summary","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaralalwi%2Fsolid-principles-summary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaralalwi%2Fsolid-principles-summary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaralalwi%2Fsolid-principles-summary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaralalwi%2Fsolid-principles-summary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/omaralalwi","download_url":"https://codeload.github.com/omaralalwi/solid-principles-summary/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaralalwi%2Fsolid-principles-summary/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28631936,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["best-practices","clean-architecture","clean-code","code","design","design-pattern","design-systems","software-engineer","software-engineering","solid","solid-principles","uncle-bob"],"created_at":"2025-02-12T20:52:24.259Z","updated_at":"2026-01-21T10:01:55.022Z","avatar_url":"https://github.com/omaralalwi.png","language":null,"readme":"# SOLID Principles Summary\n\n## Introduction\n\nThe SOLID principles are a set of five design principles intended to make software designs more understandable, flexible, and maintainable. Introduced by Robert C. Martin (also known as Uncle Bob), these principles are essential for creating robust and scalable software systems.\n\n## Table of Contents\n\n1. [Single Responsibility Principle (SRP)](#single-responsibility-principle-srp)\n2. [Open-Closed Principle (OCP)](#open-closed-principle-ocp)\n3. [Liskov Substitution Principle (LSP)](#liskov-substitution-principle-lsp)\n4. [Interface Segregation Principle (ISP)](#interface-segregation-principle-isp)\n5. [Dependency Inversion Principle (DIP)](#dependency-inversion-principle-dip)\n6. [Conclusion](#conclusion)\n\n---\n\n## Single Responsibility Principle (SRP)\n\n### Definition\n\n\u003e A class should have only one reason to change.\n\n### Explanation\n\nThe Single Responsibility Principle states that every class or module in a program should have responsibility over a single part of the program's functionality. This means that a class should not take on multiple responsibilities, as this can lead to a higher risk of bugs and decreased maintainability.\n\n### Example\n\nConsider a `User` class that handles user data and also manages user notifications. To adhere to SRP, you should separate these responsibilities into different classes, such as `User` and `NotificationService`.\n\n```php\nclass User {\n    private $name;\n    private $email;\n\n    public function __construct($name, $email) {\n        $this-\u003ename = $name;\n        $this-\u003eemail = $email;\n    }\n\n    // User-related methods\n}\n\nclass NotificationService {\n    public function sendNotification(User $user, $message) {\n        // Send notification logic\n    }\n}\n\n```\n\n---\n\n## Open-Closed Principle (OCP)\n\n### Definition\n\n\u003e Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification.\n\n### Explanation\n\nThe Open-Closed Principle suggests that you should design your modules, classes, and functions in a way that allows you to extend their behavior without modifying their source code. This can be achieved through inheritance, interfaces, and abstract classes.\n\n### Example\n\nSuppose you have a `Shape` class with a `draw` method. To add a new shape without modifying the existing code, you can create a new class that implements the `Shape` interface.\n\n```php\ninterface Shape {\n    public function draw();\n}\n\nclass Circle implements Shape {\n    public function draw() {\n        // Draw circle logic\n    }\n}\n\nclass Square implements Shape {\n    public function draw() {\n        // Draw square logic\n    }\n}\n```\n\n---\n\n## Liskov Substitution Principle (LSP)\n\n### Definition\n\n\u003e Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it.\n\n### Explanation\n\nThe Liskov Substitution Principle states that objects of a superclass should be replaceable with objects of its subclasses without affecting the correctness of the program. This means that subclasses should maintain the behavior expected by the superclass.\n\n### Example\n\nIf you have a `Bird` class with a `fly` method, a `Penguin` subclass should not inherit from `Bird` because penguins cannot fly. Instead, you might have a `FlyingBird` class and a `Bird` class without the `fly` method.\n\n```php\nclass Bird {\n    public function speak() {\n        // Speak logic\n    }\n}\n\nclass FlyingBird extends Bird {\n    public function fly() {\n        // Fly logic\n    }\n}\n\nclass Penguin extends Bird {\n    public function swim() {\n        // Swim logic\n    }\n}\n```\n\n---\n\n## Interface Segregation Principle (ISP)\n\n### Definition\n\n\u003e No client should be forced to depend on methods it does not use.\n\n### Explanation\n\nThe Interface Segregation Principle suggests that you should create specific interfaces for each client, rather than one general-purpose interface. This prevents clients from having to implement methods they do not need.\n\n### Example\n\nInstead of having a single `Worker` interface with `work` and `eat` methods, you can split it into `Workable` and `Eatable` interfaces.\n\n```php\ninterface Workable {\n    public function work();\n}\n\ninterface Eatable {\n    public function eat();\n}\n\nclass Human implements Workable, Eatable {\n    public function work() {\n        // Work logic\n    }\n\n    public function eat() {\n        // Eat logic\n    }\n}\n\nclass Robot implements Workable {\n    public function work() {\n        // Work logic\n    }\n}\n```\n\n---\n\n## Dependency Inversion Principle (DIP)\n\n### Definition\n\n\u003e High-level modules should not depend on low-level modules. Both should depend on abstractions.\n\n### Explanation\n\nThe Dependency Inversion Principle states that high-level modules should not depend on low-level modules. Instead, both should depend on abstractions. This can be achieved through the use of interfaces and dependency injection.\n\n### Example\n\nInstead of having a `Car` class depend directly on a `Engine` class, you can have the `Car` class depend on an `Engine` interface.\n\n```php\ninterface Engine {\n    public function start();\n}\n\nclass ElectricEngine implements Engine {\n    public function start() {\n        // Start electric engine logic\n    }\n}\n\nclass Car {\n    private $engine;\n\n    public function __construct(Engine $engine) {\n        $this-\u003eengine = $engine;\n    }\n\n    public function start() {\n        $this-\u003eengine-\u003estart();\n    }\n}\n```\n\n---\n\n## Conclusion\n\nThe SOLID principles provide a framework for creating software that is modular, maintainable, and scalable. By adhering to these principles, developers can design systems that are easier to understand, test, and extend.\n\n### References\n\n- [SOLID Principles - Wikipedia](https://en.wikipedia.org/wiki/SOLID)\n- [Clean Code by Robert C. Martin](https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882)\n\n## Helpful Links\n\n- [Clean Code Summary](https://github.com/omaralalwi/clean-code-summary)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomaralalwi%2Fsolid-principles-summary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomaralalwi%2Fsolid-principles-summary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomaralalwi%2Fsolid-principles-summary/lists"}