Code Refactoring

or 

"Why I swear so much"

@BeardedBasco

What is "refactoring"?


What it's not


"We're gonna need a whole bunch of refactoring to make this code right..."
WRONG!

Refactoring is not optimization or re-writing

Why Bother?


“ANY FOOL CAN WRITE CODE THAT A COMPUTER CAN UNDERSTAND. GOOD PROGRAMMERS WRITE CODE THAT HUMANS CAN UNDERSTAND.” 

Martin Fowler

When?

Refactoring can and should be folded in to how you write and maintain code – a part of the everyday discipline of development, like writing tests and reviewing code. It should be done quietly, continuously and implicitly. It becomes part of the cost of doing work, folded in to estimates and risk assessments. Done properly, it doesn’t need to be explained or justified.

Jim Bird

Code smell


Blob Code*


Duplicate code


COMBINITORIAL Explosion


over / under expansion*


Long method


uncommunicative names

 


“Good code is its own best documentation. As you’re about to add a comment, ask yourself, ‘How can I improve the code so that this comment isn’t needed?’”

Steve McConnell


“Self documenting code is a myth perpetuated by people who hate to write documentation”

Nicholas Zakas

comments


Dead Code


speculative code


Graffiti code*


crossing streams*


other types



  • Inconsistent naming
  • Long parameter list
  • Conditional complexity
  • Data clumps
  • Feature envy

sources


In closing...

“You are not revolutionizing your app; rather you are evolutionizing your app... and evolution is an incremental, slow-paced intelligently-designed process (pun intended).”

Volkan Özçelik


“I’m not a great programmer; I’m just a good programmer with great habits.”

Kent Bock




thanks!

Code Refactoring

By jamesbasco

Code Refactoring

They say "Cleanliness is next to Godliness". So why do we write such messy code?

  • 328