3 Writing loosely coupled code

 

In this chapter

  • Redesigning Mary’s e-commerce application to become loosely coupled
  • Analyzing that loosely coupled application
  • Evaluating that loosely coupled application

When it comes to grilling steak, an important practice is to let the meat rest before you cut it into slices. When resting, the juices redistribute, and the results get juicier. If, on the other hand, you cut it too soon, all the juice runs out, and your meat gets drier and less tasty. It’d be a terrible shame to let this happen, because you’d like to give your guests the best tasting experience you can deliver. Although it’s important to know the best practices for any profession, it’s just as important to know the bad practices and to understand why those lead to unsatisfactory results.

Knowing the difference between good and bad practices is essential to learning. This is why the previous chapter was completely devoted to an example and analysis of tightly coupled code: the analysis provided you with the why.

3.1 Rebuilding the e-commerce application

3.1.1 Building a more maintainable UI

3.1.2 Building an independent domain model

3.1.3 Building a new data access layer

3.1.4 Implementing an ASP.NET Core–specific IUserContext Adapter

3.1.5 Composing the application in the Composition Root

3.2 Analyzing the loosely coupled implementation

3.2.1 Understanding the interaction between components

3.2.2 Analyzing the new dependency graph

Summary