next up previous
Next: White Space Usage Up: Naming Convention Previous: Field Naming

Method naming

Method name should use the infixCaps style. Start with a lower-case letter, and capitalize the first letter of any subsequent word in the name, as well as any letters that are part of an acronym. All other characters in the name are lower-case. Do not use underscores to separate words. Note that this is identical to the naming convention for non-constant fields; however, it should always be easy to distinguish the two from context. Method names should be verbs or verb phrases. Examples:

    // GOOD method names:
    showStatus(),
    drawCircle(),
    addLayoutComponent()

    // BAD method names:
    mouseButton()          // noun phrase; doesn't describe function
    DrawCircle()           // starts with upper-case letter
    add_layout_component() //underscores

A method to get or set some property of the class should be called getProperty() or setProperty() respectively, where Property is the name of the property. Examples:

    getHeight()
    setHeight()

A method to test some boolean property of the class should be called isProperty(), where Property is the name of the property. Examples:

    isResizable()
    isVisible()



Dennis Seah Mon Jul 17 11:43:42 2006