Domain-Driven Design Refactoring
Transform your legacy app with strategic and tactical DDD patterns.
Step-by-step transformation of anemic models to rich domain models
Real-world Car Rental application case study
Practical exercises and expert feedback
Join the waitlist to be the first to know when the course launches and get exclusive early-bird offers.
Course Outline
👋 Introduction and Course Overview
- Goals of This Course: Understanding rich domain models vs anemic ones
- DDD Fundamentals Refresher: Entities, Value Objects, Domain Services
- Tech Stack: C# with .NET 9, EF Core and PostgreSQL
- Project Setup: Car Rental codebase tour and initial pain points
🔍 Recognizing Anemic Domain Models
- Identifying anemic model symptoms: entities with only data, no behavior
- Code smells: long transaction-script methods, duplicated logic
- Real-world example: Walk through the RentCar method
- Understanding maintenance challenges and testing difficulties
🛠 Breaking Up the Transaction Script
- Identifying logical sections in procedural code
- Extract Method refactoring: pricing, date calculation, validation
- Creating high-level workflow steps
- Benefits: Resolving Long Method smell and clarifying intent
🚚 Moving Behavior into Domain Entities
- Entity behavior: Car.CalculateRentalPrice, Customer.CanRent
- Using IDE refactoring tools safely
- Transforming service code into domain calls
- Eliminating inappropriate intimacy between components
🔗 Domain Services and Cross-Cutting Logic
- Identifying cross-entity and external logic
- Creating service interfaces (e.g., IRentalPricingService)
- Refactoring external calls into domain services
- Double-dispatch pattern for service integration
🔒 Enforcing Invariants and Encapsulation
- Converting public setters to private
- Using read-only collections and proper access methods
- Validating business rules and throwing exceptions
- Implementing value objects for domain concepts
🧪 Testing and Refactoring Safety
- Writing characterization tests for existing behavior
- Unit testing domain entities and services
- Integration testing with EF Core and PostgreSQL
- Continuous feedback through automated testing
Join the waitlist to be the first to know when the course launches and get exclusive early-bird offers.
4.9/5 from 7,000+ students
Why Join This Course?
Learn how to refactor an anemic domain model into a rich, expressive model using DDD principles.
Gain hands-on experience with real-world examples and practical exercises.
Get access to expert insights and personalized feedback.