Return to site

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

May 27, 2020

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.