Chapter 8. Using AOP as an architectural tool
This chapter covers
- Aspect initialization
- Aspect validation
- Improving a threading aspect using validation and initialization
- Dealing with architectural constraints
- Using architectural constraints to help with NHibernate
- Working with multicasting attributes
AOP’s own architecture and its effect on the architecture of a large code base are important concepts to understand in order to use AOP effectively. When you’re designing and implementing an architecture, failing earlier in the process may reduce costs from rework, and PostSharp can help you quickly and automatically identify failures at compile time.
Until this point, we’ve been looking at PostSharp and AOP in a narrow way: one aspect and one class at a time. Let’s look at PostSharp through the eyes of an architect, viewing an entire system and how it fits together. PostSharp contains tools to make an architect’s job easier, as well as tools to make sure that the aspects themselves are well-architected.
One thing about PostSharp that may have concerned you at some point is that all of my examples involve putting attributes on individual methods and properties, which may seem tedious and repetitive, and if you had to do that with a large code base, it would be. Fortunately, PostSharp doesn’t require that you always do that. We’ll look at ways in which we can multicast aspect attributes so that we can reuse aspects without a lot of attribute repetition.