design-patterns

Quick-reference guide to software design patterns with concise Dart examples.

View project on GitHub

⚡ Design Patterns under 1 min

Quick-reference guide to software design patterns with concise Dart examples.

Dart 27 patterns Concise

🏗️ Creational

All about object instantiation.

Pattern Description
🏭 Abstract Factory Create families of related objects based on context
🧱 Builder Construct complex objects step by step
🔨 Factory Method Let subclasses decide which class to instantiate
♻️ Object Pool Reuse expensive objects instead of recreating them
🐑 Prototype Clone existing objects instead of building from scratch
1️⃣ Singleton Ensure a class has only one instance

🧩 Structural

All about composing classes and objects.

Pattern Description
🔌 Adapter Make incompatible interfaces work together
🌉 Bridge Decouple abstraction from implementation
🌳 Composite Treat individual objects and groups uniformly
🎀 Decorator Add behavior dynamically without subclassing
🏛️ Facade Simplify a complex subsystem with one interface
🪶 Flyweight Share common state to save memory
📦 Module Encapsulate code with controlled public API
🔒 Private Class Data Restrict write access to class attributes
🛡️ Proxy Control access via a surrogate object

🎭 Behavioral

All about communication between objects.

Pattern Description
⛓️ Chain of Responsibility Pass requests along a handler chain
📝 Command Encapsulate actions as objects with undo support
🔤 Interpreter Evaluate sentences in a language grammar
🔄 Iterator Access collection elements sequentially
📡 Mediator Centralize complex communication between objects
💾 Memento Capture and restore object state
🚫 Null Object Provide a do-nothing default to eliminate null checks
👀 Observer Notify dependents when state changes
🔀 State Change behavior when internal state changes
🎯 Strategy Swap algorithms at runtime
📋 Template Method Define algorithm skeleton, let subclasses fill in steps
🚶 Visitor Add operations to classes without modifying them