Attributes in .Net are given the red headed stepchild treatment; misunderstood, misused, and widely ignored (at least in most of the projects I’ve worked on). They were one of those new features exposed by .Net that most of us coming from a legacy background simply didn’t understand…for me personally it was a matter of “I’ll learn about them when I get around to it, or when a project calls for their use.” I’ve done a sprinkling of custom attribute work, but nothing that I would consider hard core. I picked up Applied .Net Attributes this weekend; at just over 200 pages it’s a quick read (and probably the shortest book in my technical library), took me all of 2 hours…but a very good one. We’ve all heard the TLA Aspect Oriented Programming being thrown around like it’s the next OOP; admittedly I know next to nothing about AOP beyond the basics, but this book does a good high level job of explaining how custom attribute development lends itself to the AOP paradigm and has some great sample code to illustrate this.
It also explores some advanced .Net concepts such as context bound objects and custom context attribute development (2 concepts I was largely unfamiliar with outside the realm of seeing them mentioned from time to time in various reads, nothing in depth though). After reading about the above mentioned concepts and how they relate to .Net attributes, I can definitely see the benefits of exploring this some more. I have an old exception management/logging library (mundane plumbing code that no one really likes to write..well, I do) that I wrote a while back, I started gutting it recently (in what little spare time I have) to see what AOP/custom attributes can bring to the table for this type of scenario. Of course, anyone having used nUnit (which should be all of us) knows how powerful custom attributes can be.
So all in all, a highly recommended read…and short enough that it won’t take too many brain clock cycles out of your day gig.