# OO Design Principles

### SOLID Principle:

* SOLID is a mnemonic acronym for five different OOD principles intended to make software design more understandable, flexible and maintainable.
* Combining this five principles, it makes easy for the programmer to develop a software that are easy to maintain and extend.
* It makes easy to avoid code smells and easy code refractor.

**S - Single-responsibility**

A class should have one and only one reason to change, states that a class should have only one job.

**O - Open-Closed**

Objects or entities should be open for extend and closed for modification. It means that, class should be easily extendable instead of modifying the class directly.

**L - Liskov Substitution**

It states that every subclasses/derived classes should be substitutable for their base/parent class.

**I - Interface Segregation**

A client should never be forced to implement an interface that it doesn't use or clients shouldn't be forced to depend on methods they do not use.

**EX:** Creating a single interface for multiple objects, create different interfaces based on their requirements.

**D - Dependency Inversion**

Entities must depend on abstractions not on concretions. It states that the high level module must not depend on the low level module, but they should depend on abstractions.

### DRY Principle:

* DRY - Don't repeat yourself is a software development principle aimed at reducing the repetition of software patterns. It is replaceable, to avoid redundancy with abstraction or using data normalization.
* This principle is stated as Every piece of knowledge must have a single, clear-cut, authoritative responsibility within a system.
* &#x20;When the DRY principle is applied successfully, a modification of any single element of a system does not require a change in other logically unrelated elements. Additionally, elements that are logically related all change predictably and uniformly, and are thus kept in sync.

### Other principles:

**KISS** -  "Keep it simple, silly", "keep it short and simple", "keep it simple and straightforward", "keep it small and simple", or "keep it stupid simple".

&#x20;**GRASP -** General Responsibility Assignment Software Patterns.

&#x20;**IDEF4 -** Integrated DEFinition for Object-Oriented Design - design of component-based client/server systems.


---

# 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://javascript-1.gitbook.io/design-pattern/oo-design-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.
