Clean Code: A Handbook of Agile Software Craftsmanship (a)

Wrote by Robert C. Martin

(1) Can you Spot the Differences?


(2) A tale of two apps below

  • One enormous class. => 1300 lines
  • 26 data members
  • 40 public methods named “setFlagsForLaterProcessing”
  • Long functions
  • Badly named variables
  • Tens of classes
  • Several packages
  • “Board”, “Game”, “Strategy” classes
  • Small functions
  • Comprehensive unit tests

(3) The User can’t tell


(4) Clean code == happy coding jobs

  • ”If by life you were deceived, Don’t be dismal, don’t be wild!”
  • If horrible code sucks the life out of you, what would you do?
  • image

(5) Remember it!


(6) Two reasons for you


(7) Foreword


(8) There will be code

“Nonsense! We will never be rid of code, because code represents the details of the requirements.”

(9) Bad code

  • Kent Beck’s book Implementation Patterns. He says, “…this book is based on a rather fragile premise: that good code matters….”
  • image
  • 1.“It was the bad code that brought the company down.”
  • 2.“Of course you have been impeded by bad code. So then—why did you write it?”
  • 3.“LeBlanc’s law: Later equals never.”

(10) The total cost of owning a mess

  • No change is trivial
  • The productivity of the team continues to decrease
  • Add more new staff to the project in hopes of increasing productivity
  • There is no way at all in the end
  • image