Skip to content

MatiasCarabella/design-patterns-js

Repository files navigation

Design Patterns in JavaScript

JavaScript TypeScript HTML5 CSS3

Stars Forks

A comprehensive collection of design patterns implemented in JavaScript and TypeScript, with clear examples and explanations to help you write better, more maintainable code.

About Us

Created with β™₯ by:

What Are Design Patterns?

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.

What's Inside

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

Pattern Categories

πŸ—οΈ Creational Patterns

Focus on object creation mechanisms, providing flexibility in how objects are instantiated.

πŸ”§ Structural Patterns

Deal with object composition and relationships, forming larger structures from individual components.

🎯 Behavioral Patterns

Define communication patterns between objects and how they collaborate.

πŸ›οΈ Architectural Patterns

Provide guidance on organizing application structure for scalability and maintainability.

🌐 Live Demo

Visit the live site: https://matiascarabella.github.io/design-patterns-js

Getting Started

Option 1: View Online (Recommended)

Simply visit the GitHub Pages link above to explore all patterns interactively!

Option 2: Run Locally

Prerequisites

  • Node.js (v14 or higher)
  • npm or yarn

Installation

  1. Clone the repository:
git clone https://github.com/matiascarabella/design-patterns-js
cd design-patterns-js
  1. Install dependencies:
npm install
  1. Start the development server:
npm start
  1. Open http://localhost:3000 in your browser

πŸš€ Deploying to GitHub Pages

This project is ready for GitHub Pages deployment:

  1. Push your code to GitHub
  2. Go to your repository Settings β†’ Pages
  3. Under "Source", select the main branch
  4. Click Save
  5. Your site will be live at https://matiascarabella.github.io/repository-name

No build step required - it's all static HTML/CSS/JS!

πŸ“š Available Patterns

01 - JavaScript Intro

  • JavaScript fundamentals and ES6+ features

02 - Creational Patterns

  • Singleton - Ensure a class has only one instance
  • Builder - Construct complex objects step by step

03 - Behavioral Patterns

  • 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

04 - Structural Patterns

  • Bridge - Decouple abstraction from implementation
  • Decorator - Add responsibilities to objects dynamically

05 - Architectural Patterns

  • Flux - Unidirectional data flow architecture

Repository Structure

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

Learn More

This repository is based on content from the Udemy Design Patterns Course and various online resources.

Contributing

Feel free to explore, experiment, and adapt the code to your projects. Contributions and improvements are welcome!

License

This project is licensed under the MIT License.

About

JavaScript design patterns with interactive examples - Creational, Structural, Behavioral & Architectural patterns in JS/TS.

Topics

Resources

License

Stars

Watchers

Forks

Contributors