{"id":31805141,"url":"https://github.com/zahidrahimoon/designpatterns","last_synced_at":"2025-10-11T02:46:50.535Z","repository":{"id":304577498,"uuid":"1019057350","full_name":"zahidrahimoon/designpatterns","owner":"zahidrahimoon","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-14T00:16:25.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-14T02:49:55.366Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zahidrahimoon.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-13T16:37:33.000Z","updated_at":"2025-07-14T00:16:29.000Z","dependencies_parsed_at":"2025-07-14T02:49:57.769Z","dependency_job_id":"55aa73b7-f9bd-4929-8d0e-979e2421212a","html_url":"https://github.com/zahidrahimoon/designpatterns","commit_stats":null,"previous_names":["zahidrahimoon/designpatterns"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/zahidrahimoon/designpatterns","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zahidrahimoon%2Fdesignpatterns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zahidrahimoon%2Fdesignpatterns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zahidrahimoon%2Fdesignpatterns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zahidrahimoon%2Fdesignpatterns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zahidrahimoon","download_url":"https://codeload.github.com/zahidrahimoon/designpatterns/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zahidrahimoon%2Fdesignpatterns/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279005958,"owners_count":26084004,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-11T02:46:48.473Z","updated_at":"2025-10-11T02:46:50.529Z","avatar_url":"https://github.com/zahidrahimoon.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Design Patterns Made Simple\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n[![JavaScript](https://img.shields.io/badge/language-JavaScript-blue.svg)](https://developer.mozilla.org/en-US/docs/Web/JavaScript)\n\nWelcome!  \nThis repository is all about **Design Patterns** in JavaScript, explained in a way that's easy to understand—even if you're just starting out.  \nYou'll find simple explanations, real-world examples, and code you can actually use.  \n**Everyone is welcome to contribute, ask questions, or suggest improvements!**\n\n---\n\n## 📚 Table of Contents\n\n- [What Are Design Patterns?](#what-are-design-patterns)\n- [Why Use Design Patterns?](#why-use-design-patterns)\n- [Types of Design Patterns](#types-of-design-patterns)\n  - [Creational Patterns](#creational-patterns)\n  - [Structural Patterns](#structural-patterns)\n  - [Behavioral Patterns](#behavioral-patterns)\n- [JavaScript Tips](#javascript-tips)\n- [How to Contribute](#how-to-contribute)\n- [License](#license)\n\n---\n\n## What Are Design Patterns?\n\n**Design patterns** are like reusable solutions to common problems you face when writing code.  \nThink of them as recipes or blueprints that help you solve issues in a smart, proven way.\n\n\u003e **Real-life example:**  \n\u003e Imagine you want to make a sandwich. You don’t invent a new way every time—you follow a recipe.  \n\u003e Design patterns are like those recipes, but for code!\n\n---\n\n## Why Use Design Patterns?\n\n- **Save time:** No need to reinvent the wheel.\n- **Write better code:** Patterns help you organize your code so it’s easier to read and maintain.\n- **Work with others:** Patterns are a common language among developers.\n\n\u003e **Tip:**  \n\u003e Use patterns when they make your code simpler or solve a real problem.  \n\u003e Don’t use them just for the sake of it!\n\n---\n\n## Types of Design Patterns\n\nDesign patterns are usually grouped into three main types.  \nLet’s look at each, with easy words and real-world examples.\n\n---\n\n### 🏗️ Creational Patterns\n\nThese patterns help you create objects in your code, kind of like how you might use different ways to make a pizza (by hand, with a machine, etc).\n\n#### 1. Singleton\n\n- **What it does:** Makes sure there’s only one of something.\n- **Real-world example:**  \n  Think of a single President in a country—there’s only one at a time.\n- [See code example](./creationaldesignpatterns/singleton/index.js)\n\n#### 2. Factory Method\n\n- **What it does:** Lets you create objects without saying exactly what kind of object you want.\n- **Real-world example:**  \n  Like ordering a drink at a café—you just say “coffee” and the barista decides which cup and method to use.\n- [See code example](./creationaldesignpatterns/factorymethod/index.js)\n\n#### 3. Abstract Factory\n\n- **What it does:** Makes families of related objects.\n- **Real-world example:**  \n  Buying a furniture set (table + chairs) that all match.\n- [See code example](./creationaldesignpatterns/abstractfactorymethod/index.js)\n\n#### 4. Builder\n\n- **What it does:** Helps you build complex objects step by step.\n- **Real-world example:**  \n  Building a burger by adding ingredients one at a time.\n- [See code example](./creationaldesignpatterns/builderpattern/index.js)\n\n#### 5. Prototype\n\n- **What it does:** Makes new objects by copying an existing one.\n- **Real-world example:**  \n  Photocopying a document to make a new copy.\n- [See code example](./creationaldesignpatterns/prototypepattern/index.js)\n\n---\n\n### 🧩 Structural Patterns\n\nThese patterns show you how to put objects together, like building blocks.\n\n#### 1. Adapter\n\n- **What it does:** Lets things work together even if they weren’t designed to.\n- **Real-world example:**  \n  Using a travel plug adapter to charge your phone in another country.\n- [See code example](./structuraldesignpatterns/adapterpattern/index.js)\n\n#### 2. Decorator\n\n- **What it does:** Adds new features to something without changing how it works inside.\n- **Real-world example:**  \n  Putting a case on your phone to add protection or style.\n- [See code example](./structuraldesignpatterns/decoratorpattern/index.js)\n\n#### 3. Facade\n\n- **What it does:** Hides complex stuff behind a simple interface.\n- **Real-world example:**  \n  Using a TV remote instead of pressing buttons on the TV itself.\n- [See code example](./structuraldesignpatterns/facadepattern/index.js)\n\n#### 4. Proxy\n\n- **What it does:** Acts as a go-between for something else.\n- **Real-world example:**  \n  A receptionist who takes calls and passes messages to the boss.\n- [See code example](./structuraldesignpatterns/proxypattern/index.js)\n\n---\n\n### 🤝 Behavioral Patterns\n\nThese patterns are about how objects talk to each other and share work.\n\n#### Chain of Responsibility\n\n- **What it does:** Passes a request along a chain until someone handles it.\n- **Real-world example:**  \n  Customer support: your question goes from the chatbot, to a junior agent, to a manager if needed.\n\n#### Iterator\n\n- **What it does:** Lets you go through items in a collection one by one.\n- **Real-world example:**  \n  Flipping through pages in a book, one at a time.\n\n#### Observer\n\n- **What it does:** Lets objects know when something happens.\n- **Real-world example:**  \n  Subscribing to a YouTube channel—you get notified when there’s a new video.\n\n---\n\n## JavaScript Tips\n\n- Use modern JavaScript (like `class`, arrow functions, etc.) for clear code.\n- Patterns are ideas, not strict rules—adapt them to what makes sense for your project.\n- Keep your code simple and easy to read.\n\n---\n\n## How to Contribute\n\nWe’d love your help!  \nIf you want to add new patterns, fix something, or make this guide even easier to understand:\n\n1. **Fork** this repository\n2. **Create a branch** for your changes\n3. **Open a pull request** with a clear description\n\nQuestions and suggestions are always welcome—just open an issue or pull request!\n\n---\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzahidrahimoon%2Fdesignpatterns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzahidrahimoon%2Fdesignpatterns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzahidrahimoon%2Fdesignpatterns/lists"}