Architecture Patterns
Common architectural patterns and design decisions.
Layered Architecture
code
Presentation → Business Logic → Data Access → Database
Clean Architecture
code
Controllers
↓
Use Cases
↓
Entities
Common Patterns
Repository
code
interface UserRepository {
findById(id): User
save(user): void
}
Service Layer
code
class UserService {
constructor(repo: UserRepository)
createUser(data): User
}
Dependency Injection
- •Pass dependencies via constructor
- •Program to interfaces, not implementations
- •Enables testing with mocks
Design Principles
- •SOLID: Single responsibility, Open/closed, Liskov, Interface segregation, Dependency inversion
- •DRY: Don't repeat yourself
- •KISS: Keep it simple
- •YAGNI: You aren't gonna need it