Skip to content

Latest commit

 

History

History
58 lines (57 loc) · 2.14 KB

namingConventions.md

File metadata and controls

58 lines (57 loc) · 2.14 KB

The naming convention/ style guide to be followed for this repo.

(Applicable to all java codes that is pushed)

  1. Classes and Interfaces :
    Class names should be nouns, in mixed case with the first letter of each internal word capitalised. Interfaces name should also be capitalised just like class names.
  2. Methods :
    Methods should be verbs, in mixed case with the first letter lowercase and with the first letter of each internal word capitalised. eg.
    void changeGear(int newValue);
  3. Variables :
    Variable names should be short yet meaningful.
    Should be mnemonic i.e, designed to indicate to the casual observer the intent of its use.
  4. Constant variables:
    Should be all uppercase with words separated by underscores (“_”).
  5. Javadoc:
    /**
    * Multiple lines of Javadoc text are written here,
    * wrapped normally...
    * @param:
    * @return
    */
    public int method(String p1) { ... }
    These beautiful doc comments can be auto generated in VS code, given the java plugins are installed, and you press /**/ over a function.
  6. Same line parenthesis policy:
    for (....) {    // allowed
    for (...)     // not allowed
    {
  7. Proper spacing:
    notice the difference. Proper spacing between the ( ) blocks and also between operators, e.g +, =, *
    for (int i = 0; i < n; i += 1) {    // good
    for(int i=0;i<n;i+=1){    // bad
  8. Tab over spaces:
    Indent using tab of size 4.
  9. Readable code:
    "Code should be self-documenting, that is, your naming should make it obvious what something does". exmaple:
    public boolean shouldConsiderAbbreviating(List<String> someNames) {
      for (String eachName : someNames) {    // notice how proper naming improves readability
        if (isTooLong(eachName)) {      // notice how to check if name is too long, we have used a function to improve readablity
          return true;
        }
      }
      return false;
    }
  10. Break big functions:
  11. Reduce nesting: