Skip to content

Latest commit

 

History

History
35 lines (28 loc) · 1.87 KB

index.md

File metadata and controls

35 lines (28 loc) · 1.87 KB

Clean Code: Introduction

We’ve all been impeded by bad code, so why do we write it?

  • Deadlines
  • Want to move on to another project
  • Endless backlogs

Cost of owning a mess

  • Being slowed down by someone elses code
  • A single change breaks 2 or 3 other parts of the code
  • Modifications require ‘understanding’ in order to add them
  • Productivity drops toward zero -> more staff is added to increase productivity -> new staff doesn’t understand the system design and their help thwarts efforts compounding the mess.

Redesign fallacy

  1. Management finally agrees to a redesign a tiger team is selected
  2. They race to complete the new system while other teams maintain the old system
  3. They have to create all the functionality of the old system plus keep up with new changes
  4. By the time it’s done the current team doesn’t want the new system cause it’s such a mess.

Why does good code turn into bad code?

We complain about managers and requirements but it’s us. It’s our responsibility to push back and tell managers it’s going to take more time to write our code.

What is clean code?

  • Elegant and efficient (it’s easy to write more bad code when the code is already bad because it looks like nobody cared in the first place)
  • Does one thing well, is focused, single purpose
  • Readable, literate, expressive, unsurprising, minimal
  • Is easier for others to enhance
  • Testable
  • No duplication

Miscellaneous

  • Most of the time when we're 'writing' code we're actually reading it. Our ratio of reading to writing code is 10:1. Therefore making it easier to read makes it easier to write.
  • We can’t just write clean code, we have to keep it clean. Boy Scout Rule – leave the code cleaner than when you found it. Cleanup doesn’t have to be something big, improve a variable name or break up a function.

Next: Meaningful Names