Refactoring is the hardest skill to master
I see a lot of discussions around how to spot a great software developer from an average one. Mind that I did not say rookie vs. experienced. I hear many criteria. Years of experience should not be one of the criteria for many reasons. Based on many recent job postings by many hot startups, it seems someone who can whip up solutions to complicated algorithmic problems (a specialist skill), does test-driven development (might show discipline), creates/contributes to open source projects on Github (shows initiatives), active on Stackoverflow (shows initiative and willingness to help besides experience with similar issues), and has a blog (shows initiative and willingness to share) is seen as a great programmer. While I understand the thinking behind them, but I recently realized that a great programmer is someone who is proficient at refactoring.
It is relatively easy to write something from scratch. But it is really hard to incrementally make an existing codebase better while adding new functionality or modifying existing ones. Everyone wants to write new codes for exactly this reason. Let’s face it, we developers never like working on even our own codes written a while back, let alone someone else’s codes. Not only we have to overcome this huge mental block of working with existing codes, but also muster up the courage to deal with the unknowns that come with such efforts- breaking something else, uncovering unpleasant traps, reverse engineering business logic, or writing missing test codes etc. Refactoring requires great design skill, aptitude for quick learning, forensic-style debugging, and discipline as well as patience and grace.
If you are looking to hire a programmer, why not just ask the potential hire to refactor an existing code that he/she is going to work on anyways, if hired. And observe not only what he does, but also how he does it, and ask why he did the way he did.