Coding Standards in Java

  1. Classes: Class names should be nouns, in mixed cases with the first letter of each internal word capitalized and class names should be simple and descriptive. Example: class Client, class RequestProcess, etc.
  2. Interfaces: Interface names should be capitalized like class names. Example: interface RasterDelegate; interface Storing, etc.
  3. Methods: Methods should be verbs, in mixed case with the first letter lowercase, with the first letter of each internal word capitalized. Example: run(), runFast(), getBackground(), etc.
  4. Variables: Variables in mixed case with a lowercase first letter. Internal words start with capital letters. Variable names should be short yet meaningful. Example: float myWidth , myHeight.
  5. Constants: The names of variables declared class constants and of ANSI constants should be all uppercase with words separated by underscores. Example: int MIN_WIDTH = 4; int MAX_WIDTH = 999, etc.
  1. Parentheses: It is generally a good idea to use parentheses liberally in expressions involving mixed operators to avoid operator precedence problems.


Nowadays many IDEs such as IntelliJ or Eclipse already provide code formating options using which most of the coding conventions can be followed. But we still need to add comments as they are not yet smart enough to also do it.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store