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

Refactoring 101

Josh Ghent
September 06, 2018

Refactoring 101

Josh Ghent

September 06, 2018
Tweet

More Decks by Josh Ghent

Other Decks in Technology

Transcript

  1. Always code as if the person who ends up maintaining

    your code is a violent psychopath who knows where you live. - Code for the Maintainer
  2. How do we know What to refactor? Doesn't follow design

    principles Breaking constantly Long on-boarding times Broken tests Outdated Documentation Long classes Badly named routes Inefficient code Outdate dependancies
  3. What can we learn? •Avoid data types in function names

    or variables •Encapsulate logic in sensible chunks •Name functions by their use rather than their description •Follow the single responsibility principle and abstract code where possible
  4. What can we learn? •Explain the HOW and WHY in

    code comments •Good documentation encourages developers to use your library or API •Use simple english for accessibility •Use Swagger for API documentation
  5. Recap • Business advantages of refactoring - reduced cost to

    develop features, less bugs • Developer advantages - speed up development • How to identify code to refactor - code smells, outdated documentation or dependancies • Three ways to refactor code - document, test and abstract