Jetlag and Attributes


I don’t really want to have one of those blogs were I regail you with details of my recent travel exploits, the fun I had being folded into economy class across the Atlantic, details of my family and friends, what I think of sharing a Shuttle Bus to the airport and back.. I mean, let’s face it, you don’t really care that it’s taken me a week to shift the 8 hour time difference and get back into a routine.

The real point is that my brain is still working at about 60% capacity (that’s of my own brain, not an average human brain) and so it’s likely I’m still talking nonsense a large part of the time.

However, even when I was operating at full speed, I had problems getting the concept of C# “Attributes” clear in my head. It seems strange to pepper perfectly logical sourcecode with these weird things in square brackets.

Do you “grok” Attributes? Do you use them? If so, what for? Let me know, as I’m working on the Attributes portion of the C# docs right now and want to make sure the information that most C# programmers need is in there.

And now it’s time to sneak another little piece of UK chocolate..


Comments (4)

  1. Mark Mullin says:

    Check out the CommandLineParser on codeproject.com – xlnt little utility to make command line attribute coding for console apps easy and powerful – core of the design is based on attributes and reflection – f’rinstance, here’s the complete definition of a attribute to get user name – stick this in your code, call the parser when you start, member variable automagically populated-

    [CommandLineSwitch("Name","User Name")]

    [CommandLineAlias("User")]

    public string UserName

    {

    get { return m_SomeName; }

    set { m_SomeName = value; }

    }

    ps – take melatonin – it helps A LOT!!!!!!!

  2. NUnit is a good example as well. Also "Obsolete".

    I didn’t really understand the use of attributes until working with the Common Information Model (lookup Windows Management Instrumentation WMI for details)

    The CIM relies on attributes to advise behaviour to model clients.

  3. Michael Eber says:

    Attributes are extremely important and used quite frequently in the application I write.

    Examples of use:

    1) providing a professional application property setting window that uses the PropertyGrid. Nothing works in the PropertyGrid without proper attributes set on the accessor.

    2) setting of required security levels for a section of code or an entire application. Both from the aspect of what is required as well as asserting what I want.

    What has been lacking from the Attribute aspect? DOCUMENTATION!!!!

Skip to main content