martinfowler.com logo Home Blog Articles Books About Me Contact Me ThoughtWorks

Annotation design Reactions

An annotation on a program element (commonly a class, method, or field) is a piece of meta-data added to that program element which can be used to embellish that element with extra code.

In Java this is called an annotation, in C# this is called an attribute. C# has had them since its first release, in Java they appeared with version 1.5.

A good example of an attribute is the [Obsolete] attribute in C# to mark elements that are going out of service (the same as deprecated in Java). The Obsolete attribute can take arguments to print messages and to indicate if using the element is an error or a warning. The language platform comes with many annotation defined, but allows you to add your own annotations.

When writing about programming, I prefer to use 'annotation' as the general term. Although .NET was first, the word 'attribute' is just too widely used for different things.


Links
home
bliki
feed 
Translations
Japanese
Spanish
Korean
Chinese
Thai
Categories
agile
design
dsl
leisure
refactoring
ruby
thoughtWorks
tools
uml
writing
Blog Roll
ThoughtBlogs
TW Alumni
Nicholas Carr
Steve Cook
Brian Foote
Simon Harris
Gregor Hohpe
/\ndy Hunt
Ralph Johnson
Patrick Logan
David Ing
Brian Marick
Jeremy Miller
Jimmy Nilsson
Samuel Pepys
Keith Ray
Johanna Rothman
Kathy Sierra
Dave Thomas

martinfowler.com logo mingle logo thoughtworks logo

© Copyright Martin Fowler, all rights reserved