Skip to content

Refactoring For Mortals

coloradokim edited this page Apr 18, 2018 · 1 revision

Refactoring for Mortals

Dan Levy Denver React Meetup, April 17, 2018

Overture

  1. Tiny Functions
  • Decouple and Extract Logic
  • Aim for 1-2 lines
  1. DRY is Overrated
  • Make your code readable by other humans

Keys to Refactoring

  • Pure Functions
  • Avoid this
  • Use descriptive names
  • One or two words
    • Return early, not often
  • Use destructuring!
  • Spread for for 2x the win

Tips for Code Reviews

  1. Big Function?
    • Identify steps (validation, shaping)
    • Ask if small functions are right for you
    • Suggest pure functions
    • Count pathways to prove complexity
  2. Three-word Variables?
    • As if they are in the right place
    • Could the context be more clear?
Clone this wiki locally