Stack Overflow archive
2 scoreaccepted

Android coding best practices

score
2
question views
569
license
CC BY-SA 3.0
  1. In AOSP ids normally use underscores. address_id instead of addressId. I have seen attributes use camelCase in AOSP however.
  2. That is the best practice. This is from the Code Style Guidelines for Contributors for AOSP:

Follow Field Naming Conventions

Non-public, non-static field names start with m. Static field names start with s. Other fields start with a lower case letter. Public static final fields (constants) are ALL_CAPS_WITH_UNDERSCORES.

  1. Layout files/XMLs are lowercase and use underscores. Your usage is correct.
  2. Class names should follow the naming conventions outlined by Oracle.

Class names should be nouns, in mixed case with the first letter of each internal word capitalized. Try to keep your class names simple and descriptive. Use whole words-avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML).

Originally posted on Stack Overflow. Public user contributions are licensed under Creative Commons Attribution-ShareAlike.