Basically, the design patterns are typical solutions to commonly occurring problems in software engineering. They act as pre-made blueprints that we can customize to solve recurring design problems within our code.
My point is to show you how they are structured (according to me) by examples. I am going to try to cover the most common design patterns and within this repo, also I am going to use TypeScript as a programming language.
I haven't used any kind of AI tools like ChatGPT, CoPIlot, or any other "crutches" for the mind.
Creational | Structural | Behavioral |
---|---|---|
Factory method | Decorator | Command |
Abstract Factory | Adapter | Chain of Responsibility |
Builder | Facade | Observer Pattern |
Prototype | Bridge | Interpreter |
Singleton | Composite | Iterator |
Flyweight | Mediator | |
Proxy | Memento | |
State | ||
Strategy | ||
Template | ||
Visitor |
After confirming that your environment meets the above requirements, it is time to clone the project ocally by doing the following:
$ git clone [email protected]:DeanHristov/ts-design-patterns-cheat-sheet.git <project-name>
$ cd <project-name>
When you're done with the steps above, run the following command:
$ npm install # or yarn install
Running the app in development mode with HMR.
$ npm run start:dev
All examples can be seen in the test files(/src/[dirname]/[filename].spec.ts)
Firstly, build the app with the following command:
$ npm run build
Then run following command to start the app in production mode.
$ npm start
All tasks automation are based on NPM scripts.
Tasks | Description |
---|---|
npm run start:dev |
Running the app in dev mode |
npm run build |
Building the code in production-ready mode |
npm run start |
Running the app in prod mode |
npm run test |
Running the unit tests ( using jest) |
npm run test:dev |
Running the unit with --watchAll mode ( using jest) |
npm run lint |
Code lining |
npm run prettier-format |
Code formatting |
- NodeJS- https://nodejs.org/en/
- Git - https://git-scm.com/
- TypeScript - https://www.typescriptlang.org/
- typescript
- prettier
- ts-jest
- jest
- ts-node
- eslint
- eslint-config-prettier
- eslint-plugin-jest
- eslint-plugin-prettier
- rimraf
- nodemon
Author: D. Hristov | Documentation