to write self documen?ng code • Do not use magic numbers. CREATE CONSTANTS • Do not use uncommon abbrevia?ons (Btn, Lbl, Tv) • Include units in a name (distanceInMeters) • Most meanings have mul?ple words. PICK ONE • Try to avoid comments by crea?ng meaningful names for methods
name of the func?onality and then the type (reason: alphabe?cal sor?ng). • TextView showOfferTextView; • Strings: same patern but separa?ng them with _. Reason: is used throughout the Android plaZorm • show_offer_text_view
• public class Foo • Constant in uppercase le]er, descrip?ve name • private sta?c final int THIS_IS_A_CONSTANT = 1; • Everything else with lowercase le]er • private int fooFunc?on() {..}; • private boolean hasBeenFound;
official limit. As small as possible • If you have the same code twice -‐> refactor. No excep?on. • Short methods avoid wri?ng large docs • Keep lines short • Google recommends lines of max 100 characters. Not sure why this is a magic number, but is anyway a good prac?ce to keep lines short. • If you strictly need to keep them large (i.e., mul?ple if else condi?ons) then switch to a new line
as you do it. Not when you are finished. • Don’t document constructor, ge]er, se]er • If a method is complex enough, say what it does! • Useful annota?ons • @Deprecated • @author • @see • @param • @return • @Override