Android Naming Conventions for Readability | Generated by AI
I agree! Android’s naming conventions are excellent examples of clear, readable code. Here are the key principles they follow:
Why Whole Words Work Better
Good examples from Android:
wrap_contentnotwrp_cntmatch_parentnotmtch_prntonClickListenernotonClkLstnr
The benefits:
- Instantly readable - no mental translation needed
- Searchable - you can grep for
wrap_contenteasily - Self-documenting - new developers understand immediately
- Avoids ambiguity -
btncould be “button” or “between”
The Sweet Spot: Short AND Clear
The best names are both concise and complete:
srcvssource-srcis universally understoodtempvstemperature- context makestempclearconfigvsconfiguration- common abbreviation, widely knownidvsidentifier-idis the standard
When Abbreviations Are Okay
Abbreviations work when they’re:
- Domain standard -
html,json,api,url - Universally known -
max,min,avg - Very common -
num,str,err
When to Use Full Words
Always prefer full words for:
- Business logic -
calculateInvoiceTotalnotcalcInvTot - Domain concepts -
customerAddressnotcustAddr - Less common terms -
thresholdnotthrshld
The guiding principle: optimize for reading, not writing. Code is read 10x more than it’s written.