An open API service indexing awesome lists of open source software.

https://github.com/vahidvdn/realworld-design-patterns

Explore real-world scenarios and best practices for design patterns with their unit tests โœ…
https://github.com/vahidvdn/realworld-design-patterns

ci clean-code design-patterns diagrams javascript monorepo nodejs nx-workspace oop oop-principles principles solid testing typescript unit-test

Last synced: 2 months ago
JSON representation

Explore real-world scenarios and best practices for design patterns with their unit tests โœ…

Awesome Lists containing this project

README

        

![design-pattern-cover](assets/cover.png)

# Real World Design Patterns

Explore real-world scenarios and best practices for design patterns in this comprehensive repository.

[![Automated Tests Passing](https://github.com/vahidvdn/realworld-design-patterns/actions/workflows/ci.yml/badge.svg)](https://github.com/vahidvdn/realworld-design-patterns/actions/workflows/ci.yml)
[![codecov](https://codecov.io/github/vahidvdn/realworld-design-patterns/graph/badge.svg?token=E21ZMGM3M9)](https://codecov.io/github/vahidvdn/realworld-design-patterns)
![Nx](https://img.shields.io/badge/Powered%20by-Nx-0ca5e9)
![License](https://img.shields.io/badge/License-MIT-blue.svg)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-orange.svg)](https://github.com/vahidvdn/realworld-design-patterns/compare)
![GitHub User's stars](https://img.shields.io/github/stars/vahidvdn%2Frealworld-design-patterns)


Elevate your software design skills with practical examples and insightful discussions. This workspace has been generated by [Nx, Smart Monorepos ยท Fast CI](https://nx.dev). For each design pattern, there is folder based on `TypeScript`. If you are comming from another programming language world, don't worry. They are not complicated. Also, tests are included for each pattern. Also you can see bad practices to understand use cases.

## How to Learn? ๐Ÿ“–

You can open directory, for instance:

```
$ cd app/strategy-pattern
```

There is a `README` file that you can review first.

## Structure of Readme

Here is some steps in each `README` file:

- ๐Ÿ’ก Use Case: a short description about the specific problem that we want to solve.
- โŒ Bad Practice: a typical solution that works but not in a proper way.
- โœ… Good Practice: implementing the specified design pattern to solve the problem in a proper way.

Diagram: There is also a diagram to represent the oveview of the design pattern to understand better. This is an example:

![design-pattern-diagram](assets/strategy-pattern.jpg)
![design-pattern-diagram](assets/command-pattern.jpg)
![design-pattern-diagram](assets/chain-of-res.jpg)

See `/app` folder for all design patterns. โœ…

## How to Run

In the root directory, run:

```
$ npm install
```

To run the design pattern:

```
$ npm run -w PATTERN_NAME start
```

For instance **PATTERN_NAME** can be strategy-pattern

To run the bad practice:

```
$ npm run -w PATTERN_NAME start:bad
```

## Run Tests

In order to run tests, run the following command. (add `:watch` to run it in watch mode):

```
$ npm run test
```

## Test Coverage

Run the following command to evaluate test coverage:

```
$ npm run test:cov
```

To see the coverage report, just run:

```
$ npm run test:cov:open
```

## Contributing

Contributing to a community project is always welcome.

## Checklist

- [x] Strategy Pattern
- [x] Dependency Injection Pattern
- [x] Chain of Responsibility Pattern
- [x] Builder Pattern
- [x] Decorator Pattern
- [x] Template Method Pattern
- [x] Observer Pattern
- [x] Command Pattern
- [ ] Proxy Pattern
- [ ] Adapter Pattern

## Support

Any support is welcome. You can give the project a star, if you liked it โญ

## License

MIT