Refactoring For Mortals - kimschles/schlesinger-knowledge GitHub Wiki
Refactoring for Mortals
Dan Levy Denver React Meetup, April 17, 2018
Overture
- Tiny Functions
- Decouple and Extract Logic
- Aim for 1-2 lines
- 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
- Big Function?
- Identify steps (validation, shaping)
- Ask if small functions are right for you
- Suggest pure functions
- Count pathways to prove complexity
- Three-word Variables?
- As if they are in the right place
- Could the context be more clear?