Return to site

Naming in code: variables, methods, classes, ...

1)

  • Low Coupling (This is how much a class knows about other classes.) 
  • High Cohesion (This is how specific your class/method is.)

2)

  • DON"T public void findByIdAndName(int id, String name) {} 
  • DO public void findBy(int id, String name) {}

3)

  • Name variable in camel case 
  • Name constants in all caps and words separated with an underscore 
  • Name classes in pascal case

4)

  • Whenever possible, use a constant value instead of a literal number.