nilbuild /design-patterns-for-humans
An ultra-simplified explanation to design patterns
★ 48,941⑂ 5,573👁 1,194⑃ 89● 53▤ 0◈ 0
48,941
stars
+2
5,573
forks
1,194
watchers
89
prs
53
issues
0
releases
0
discussions
README
🎉 Ultra-simplified explanation to design patterns! 🎉 A topic that can easily make anyone's mind wobble. Here I try to make them stick in to your mind (and maybe mine) by explaining them in the simplest way possible. Check out my other project and say "hi" on Twitter. |Creational Design Patterns|Structural Design Patterns|Behavioral Design Patterns| |:-|:-|:-| |Simple Factory|Adapter|Chain of Responsibility| |Factory Method|Bridge|Command| |Abstract Factory|Composite|Iterator| |Builder|Decorator|Mediator| |Prototype|Facade|Memento| |Singleton|Flyweight|Observer| ||Proxy|Visitor| |||Strategy| |||State| |||Template Method| Introduction ================= Design patterns are solutions to recurring problems; guidelines on how to tackle certain problems. They are not classes, packages or libraries that you can plug into your application and wait for the magic to happen. These are, rather, guidelines on how to tackle certain problems in certain situations. Design patterns are solutions to recurring problems; guidelines on how to tackle certain problems Wikipedia describes them as In software engineering, a software design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. It is not a finished design that can be transformed directly into source or machine code. It is a description or template for how to solve a problem that can be used in many different situations. ⚠️ Be Careful ----------------- - Design patterns are not a silver bullet to all your problems. - Do not try to force them; bad things are supposed to happen, if done so. - Keep in mind that design patterns are solutions to problems, not solutions finding problems; so don't overthink. - If used in a correct place in a correct manner, they can prove to be a savior; or else they can result in a horrible mess of a code. Also note that the code samples below are in PHP-7, however this shouldn't stop you because the concepts are same anyways. Types of Design Patterns ----------------- Creational Structural Behavioral Creational Design Patterns ========================== In plain words Creational patterns are focused towards how to instantiate an object or group of related objects. Wikipedia says In software engineering, creational design patterns are design patterns that deal with object creation mechanisms, trying to create objects in a manner suitable to the situation. The basic form of object creation could result in design problems or added complexity to the design. Creational design patterns solve this problem by somehow controlling this object creation. Simple Factory Factory Method Abstract Factory Builder Prototype Singleton 🏠 Simple Factory -------------- Real world example Consider, you are building a house and you need doors. You can either put on your carpenter clothes, bring some wood, glue, nails and all the tools required to build the door and start building it in your house o
Top issues
#28Wrong Composite Pattern Definition11 comments · 2017-02-17#122adding more coding language support - DISCUSSION2 comments · 2020-04-23#81Interpreter pattern1 comments · 2017-03-11#157Proxy example does not match the Door interface signature0 comments · 2026-09-20#154Patternizing Data0 comments · 2025-01-09#144Recommendation: Use VitePress for Improved Documentation Structure0 comments · 2024-06-13