I am looking for a thorough Android naming convention suggestion. I found a little bit here:
http://source.android.com/source/code-style.html#follow-field-naming-co
Every body uses his own, The main goal is to avoid mistakes and misinterpretation, specially when others read your code. Though syntax highlighting, and auto code inspection in modern IDE's makes it pretty point less.
But these naming conventions also make it very convenient when code completion is turned on. For example just type m
and auto complete will show you a list of class fields.
But many times you have to work with other's code, which doesn't use such convention. such protected variables and overridden method parameters just add to the confusion.
Few examples:
Prefix class variables with m , and make static finals variables all caps, with _
separating words. Don't prefix any thing to lower scope variables.
Name layout after the UI parent, for example act_main.xml
, frg_detail.xml
, itm__act_main__list1.xml
; for an activity MainActivity
, a fragment DetailFragment
, item layout for a ListView
in MainActivity
with id list1
, respectively.
Name element Id's in xml layouts like: lsv__act_main__list1
for a ListView and btn__act_main__submit
for a `Button element. This makes them much easier to find with auto complete.