0.0 General‎ > ‎

Best Practices

Braces{}, Brackets[] and Parentheses()
  • always type them in pairs, then add the required code between the balanced pair of "brackets"
  • instance variables must be private
  • variable names must be descriptors -- adjectives -- describing the contents of the variable
  • keep the number of instance variables to a minimum. i.e. do not store a calculated value in an instance variable, use a method to calculate and return it when needed.
  • method names must describe the action of the method -- verb or verb phrases as method names
  • do not daisy chain methods -- have method 1 call method 2 call method 3 etc.
  • all method should fit on a screen -- 15 to 20 lines of code max -- often methods will be 2 or 3 lines long.
  • each method should perform one small well defined action only
  • methods should be private, unless other objects need to call them.
  • create a constructor for each class, even if it is empty
  • use nouns for class names  
  • logic and ui decoupling