10 Aspect-Oriented Programming by design

 

In this chapter

  • Recapping the SOLID principles
  • Using Aspect-Oriented Programming to prevent code duplication
  • Using SOLID to achieve Aspect-Oriented Programming

There’s a big difference between cooking at home and working in a professional kitchen. At home, you can take all the time you want to prepare your dish, but in a commercial kitchen, efficiency is key. Mise en place is an important aspect of this. This is more than in-advance preparation of ingredients; it’s about having all the required equipment set up, including your pots, pans, chopping boards, tasting spoons, and anything that’s an essential part of your workspace.

The ergonomics and layout of the kitchen is also a major factor in the efficiency of a kitchen. A badly laid out kitchen can cause pinch points, high levels of disruption, and context switching for staff. Features like dedicated stations with associated specialized equipment help to minimize the movement of staff, avoid (unnecessary) multitasking, and encourage concentration on the task at hand. When this is done well, it helps to improve the efficiency of the kitchen as a whole.

In software development, the code base is our kitchen. Teams work together for years in the same kitchen, and the right architecture is essential to be efficient and consistent, keeping code repetition to a minimum. Your “guests” depend on your successful kitchen strategy.

10.1 Introducing AOP

10.2 The SOLID principles

10.2.1 Single Responsibility Principle (SRP)

10.2.2 Open/Closed Principle (OCP)

10.2.3 Liskov Substitution Principle (LSP)

10.2.4 Interface Segregation Principle (ISP)

10.2.5 Dependency Inversion Principle (DIP)

10.2.6 SOLID principles and Interception

10.3 SOLID as a driver for AOP

10.3.1 Example: Implementing product-related features using IProductService

10.3.2 Analysis of IProductService from the perspective of SOLID

10.3.3 Improving design by applying SOLID principles

10.3.4 Adding more Cross-Cutting Concerns

10.3.5 Conclusion

Summary