Any indication of an enumeration suffix (kind versus type)?

I am developing a .NET API for public use. There are many enumerations in my API, and I'm struggling to decide whether to use suffixes.

In the .NET Framework, I see examples of using both Good (for example, System.DateTimeKind ) and Type (for example, System.IO.DriveType ).

Looking at the public enumerations in mscorlib, I see that the โ€œTypeโ€ is used more often, but both of them are still used in some new types, which means that Microsoft does not adhere to any specific agreement on this.

Does anyone have any recommendations on what to use in my API? Are there any published conventions covering this topic?

I tend to use โ€œKindโ€ as a suffix and reserve the term โ€œTypeโ€ to handle System.Type objects or data types.

+6
source share
2 answers

The only naming convention I know from Microsoft regarding enumerations is (from msdn )

  • Use the Pascal argument for names and name names.
  • Reduce the use of abbreviations.
  • Do not use the Enum suffix for names of type Enum.
  • Use a unique name for most Enum types, but use a plural name for Enum types, which are bit fields.
  • Always add the FlagsAttribute attribute to the Enum type in the bit field.

It is quite old, but does not see any update in relation to this.

I donโ€™t think anyone can tell you the โ€œrightโ€ approach for your particular question, since both options are valid and it is just a matter of taste.

I would say that you must agree with the general strategy with the team and adhere to it. I think itโ€™s more important that everyone uses the same naming convention than the one you use.

I personally use the Type suffix, but then again, it's just a matter of taste.

+4
source

Name your listings descriptive phrases nouns, describing that listing (e.g. RegexOptions , DateTimeKind , BorderStyle , etc.). Do not force to use arbitrary suffixes. The name must come naturally from the fact that .

+2
source

Source: https://habr.com/ru/post/946797/


All Articles