Explaining the Joy of Refactoring (to the non-developer)

I thought of the above sketch when I recently was explaining why refactoring can be joyous for a developer.

A common workflow pattern is to make something work, however you can. Once you have it working, you clean up your code (refactor), such that the external behavior/functionality is unchanged, but the internal code design and organization is refined and improved. (This should be done in small doses; I would not recommend building an entire application and then trying to clean up its codebase.)

You start with a dilapidated mess (a shack), held together with duct tape, paper clips and whatever you can find. And through disciplined refactoring, you have an elegant, organized and manageable codebase. The transformation is very rewarding and can make a developer happy and proud of their work.

And as noted in the sketch, you should refactor with an automated test suite, so you can verify everything still works. Otherwise a light switch in one room might control the lights (or worse) in another room.

justideas.io

justideas.io

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store