Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Readable Code

Readable Code

The positive impact authoring readable code can have on your career can be huge. There are some simple techniques you can use to create more readable code that can improve your efficiency and make it easier for your code to be supported across teams. Clean Code is popular and Readable Code takes a look at these concepts in a different light and gives you actionable items to improve your code today. Learn how to make Readable Code by using some of the techniques such as separation of concerns, above the fold, the LIFT principles, commenting, encapsulation, and many more! Is your code readable?


John Papa

August 09, 2014



  2. READABLE  CODE   @john_papa   HOW  FAST  CAN  YOU  READ

  3. READABLE  CODE   @john_papa   “     How  can

     you  enhance  code  if  you  can’t  read  it?   ”    
  4. READABLE  CODE   @john_papa  

  5. READABLE  CODE   @john_papa   “     It’s  harder

     to  read  code  than  to  write  it.   ”     -­‐  Joel  Spolsky   But  Why?
  6. READABLE  CODE   @john_papa   “     It’s  not

     about  clever,  craHy,  arIul,  preJy  code.     It’s  about  fast  and  effecLve  communicaLon  and   code  quality.   ”     What’s  it  all  About?
  7. READABLE  CODE   @john_papa   Who  Cares  for  the  Developer

     Behind  You? “     ”     Caring  about  your  craH  is  a  good  thing.  Caring  about   the  what  happens  aHer  you  deploy  your  code  is   beauLful.  
  8. READABLE  CODE   @john_papa   What’s  Your  MoKvaKon? Time  

    ProducLvity   Cost  of  a  Complete  Mess  
  9. READABLE  CODE   @john_papa   “     ”  

  10. READABLE  CODE   @john_papa   “     Deploy  faster,

     spend  less,  re-­‐use  more,     and  maintain  high  quality.     ”    
  11. READABLE  CODE   @john_papa   Who  is  Code  Intended  For?

    Programs  must  be  wriJen  for  people  to  read,  and   only  incidentally  for  machines  to  execute.   -­‐  Abelson  &  Sussman,  Structure  and  Interpreta9on  of  Computer  Programs   “     ”    
  12. READABLE  CODE   @john_papa   Meaningful  Names  Are  Crucial  to

     Read  Speed
  13. READABLE  CODE   @john_papa   Crystal  Clear  Names  Promote  Readability

  14. READABLE  CODE   @john_papa   DescripKve  Names

  15. READABLE  CODE   @john_papa   Can’t  Decipher  within  the  5

     Second  Rule
  16. READABLE  CODE   @john_papa   IntenKons  are  Clear

  17. READABLE  CODE   @john_papa   “     Most  important

     code  is  instantly  visible   ”     Above  the  Fold
  18. READABLE  CODE   @john_papa  

  19. READABLE  CODE   @john_papa   Simple  and  Clear

  20. READABLE  CODE   @john_papa  

  21. READABLE  CODE   @john_papa   “     Less  than

     20  lines  of  code   ”     Small  FuncKons  Are  Readable

        What  will  you  find  when  you  search  for  your  code?   ”    
  23. READABLE  CODE   @john_papa   Clarity,  Inconsistent  Naming  and  Spelling

  24. READABLE  CODE   @john_papa   Consistent  Naming  and  Spelling  MaSer

  25. READABLE  CODE   @john_papa   Pick  One  ConvenKon

  26. READABLE  CODE   @john_papa   “     People  who

     maintain  code  lack  the  author’s  context   ”     CONTEXT  ===  CLARITY  
  27. READABLE  CODE   @john_papa   Does  Your  Code  Provide  Context?

  28. READABLE  CODE   @john_papa   Explain  Yourself  in  Code,  Not

  29. READABLE  CODE   @john_papa   Self  Describing  Code

  30. READABLE  CODE   @john_papa   Replace  Comments  and  Magic  Strings

  31. READABLE  CODE   @john_papa   Use  DescripKve  FuncKons  and  Constants

  32. READABLE  CODE   @john_papa   Comments  are  noise  when  …

    Outdated  and  incorrect   Shoulda  coulda  used  a  variable  or  funcLon   Redundant  
  33. READABLE  CODE   @john_papa   Comments  are  awesome  when  …

    Warnings  of  Consequences   API  DocumentaLon   TODO’s  
  34. READABLE  CODE   @john_papa   How  Readable  Is  My  Code?

    LocaLng  our  code  is  easy   IdenLfy  code  at  a  glance   Flat  structure  as  long  as  we  can   Try  to  stay  DRY   L   I   F   T  
  35. READABLE  CODE   @john_papa   “     Clean  code

     is  the  secret  to     your  applicaLon’s  long  and  healthy  life   ”    
  36. READABLE  CODE   @john_papa   Nothing  Starts  Readable “  

      Write  dirty  code,  then  clean  it   ”    
  37. READABLE  CODE   @john_papa   Opinionated  AngularJS  Style  Guide hJp://jpapa.me/ngstyles