Meaningful Namesvariable, function or class names shouldanswer all the big questions: why it exists? what it does? how it is used? 9
Meaningful NamesIf a name requires a comment, then thename does not reveal its intentavoid disinformation dont use type information in names (example: personList) Spelling similar concepts similarly is information. Using inconsistent spellings is disinformation. 10
Good and Bad Comments•Public API Comments •Redundant Comments•Legal Comments •Noise Comments•Explanation of Intent •Position Markers•Warning for •Closing Brace Comments Consequences •Commented-Out Code•real TODO Comments •Obsolete Comments •Nonpublic JavaDocs 12
Comments„Purpose of a comment is to explain codethat does not explain itself.“Comments do not make up for bad codeDon‘t use a comment when you can use afunction or a variableComments can contains lies 13
Error HandlingWrite code that is clean and rebustSee error handling as a separate concernUse exceptions rather than return codesUse unchecked exceptions 21
Error HandlingDon‘t return NULL throwing an exception or a special case object like „Collections.emptyList()“Don‘t pass NULL InvalidArgumentExceptions or assert better: forbid passing NULL by default 22
SourcesBook „Clean Code“ by Robert C. Martin ISBN: 0132350882Images http://www.failblog.org http://www.flickr.com/photos/hugovk/199425487/ http://www.flickr.com/photos/jackpot321/1809424991/ http://www.osnews.com/story/19266/WTFs_m 27
A particular slide catching your eye?
Clipping is a handy way to collect important slides you want to go back to later.