Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering

User Tools

Site Tools

Java Coding Conventions


  • Use Java-style: start with lower-case letter, do not use underlines
  • Like this: veryLongVarName
  • Don't use: A_very_long_var_name
  • Why: Sun Standard

Method Names

  • see Variables

Field Names

  • see Variables

Package Names

  • Use Java-style: use only lower-case letters, avoid underlines
  • Like this: packagename
  • Don't use: Package_name
  • Why: Sun Standard

Getter Methods

  • Methods starting with get must have no side effects.
    Exception: Singleton Implementation
  • Like this: public int getI() { return i;}
  • Don't use: public int getI() { i = 3*i + 2; return i; }
  • Why: Called more than one time they may change the state of the system.

Field visibility

  • Fields must have a private of protected visibility
  • Why: This enables the simple replacement of a class with an interface, avoids unwanted write access, encapsulates field access for later additional processing and enhances the intiutive work with a code assist (get CTRL+SPACE).
teaching/labs/xp/2005a/codingconventionsjava.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2024