Refactoring with a twist
Reverse Refactoring
Having been asked to facilitate a kata at work, I was wracking my brains thinking of something different to do. Everyone has been through the Roman Numeral kata many a time. I wanted something more unique, memorable and above all fun…
Then I thought back to SoCraTes Uk, where I went to a ‘refuctoring’ session, where the aim is to bastardise your code as much as possible. Sounds easy huh.. well, it was lots of fun, letting loose, doing everything in the worst way possible.. But actually personally I found it quite hard. It went against everything I believed in. Regardless I felt it was a good session to run at work, but being polite, I rebranded the title of the kata as ‘Reverse Refactoring’.
As this was an educational session, I wanted it to have a point….and actually I think there is a point. The points were
- Don’t over engineer your code.
- Sometimes you can refactor too far
- Code gets more complex over time
- It’s easy to write unmaintainable code
All so easily done especially when stakeholders think they might want this or that at a future date.
Instruction was given: #### “Take the classic ‘Hello World’ and make it as bad as you can.”
After a few nervous laughs, people got into the spirit when they realised I was serious. The results were brilliant. We had comments, logic in catch and finally blocks, letter factories, SpeachManagers, LanguageUtilities, reading letters from files, reflection… One pair ended up writing and releasing one maven library, to which another part of their ‘Hello World’ project depended on…. Smiles all round. Mission accomplished!