Chapter 1. Introducing AOP
This chapter covers
- A brief history of AOP
- What problems AOP was created to solve
- Writing a very simple aspect using PostSharp
In this first chapter, I’ll start in an obvious place—introducing you to aspect-oriented programming (AOP), where it came from, and what problems it’ll help you solve.
We’ll look at several tools as you progress through this book, but I will focus on PostSharp and Castle DynamicProxy. These aren’t the only tools available to .NET developers, but they’re popular ones that have stood the test of time. The concepts and code you use in this book should still be applicable if you use a different tool (see appendix A for notes on the ecosystem of AOP tools in .NET).
We’ll use PostSharp in this chapter, but before you start typing out real code, we’ll look at features central to the software concept of AOP itself. I’ll talk about cross-cutting concerns, what a nonfunctional requirement is (and contrast it with a functional requirement), and what nonfunctional requirements have to do with AOP.
Finally, I’ll walk you through a basic “Hello, World!” example using AOP in .NET. I’ll break apart that example, identifying the individual puzzle pieces and explaining how they fit together into something called an aspect.