ποΈ Software Design & Architecture¶
From OOP principles to system architecture. The art of structuring code that survives change.
π The Design Hierarchy¶
Principles (SOLID, DRY, KISS)
β
Paradigms (OOP, Functional, Procedural)
β
Design Patterns (GoF, Enterprise, Concurrency)
β
Architecture Patterns (Layered, Hexagonal, Event-Driven)
β
System Architecture (Monolith, Microservices, Distributed)
β
Diagrams & Documentation (UML, C4, ADRs)
π§± Core Principles¶
SOLID¶
| Principle | Meaning | Resource |
|---|---|---|
| S Single Responsibility | One class, one reason to change | YouTube |
| O Open/Closed | Open for extension, closed for modification | YouTube |
| L Liskov Substitution | Subtypes must be substitutable for base types | YouTube |
| I Interface Segregation | Many specific interfaces > one general interface | YouTube |
| D Dependency Inversion | Depend on abstractions, not concretions | YouTube |
Other Principles¶
| Principle | Meaning |
|---|---|
| DRY | Don't Repeat Yourself |
| KISS | Keep It Simple, Stupid |
| YAGNI | You Aren't Gonna Need It |
| Composition over Inheritance | Prefer has-a over is-a |
| Separation of Concerns | Each module handles one concern |
| Law of Demeter | Talk only to immediate friends |
| Principle of Least Surprise | Code should do what the reader expects |
| Tell, Don't Ask | Tell objects what to do, don't query and decide |
Resources¶
| Resource | Link |
|---|---|
| Clean Code (Uncle Bob talks) | YouTube |
| Clean Architecture (Uncle Bob) | YouTube |
| SOLID Principles (NPTEL) | NPTEL Software Engineering |
𧬠Programming Paradigms¶
Object-Oriented Programming (OOP)¶
| Concept | What |
|---|---|
| Encapsulation | Bundle data + behavior, hide internals |
| Inheritance | Reuse via parent-child relationships |
| Polymorphism | Same interface, different implementations |
| Abstraction | Expose what, hide how |
| Course | Platform | Link |
|---|---|---|
| OOP in Java (NPTEL) | NPTEL (IIT Kharagpur) | NPTEL |
| OOP in C++ (NPTEL) | NPTEL (IIT Kharagpur) | NPTEL |
| OOP Design (MIT OCW) | MIT | MIT OCW |
Functional Programming¶
| Concept | What |
|---|---|
| Pure Functions | No side effects, same input β same output |
| Immutability | Data never changes after creation |
| Higher-Order Functions | Functions that take/return functions |
| Composition | Build complex from simple functions |
| Monads | Chainable computation contexts |
| Course | Platform | Link |
|---|---|---|
| Functional Programming (Haskell) | edX (audit) | edX |
| Category Theory for Programmers | YouTube (Bartosz Milewski) | YouTube |
| Functional Programming in Scala | Coursera (audit) | Coursera |
Other Paradigms¶
| Paradigm | Use Case | Language Examples |
|---|---|---|
| Procedural | Scripts, embedded, OS | C, Bash, Fortran |
| Declarative | Config, queries, UI | SQL, HTML, Terraform |
| Reactive | Event streams, UI | RxJS, Reactor, Akka |
| Actor Model | Concurrency, distributed | Erlang, Akka, Go (goroutines) |
| Data-Oriented | Performance-critical, games | C, C++ (ECS pattern) |
| Logic | AI, constraint solving | Prolog |
π¨ Design Patterns¶
GoF (Gang of Four) 23 Classic Patterns¶
Free reference: refactoring.guru/design-patterns
Creational (Object Creation)¶
| Pattern | When | Example |
|---|---|---|
| Singleton | One instance globally | Logger, Config |
| Factory Method | Delegate creation to subclasses | UI widget factories |
| Abstract Factory | Families of related objects | Cross-platform UI |
| Builder | Complex object construction | Query builders, configs |
| Prototype | Clone existing objects | Game entity spawning |
Structural (Composition)¶
| Pattern | When | Example |
|---|---|---|
| Adapter | Incompatible interfaces | Legacy API wrappers |
| Bridge | Separate abstraction from implementation | Platform-independent rendering |
| Composite | Tree structures | File systems, UI components |
| Decorator | Add behavior dynamically | Middleware, logging wrappers |
| Facade | Simplify complex subsystems | SDK wrappers |
| Flyweight | Share common state | Text rendering, game tiles |
| Proxy | Control access | Lazy loading, caching, auth |
Behavioral (Communication)¶
| Pattern | When | Example |
|---|---|---|
| Observer | Event notification | Pub/sub, UI events |
| Strategy | Interchangeable algorithms | Sorting, compression |
| Command | Encapsulate actions | Undo/redo, task queues |
| State | Object behavior changes with state | TCP connection states |
| Template Method | Algorithm skeleton with hooks | Framework lifecycle |
| Iterator | Sequential access | Collections, streams |
| Chain of Responsibility | Pass request along handlers | Middleware pipelines |
| Mediator | Centralize communication | Chat rooms, event buses |
| Visitor | Add operations without modifying classes | AST traversal, serialization |
Concurrency Patterns¶
| Pattern | What | Use Case |
|---|---|---|
| Producer-Consumer | Queue between threads | Task processing |
| Thread Pool | Reuse threads | Web servers |
| Future/Promise | Async result placeholder | API calls |
| Actor Model | Message-passing concurrency | Distributed systems |
| Monitor | Mutual exclusion + condition vars | Shared resources |
| Read-Write Lock | Multiple readers, single writer | Caches, databases |
| Barrier | Synchronize thread groups | Parallel computation |
| Double-Checked Locking | Lazy init in multithreaded | Singleton |
Enterprise Patterns¶
| Pattern | What | Link |
|---|---|---|
| Repository | Abstract data access | martinfowler.com |
| Unit of Work | Track changes, batch commits | martinfowler.com |
| CQRS | Separate read/write models | martinfowler.com/bliki/CQRS |
| Event Sourcing | Store events, not state | eventstore.com |
| Saga | Distributed transactions | microservices.io/patterns/saga |
| Circuit Breaker | Fail fast on downstream failure | martinfowler.com |
| Bulkhead | Isolate failures | docs.microsoft.com |
Resources¶
| Resource | Link |
|---|---|
| Refactoring Guru (visual, free) | refactoring.guru |
| Head First Design Patterns (talks) | YouTube |
| Game Programming Patterns (free book) | gameprogrammingpatterns.com |
| Christopher Okhravi (YouTube) | youtube.com/@ChristopherOkhravi |
| Derek Banas (YouTube) | youtube.com/@deaborrekbanas |
ποΈ Architecture Patterns¶
Application Architecture¶
| Pattern | When | Diagram |
|---|---|---|
| Layered (N-Tier) | Traditional web apps | Presentation β Business β Data |
| Hexagonal (Ports & Adapters) | Testable, framework-independent | Core β Ports β Adapters |
| Clean Architecture | Domain-centric, dependency inversion | Entities β Use Cases β Interface Adapters β Frameworks |
| Onion Architecture | Similar to Clean, .NET world | Domain β Application β Infrastructure |
| Vertical Slice | Feature-based organization | Each feature owns its full stack |
| Event-Driven | Async, decoupled systems | Events β Handlers β Side Effects |
| Pipe and Filter | Data transformation pipelines | Input β Filterβ β Filterβ β Output |
| Microkernel (Plugin) | Extensible systems | Core + Plugins |
System Architecture¶
| Pattern | Scale | Use Case |
|---|---|---|
| Monolith | Small-medium | Start here. Always. |
| Modular Monolith | Medium | Monolith with clear boundaries |
| Microservices | Large, multiple teams | Independent deployment |
| Service Mesh | Microservices at scale | Istio, Linkerd |
| Serverless | Event-driven, variable load | AWS Lambda, Cloud Functions |
| Edge Computing | Low latency, IoT | Cloudflare Workers, Fly.io |
| CQRS + Event Sourcing | Complex domains | Finance, audit trails |
Resources¶
| Resource | Link |
|---|---|
| Martin Fowler (Architecture) | martinfowler.com/architecture |
| Microsoft Azure Architecture Center | learn.microsoft.com/azure/architecture |
| Microservices.io (Chris Richardson) | microservices.io |
| Clean Architecture (Uncle Bob talk) | YouTube |
| Hexagonal Architecture (Alistair Cockburn) | alistair.cockburn.us |
| Software Architecture Monday (Mark Richards) | youtube.com/@markrichards5014 |
π Diagrams & Documentation¶
Diagram Types¶
| Diagram | Purpose | Tool |
|---|---|---|
| C4 Model | System context β Container β Component β Code | c4model.com |
| UML Class Diagram | Static structure (classes, relationships) | PlantUML |
| UML Sequence Diagram | Interaction over time | Mermaid |
| UML Activity Diagram | Workflow/process flow | draw.io |
| Entity-Relationship (ER) | Database schema | dbdiagram.io |
| Data Flow Diagram (DFD) | How data moves through system | draw.io |
| Architecture Decision Record | Why decisions were made | adr.github.io |
Diagramming Tools (Free)¶
| Tool | Best For | Link |
|---|---|---|
| Mermaid | Diagrams as code (in Markdown) | mermaid.js.org |
| PlantUML | UML from text | plantuml.com |
| draw.io (diagrams.net) | General diagramming | app.diagrams.net |
| Excalidraw | Whiteboard-style | excalidraw.com |
| D2 | Declarative diagrams | d2lang.com |
| Structurizr | C4 model | structurizr.com |
From Design to Code¶
1. Requirements (PRD / User Stories)
β
2. System Design (C4 Context + Container diagrams)
β
3. API Contract (OpenAPI / Protobuf)
β
4. Data Model (ER diagram β migrations)
β
5. Component Design (Class/Sequence diagrams)
β
6. Implementation (TDD: test β code β refactor)
β
7. Review (ADR for decisions, PR for code)
π Books¶
| Book | Free? | Link |
|---|---|---|
| Refactoring Guru (Patterns) | β | refactoring.guru |
| Game Programming Patterns | β | gameprogrammingpatterns.com |
| Architecture of Open Source Apps | β | aosabook.org |
| Clean Code (talks) | β (talks) | YouTube |
| Domain-Driven Design (talks) | β (talks) | youtube.com/@ddd_eu |
| Patterns of Enterprise Application Architecture | β | martinfowler.com/eaaCatalog (catalog free) |
| Design Patterns (GoF) | β | refactoring.guru (explanations free) |
Cross-references: Best Practices Β· Systems Track Β· Product Engineering Β· Interview Prep