Difference between revisions of "Naming convention"

From DarkWiki
Jump to: navigation, search
(Factories)
(Factories)
Line 24: Line 24:
  
 
===Factories===
 
===Factories===
 +
 +
* Factories
 +
** Responsible for creating objects - not persisting them!
  
 
* Factory classes
 
* Factory classes
Line 30: Line 33:
 
* Factory methods
 
* Factory methods
 
** Conform to create[ObjectType] naming convention
 
** Conform to create[ObjectType] naming convention
 +
 +
===Persistance===
 +
 +
* Repositories
 +
** Conform to [ObjectType]Repository naming convention
 +
** Methods such as 'save*', 'load*', 'find*', 'read*', 'write*', 'delete*'

Revision as of 09:01, 29 March 2019

Java naming convention

Getters and setters

  • Getters (get, is)
    • Takes no parameters
    • Does not alter the object in any way; it is constant
    • Can be called multiple times, and in any order
    • Returns a consistent single result
  • Setters (set)
    • Takes one parameter
    • May or may not alter the object
    • Only affects the object that has the setter; it does not persist anywhere else
    • Can be called multiple times, and in any order

Finders & filters

  • Finders (find)
    • Takes zero or more arguments (which act as filter or sorting controls)
    • Does not alter the object in any way; it is constant
    • Can be called multiple times, and in any order
    • Returns a consistent single, non-null collection result

Factories

  • Factories
    • Responsible for creating objects - not persisting them!
  • Factory classes
    • Conform to [ObjectType]Factory naming convention
  • Factory methods
    • Conform to create[ObjectType] naming convention

Persistance

  • Repositories
    • Conform to [ObjectType]Repository naming convention
    • Methods such as 'save*', 'load*', 'find*', 'read*', 'write*', 'delete*'