Refactoring Code Smells

Our senses allow us to perceive the world. Some smells are good, others less pleasant, but all of them give us more information.

If you have enough time I highly suggest watching this talk, Get a Whiff of This by Sandi Metz. If you are pressed for time jump forward to 11:35.

Martin Fowler, and Kent Beck have given us a name for code smells. Having a name for something wins. It lets us identify it, talk about it, and identify a next step. In Refactoring, they created recipes, a step by step approach to make code better. Sandi explains each code smell maps to a specific recipe for refactoring.

In practice, all you need to do is know how to identify code smells, and what they are. If you can name them then you can look up the mapped recipe and improve your code.

In the future, with enough practice you may even be able to get intuit the smell before it is introduced.

We stand on the shoulders of giants. They have provided us with recipes for success. It is our responsibility to learn the recipes from our fore-coders so that we may build more maintainable code, one commit at a time.


Takeaway

Code Smell Refactoring Checklist
Write code
Identify smell(s)
Look up recipe for one code smell
Refactor
It is best to have tests in place whenever refactoring.

Sandi is an incredible teacher of software, softskills, and how to give an outstanding presentation. Check out her talks