{"id":26120699,"url":"https://github.com/alideweb/design-patterns-ts","last_synced_at":"2025-03-10T13:43:51.482Z","repository":{"id":281362265,"uuid":"945043820","full_name":"AliDeWeb/Design-Patterns-Ts","owner":"AliDeWeb","description":"Examples of design patterns and guide how to implement them ;)","archived":false,"fork":false,"pushed_at":"2025-03-08T15:22:26.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-08T15:30:47.082Z","etag":null,"topics":["design-patterns","oop","oop-in-javascript","oop-in-typescript","oop-principles","ts","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AliDeWeb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2025-03-08T14:29:05.000Z","updated_at":"2025-03-08T15:27:43.000Z","dependencies_parsed_at":"2025-03-08T15:42:10.939Z","dependency_job_id":null,"html_url":"https://github.com/AliDeWeb/Design-Patterns-Ts","commit_stats":null,"previous_names":["alideweb/design-patterns-ts"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AliDeWeb%2FDesign-Patterns-Ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AliDeWeb%2FDesign-Patterns-Ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AliDeWeb%2FDesign-Patterns-Ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AliDeWeb%2FDesign-Patterns-Ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AliDeWeb","download_url":"https://codeload.github.com/AliDeWeb/Design-Patterns-Ts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242863893,"owners_count":20197672,"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","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":["design-patterns","oop","oop-in-javascript","oop-in-typescript","oop-principles","ts","typescript"],"created_at":"2025-03-10T13:43:50.737Z","updated_at":"2025-03-10T13:43:51.454Z","avatar_url":"https://github.com/AliDeWeb.png","language":"TypeScript","readme":"# 🐦‍🔥 Design Patterns In TS - Principles and Rules\n\n### By Ali Moradi [AliDeWeb](https://github.com/AliDeWeb)\n\n### Principles of Object-Oriented Programming (OOP):\n\n1. **Encapsulation** – Bundling data and methods within a class while restricting direct access to some details.\n2. **Abstraction** – Hiding complex implementation details and exposing only the necessary functionality.\n3. **Inheritance** – Allowing a class to inherit properties and behaviors from another class to promote code reuse.\n4. **Polymorphism** – Enabling multiple classes to be treated as instances of a common superclass, allowing method overriding and dynamic behavior.\n\n---\n\n### **SOLID Principles:**\n\n1. **Single Responsibility Principle (SRP)** – A class should have only one reason to change, meaning it should have only one responsibility.\n2. **Open/Closed Principle (OCP)** – Software entities should be open for extension but closed for modification.\n3. **Liskov Substitution Principle (LSP)** – Subtypes must be substitutable for their base types without altering the correctness of the program.\n4. **Interface Segregation Principle (ISP)** – Clients should not be forced to depend on interfaces they do not use.\n5. **Dependency Inversion Principle (DIP)** – High-level modules should not depend on low-level modules; both should depend on abstractions.\n\n---\n\n### **Other Important Principles:**\n\nApart from SOLID, other key design principles in OOP include:\n\n- **DRY (Don’t Repeat Yourself)** – Avoid duplication by abstracting reusable code.\n- **KISS (Keep It Simple, Stupid)** – Keep code simple and avoid unnecessary complexity.\n- **YAGNI (You Ain’t Gonna Need It)** – Don’t implement features unless absolutely necessary.\n- **Law of Demeter (LoD)** – Objects should only interact with closely related objects to reduce coupling.\n\nThese principles ensure maintainability, scalability, and clean code.\n\n## 📂 Types of Design Patterns\n\nDesign patterns are categorized into three main types:\n\n### **1. Behavioral Patterns**\n\nThese patterns focus on communication between objects and how they interact with each other.\n\n- **Observer** – Defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified.\n- **Strategy** – Allows an object to change its behavior dynamically by switching between multiple algorithms.\n- **Command** – Encapsulates a request as an object, allowing for parameterization of clients, queuing of requests, and logging of operations.\n\n### **2. Structural Patterns**\n\nThese patterns deal with the composition of classes and objects to form larger structures while keeping them flexible and efficient.\n\n- **Adapter** – Bridges the gap between incompatible interfaces.\n- **Decorator** – Dynamically extends the functionality of an object without modifying its code.\n- **Facade** – Provides a simplified interface to a complex subsystem.\n\n### **3. Creational Patterns**\n\nThese patterns focus on object creation mechanisms to increase flexibility and reuse.\n\n- **Factory Method** – Provides an interface for creating objects but allows subclasses to alter the type of objects created.\n- **Singleton** – Ensures that a class has only one instance and provides a global point of access to it.\n- **Builder** – Allows the step-by-step creation of complex objects, improving readability and maintainability.\n\n## 📂 Patterns\n\n| Design Pattern              | Documentation                                     |\n| --------------------------- | ------------------------------------------------- |\n| **Memento**                 | [📜 README](01_Memento/README.md)                 |\n| **State**                   | [📜 README](02_State/README.md)                   |\n| **Iterator**                | [📜 README](03_Iterator/README.md)                |\n| **Strategy**                | [📜 README](04_Strategy/README.md)                |\n| **Template Method**         | [📜 README](05_Template_Method/README.md)         |\n| **Command**                 | [📜 README](06_Command/README.md)                 |\n| **Observer**                | [📜 README](07_Observer/README.md)                |\n| **Chain Of Responsibility** | [📜 README](09_Chain_Of_Responsibility/README.md) |\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falideweb%2Fdesign-patterns-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falideweb%2Fdesign-patterns-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falideweb%2Fdesign-patterns-ts/lists"}