Chapter 16. Improving domain logic
This chapter covers
- Empowering objects using DI
- Implementing crosscutting business logic
- Avoiding unnecessary DTOs
So far in this book, we’ve established that AOP is useful for implementing crosscutting infrastructure functionality such as monitoring, concurrency control, transaction management, and security. Those crosscutting concerns are often the first you’ll implement with AOP. But AOP is also useful in improving the implementation of domain logic in several ways. First, aspects help in implementing dependency injection (DI) for objects not explicitly managed by a DI container. This enables the implementation of complex behavior that would otherwise be tedious. Second, by modularizing crosscutting business logic, AOP provides the same benefits it offers to crosscutting infrastructure concerns. Furthermore, AOP helps enforce design rules targeted toward the domain objects, improving the overall quality of the software system.