CTT .Net User's Group: Take Advantage of Custom Attributes - Sep 24, 2003 - Toronto - -8

Although it might seem that everything that a developer could want to do can be accomplished within the bounds of a class hierarchy, the reality is (of course) something different. There are instances where the functionality that needs to be applied to a group of classes actually cuts across the hierarchy. One of the more common instances of this need is the ability for an object to be serialized into a stream of characters. It would be nice to be able to implement serialization once and be able to apply it to all classes without needed to embed it in every base class.

In the .NET world, this functionality is accomplished through the use of attributes. In this presentation, we looked not only at the mechanics behind defining your own set of attributes, but also at the impact that they can have on the design of the class hierarchy and some of the uses to which they can be put.

This presentation included:

  1. Introduction to Attributes
    • Why are they useful
    • Aspect-Oriented Programming
    • How Attributes Impact Your Class Design

  2. Creating a Custom Attribute
    • Building a Custom Attribute
    • Using a Custom Attribute

  3. Putting Attributes to Use
    • Logging method calls
    • How NUnit uses attributes to implement its functionality


Download the slides and demos using the icons on the right.