How mishad01/design-patterns-solid-principles-and-low-level-system-design works
This repository is not a single application; it is a Dart-based teaching corpus of isolated examples that demonstrate OOP, SOLID, and GoF design patterns. The architecture is primarily pedagogical: each folder is a self-contained scenario, often with a “bad/problem” version and a “good/solution” version to show how responsibilities and dependencies change.
1. Top-level structure
- The repo is divided into four main learning areas: OOP, SOLID Principles, Design Pattern Basics, Behavioral Design Pattern, and Creational Design Pattern.
- Most sections pair .dart source files with .md explanation files, so code and narrative documentation are co-located.
2. Execution model
- There is no central runtime, service, or shared application state.
- Individual Dart files act as independent demo entrypoints or example modules; architecture diagrams should treat them as standalone examples rather than as a connected system.
3. OOP subsystem
- The OOP/ folder introduces core language-level object concepts: class/object, inheritance, abstraction, polymorphism, encapsulation, static members, factory constructors, singleton usage, mixins, extensions, composition, copy-with, and operator overloading.
- This area is foundational and feeds into the design-pattern examples by establishing object relationships and reuse mechanisms.
4. SOLID Principles subsystem
- SOLID Principles/ is organized by principle: SRP, OCP, LSP, ISP, and DIP.
- Each principle usually includes a Bad Code version and a Good Code version, making the architectural boundary explicit: the “good” side extracts responsibilities into smaller classes, interfaces, or services.
- These examples are mostly about dependency direction and separation of concerns rather than infrastructure.
5. Behavioral pattern subsystem
- Behavioural Design Pattern/ contains examples for Memento, Observer, Strategy, Command, Template, Iterator, State, and Mediator.
- Each pattern is typically split into problem and solution, showing the pre-pattern coupling and the refactored pattern-based design.
- The main data flow in these demos is usually object-to-object communication: event propagation, state transitions, command execution, iteration over collections, or mediated collaboration.
6. Creational pattern subsystem
- Creational Design Pattern/ covers Singleton, Factory, Abstract Factory, Builder, and Prototype.
- These examples focus on object creation boundaries: who creates objects, how variants are chosen, and how construction is centralized or abstracted.
- The factory and singleton examples are especially important architectural boundaries because they control instantiation and shared access.
7. Problem/solution boundary as a recurring architectural motif
- Across the repo, the most important boundary is not technical infrastructure but the split between a naive implementation and a pattern/SOLID-compliant implementation.
- This makes the repository ideal for diagrams that show “before/after” structure: fewer classes and direct dependencies in the problem version, versus interfaces, factories, mediators, or strategy objects in the solution version.
8. Class relationships and dependency direction
- The examples emphasize common OO dependency shapes: inheritance trees, interface-based polymorphism, composition over inheritance, and dependency inversion.
- Many solution folders introduce indirection layers such as interfaces, abstract types, or mediator/factory objects to reduce coupling between concrete classes.
9. State and behavior flow
- Behavioral examples often model behavior as interchangeable or evolving runtime state.
- For example, Strategy and State both rely on swapping behavior objects; Mediator centralizes cross-object communication; Observer pushes updates from one source to multiple subscribers; Command encapsulates actions as objects.
10. Creation flow
- Creational examples separate “requesting an object” from “knowing its concrete type.”
- This means the flow is often: client/service asks a factory or singleton for an instance, then operates through an abstract type or interface rather than a concrete class.
11. Documentation and teaching assets
- The repository includes many Markdown files that explain the concepts and scenario-specific rationale.
- There are no signs of external dependencies, storage, APIs, or deployment infrastructure; the architecture is self-contained and language-centric.
12. How to diagram this repo accurately
- Diagram it as a set of independent modules grouped by concept, with arrows showing class relationships inside each example.
- Use special emphasis on:
- code-vs-refactor boundaries (Bad Code → Good Code, problem → solution)
- abstraction layers introduced by SOLID and patterns
- object-creation boundaries in creational patterns
- collaboration boundaries in behavioral patterns
- Avoid depicting it as a monolithic system; it is a catalog of reference implementations.
13. Primary technology boundary
- The only significant runtime technology visible from the tree is Dart.
- That matters because many examples rely on Dart-specific language features such as factory constructors, mixins, extensions, and singleton patterns.
Overall, this repo is best understood as a curated set of architecture and language-pattern demonstrations, not an integrated product. The key architectural theme is reducing coupling through abstraction, composition, and explicit object-creation/control boundaries.
Main entry points: introduction.md Patterns intro · solid_principle.md SOLID guide · transport_factory.dart Factory · OOP.md OOP guide
Components 25
OOP
Language-level object concepts and Dart-specific features
- OOP guide · Top-level OOP learning path
1. OOP/OOP.md - Procedural · Procedural baseline contrasted with OOP
1. OOP/procedural.dart - Class & object · Basic class/object modeling
1. OOP/1. Class and Object/class_and_object.dart - Inheritance · Inheritance and constructor/static/singleton examples
1. OOP/2. Inheritance/inheritance.dart - Abstraction · Abstraction, interfaces, and polymorphism
1. OOP/3. Abstraction and Polymorphism/abstract.dart - Dart features · Encapsulation, static members, factory constructors, mixins, and extensions
1. OOP/4. Encapsulation, Static & Factory Constructor, Singeltons, Mixin & Extension/encapsulation.dart - Advanced OOP · Composition, copy-with, and operator overloading
1. OOP/5. Advance Feature/composition.dart
SOLID
Principle-by-principle refactoring examples
- SOLID guide · Principles and refactoring overview
2. SOLID Principles/solid_principle.md - SRP · Single responsibility split from invoice monolith
2. SOLID Principles/1. Single Responsibility Principle (SRP)/Bad Code/invoice.dart - OCP · Open/closed payment processor design
2. SOLID Principles/2. Open Close Principle (OCP)/Bad Code/payment_processor.dart - LSP · Substitutability and readable/writable splits
2. SOLID Principles/3. Liskov Substiution Principle (LSP)/Bad Code/file.dart - ISP · Interface segregation for machine capabilities
2. SOLID Principles/4. Interface Segregation Principle (ISP)/Bad Code/machine.dart - DIP · Dependency inversion for notification delivery
2. SOLID Principles/5. Dependency Inversion Principle (DIP)/Bad Code/notification_service.dart
Behavioral
Object collaboration and runtime behavior patterns
- Memento · Snapshot and restore text editor state
4. Behavioural Design Pattern/1. Memento Pattern/solution/text_editor.dart - Observer · Subject-to-subscriber update flow
4. Behavioural Design Pattern/2. Observer Pattern/solution/ovserver_pattern.dart - Strategy · Swap algorithms at runtime
4. Behavioural Design Pattern/3. Strategy Pattern/solution/strategy_pattern.dart - Command · Encapsulate actions as invokable objects
4. Behavioural Design Pattern/4. Command Pattern/solution/command_pattern_sol_example_1.dart - State · Behavior changes through state objects
4. Behavioural Design Pattern/7. State Pattern/solution/car.dart - Mediator · Centralized chat collaboration
4. Behavioural Design Pattern/Mediator Pattern/solution/chat_room.dart
Creational
Object creation and instantiation patterns
- Singleton · Controlled single-instance access
5. Creational Design Pattern/1. Singleton Pattern/solution/app_settings.dart - Factory · Centralized transport creation
5. Creational Design Pattern/2. Factory Pattern/solution/transport_factory.dart - Abstract factory · Family-based object creation boundary
5. Creational Design Pattern/3. Abstract Pattern/problem/application.dart - Builder · Stepwise construction pattern
5. Creational Design Pattern/4. Builder Pattern/README.md - Prototype · Clone-based object creation pattern
5. Creational Design Pattern/5. Prototype Patter/README.md
Docs
Repo-wide introductions and learning guides
- Patterns intro · Design pattern basics introduction
3. Design Patterm Basics/introduction.md
Connections 27
- OOP guide → Procedural: contrasts · Procedural baseline versus object-oriented style
- OOP guide → Class & object: builds toward · Core object modeling example
- Class & object → Inheritance: extends · Inheritance builds on basic classes
- Inheritance → Abstraction: enables · Abstraction and polymorphism deepen class relationships
- Abstraction → Dart features: broadens · Encapsulation and Dart features refine object design
- Dart features → Advanced OOP: leads to · Composition and advanced object operations
- SOLID guide → SRP: frames · SRP example pair
- SOLID guide → OCP: frames · OCP example pair
- SOLID guide → LSP: frames · LSP example pair
- SOLID guide → ISP: frames · ISP example pair
- SOLID guide → DIP: frames · DIP example pair
- SRP → DIP: shares theme · Both reduce responsibility and coupling
- OCP → Factory: mirrors · Factory-style extensibility supports OCP
- LSP → State: relates · Substitutability connects to runtime behavior objects
- Patterns intro → Memento: introduces · Pattern concept guides the Memento example
- Patterns intro → Observer: introduces · Pattern concept guides the Observer example
- Patterns intro → Strategy: introduces · Pattern concept guides the Strategy example
- Patterns intro → Command: introduces · Pattern concept guides the Command example
- Patterns intro → State: introduces · Pattern concept guides the State example
- Patterns intro → Mediator: introduces · Pattern concept guides the Mediator example
- Observer → Mediator: collaborates · Observer and mediator both manage communication
- Strategy → Factory: feeds · Strategy and factories both select interchangeable variants
- Command → Factory: uses · Commands are often produced and executed through creation boundaries
- Singleton → Factory: pairs with · Singleton and factory are key creational boundaries
- Factory → Abstract factory: generalizes · Factory patterns expand into abstract factories
- Abstract factory → Builder: precedes · Builder separates construction steps after family creation
- Builder → Prototype: broadens · Prototype completes the creational set