# SOLID Principles

![SOLID Principles](https://user-images.githubusercontent.com/24835522/98734846-3b86c580-23ab-11eb-9c80-7587043d5b8f.png)

SOLID is an acronym for five design principles for object oriented code, although SOLID can be used and adapted as principles for any form of software development.

The term SOLID was introduced by **Robert C. Martin**, and it's considered to be the base principles which its violation can cause many problems that can be solved using one of the design patterns widely known (of course not every form of violation can have a solution in a form of a design pattern).

To fully understand the design patterns, why are they made? and what problems do they solve? you should first fully grasp the five SOLID principles:

1. [Single Responsibility Principle](/design-patterns-explained/solid-principles/single-responsibility.md)
2. [Open-Closed Principle](/design-patterns-explained/solid-principles/open-closed.md)
3. [Liskov Substitution Principle](/design-patterns-explained/solid-principles/liskov-substitution.md)
4. [Interface Segregation Principle](/design-patterns-explained/solid-principles/interface-segregation.md)
5. [Dependency Inversion Principle](/design-patterns-explained/solid-principles/dependency-inversion.md)

After applying the SOLID principles to your code base, the code should be decoupled, easy to reuse, easy to extend (as we are always looking for low coupling, and high cohesion), but be aware of over-engineering without a clear vision of why you're choosing to follow these principles, by the end of the day they're only principles, not rules, they can be ignored in some cases for clear reasons and better solutions.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://khaled-hamam.gitbook.io/design-patterns-explained/solid-principles.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
