Annotations/Decorators/Attributes are a language feature found in multiple languages, such as JavaScript/TypeScript, Java and C# to name a few.

I've been trying to find some information about how people/projects go about deciding how to name their annotations.

I've found a mix of both using nouns, adjectives and verbs. For most other language types there are common (not always good) guidelines for how to approach naming but annotations seems consistently excluded.

How do you reason about naming these, or how to interpret the ones you find in your own codebases? Do you leverage some common overlap from some other naming conventions such as for classes or functions? How do you make them express what effect they have or what the annotated item represents?

  • 1
    They can serve different purposes conceptually (e.g., sometimes they are just markers or metadata, sometimes they produce wrappers, inject elements, modify behavior), so it may make sense not to require them to always be nouns/adjectives/verbs. And because they have their own syntax, it's not necessary to communicate that they are annotations in the name itself. As with all other names, try to find something that best communicates the concept behind it, as understood first and foremost by your team (they are your readership - don't try to write for "the industry"). Commented Oct 27, 2020 at 16:10

1 Answer 1


Attributes or annotations should be named so their usage makes sense. Nouns, verbs, adjectives — all of that supports how this will be used:

public ActionResult Index()
    // ...

The [Authorize] attribute in .NET web applications is a verb.

[DisplayName("E-mail address")]
public string Email { get; set; }

The [DisplayName(...)] attribute is a noun.

What matters is how the code reads. These annotations and attributes are meta data, and should first and foremost describe the meta data. The fact these things are classes is an artifact of them being implemented in object oriented languages. The normal guidelines for naming classes do not necessarily apply, because the use case is different.

Name them so it makes sense when using the annotations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.