Method Naming Conventions: Verbs and Clarity
What you'll learn: How to name methods in Java following professional conventions that make your code instantly understandable.
The Power of a Good Name
Method names in Java should clearly communicate what action the method performs. Unlike variables (which are typically nouns describing things), method names should start with verbs because methods do something. Think of methods as commands you're giving to your program: "calculate this," "print that," "find something."
The Verb-First Rule
Start your method names with action words:
calculateTotal()— immediately clear it performs a calculationprintReport()— obviously outputs a reportfindMaxValue()— searches for the maximumisValidInput()— checks validity (returns boolean)getUserName()— retrieves user information
Bad examples that violate this convention:
total()— what about the total? Calculate it? Return it?report()— is this a noun or verb? Confusing!valid()— checking or making something valid?
Clarity Over Brevity
Your method name should be self-documenting. Someone reading calculateMonthlyInterestRate() knows exactly what happens without reading the code inside. While calcInt() is shorter, it's cryptic and unprofessional.
Use camelCase: first word lowercase, subsequent words capitalized (getUserInput, not getuserinput or get_user_input).
Common Verb Patterns
- get/set: retrieve or modify values
- is/has: boolean checks (
isComplete(),hasPermission()) - calculate/compute: perform calculations
- find/search: locate data
- validate/check: verify conditions
- print/display: output information
Key Takeaway: Name methods with verb phrases that clearly describe their action, making your code readable as plain English without requiring comments.