A comprehensive collection of design patterns implemented in JavaScript and TypeScript, with clear examples and explanations to help you write better, more maintainable code.
Created with β₯ by:
Design patterns are proven solutions to recurring problems in software design. They provide standardized templates for solving common coding challenges, enabling you to build more organized, modular, and flexible codebases.
Each design pattern includes:
- Explanation: Detailed overview of the pattern's purpose, benefits, and use cases
- Code Examples: Clear JavaScript/TypeScript implementations
- Real-World Use Cases: Practical applications and scenarios
- Best Practices: Tips for effective implementation
Focus on object creation mechanisms, providing flexibility in how objects are instantiated.
Deal with object composition and relationships, forming larger structures from individual components.
Define communication patterns between objects and how they collaborate.
Provide guidance on organizing application structure for scalability and maintainability.
Visit the live site: https://matiascarabella.github.io/design-patterns-js
Simply visit the GitHub Pages link above to explore all patterns interactively!
- Node.js (v14 or higher)
- npm or yarn
- Clone the repository:
git clone https://github.com/matiascarabella/design-patterns-js
cd design-patterns-js- Install dependencies:
npm install- Start the development server:
npm start- Open http://localhost:3000 in your browser
This project is ready for GitHub Pages deployment:
- Push your code to GitHub
- Go to your repository Settings β Pages
- Under "Source", select the
mainbranch - Click Save
- Your site will be live at
https://matiascarabella.github.io/repository-name
No build step required - it's all static HTML/CSS/JS!
- JavaScript fundamentals and ES6+ features
- Singleton - Ensure a class has only one instance
- Builder - Construct complex objects step by step
- Observer - Define one-to-many dependencies between objects
- Strategy - Define a family of algorithms and make them interchangeable
- State - Allow an object to alter its behavior when its state changes
- Bridge - Decouple abstraction from implementation
- Decorator - Add responsibilities to objects dynamically
- Flux - Unidirectional data flow architecture
design-patterns-js/
βββ index.html # Main landing page
βββ 01 - JS Intro/ # JavaScript fundamentals
β βββ index.html
β βββ js/intro.js
βββ 02 - Creational/
β βββ singleton/ # Singleton pattern
β βββ decorator/ # Builder pattern
βββ 03 - Behavioral/
β βββ observer/ # Observer pattern
β βββ strategy/ # Strategy pattern
β βββ state/ # State pattern
βββ 04 - Structural/
β βββ bridge/ # Bridge pattern
β βββ decorator/ # Decorator pattern
βββ 05 - Architectural/
β βββ flux/ # Flux pattern
βββ package.json
βββ README.md
βββ DEPLOYMENT.md # GitHub Pages deployment guide
This repository is based on content from the Udemy Design Patterns Course and various online resources.
Feel free to explore, experiment, and adapt the code to your projects. Contributions and improvements are welcome!
This project is licensed under the MIT License.
