I suffer from the inability to correctly name my classes. Colleagues also suffer from this =)
Here is some collection of rules for how to name the correct class. It is clear that he should reveal the essence of the class’s work, but how I understand his work may differ from how his colleague understands his work. This partly says that the class itself is not correctly designed, but nevertheless.
For example, I have a class that I need in order to generate an html page, and place it in the jboss temp directory so that the REST method returns a link to this page.
Actually, I named the class buildingList.class
Everything works fine, but I can’t think of a name for a pancake.
Answer 1, authority 100%
Well, they seem to have written everything correctly, nevertheless the element of understatement remained – I hasten to fill the gap (following the traces of the document Java Naming Convention and my experience):
- Class names: start with a capital letter and must be nouns like
- Interface names: start with a capital letter and must be an adjective, such as:
Buildable– also in CamelCase
- Method names: start with a lowercase letter and must be verbs (style
CamelCase ), type:
- Variable names: start with a small letter, like:
myList– in the style of CamelCase
- Package names: all in small letters, like:
com.builder.list– not in style
CamelCase , it is customary to name packages with the owner’s domain name, such as:
ru.padawan.builder.list, it is considered good practice to register your domain name and actively use your domain name with package names.
- Constant names: all capitalized, like:
MY_LIST_CONSTANT– CamelCase style is not
applies, words are separated by underscores.
CamelCase (literally camel case ) is when each new word is capitalized, such as:
This is an Example of CamelNaming Style
Read BEM (Block-Element-Modifier) as an example article: