# Design Patterns and Principles

![](https://raw.githubusercontent.com/Devansh-Maurya/Design-Patterns-And-Principles/master/Design%20Patterns%20%26%20Principles.png)

### What are Design Principles?

**A design principle is a basic tool or technique that can be applied to designing or writing code to make that code more maintainable, flexible, or extensible.**

[Explore the Design Principles on this website](/design-patterns-and-principles/design-principles.md)

### What are Design Patterns?

**A design pattern is a solution to a problem in a context.**

* The **context** is the situation in which the pattern applies. This should be a recurring situation.
* The **problem** refers to the goal you are trying to achieve in this context, but it also refers to any constraints that occur in the context.
* The **solution** is what you’re after: a general design that anyone can apply which resolves the goal and set of constraints.

If you find yourself in a context with a problem that has a goal that is affected by a set of constraints, then you can apply a design that resolves the goal and constraints and leads to a solution.

[Explore the Design Patterns on this website](/design-patterns-and-principles/design-patterns.md)

**Credits:** This repo is a collection of the notes I made while reading the book **Head First Design Patterns**. The Head First Design Patterns book is a great read if you are just starting to learn design patterns or if you want to learn patterns in a non-boring and non-academic way.


---

# 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://devansh233.gitbook.io/design-patterns-and-principles/master.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.
