Try to come up with meaningful method names that succinctly describe the purpose of the method, making your code self-documenting and reducing the need for additional comments.
Compose method names using mixed case letters, beginning with a lower case letter and starting each subsequent word with an upper case letter.
Begin method names with a strong action verb (for
example, deposit
). If the
verb is not descriptive enough by itself, include a noun (for example, addInterest
). Add adjectives if
necessary to clarify the noun (for example, convertEuroToDollars
).
Use the prefixes get
and set
for getter
and setter
methods. Getter methods merely return the value of a instance variable;
setter methods change the value of a instance variable. For example,
use the method names getBalance
and setBalance
to access
or change the instance variable balance
.
If the method returns a boolean value, use is
or has
as the prefix for the method
name. For example, use isOverdrawn
or hasCreditLeft
for
methods that return true or false values.
moveAccount()