I refactor ruthlessly. I refactor just to see what it’d look like – then throw it away. I change a name 5 times in a row just to see how it looks in context.
In attempting TDD one really big way to screw up is to gloss over the refactor step. Maybe part of that is pressure to move on to the next task, but some for some people it seems to take effort.
Now I usually write C# in Visual Studio and ReSharper. This means I can do things like:
- Rename a variable/method/class/interface
- Extract a variable/method/class/interface
- Navigate easily between related code elements
Not only can I do them, but the work to do them is approximately equal to thinking them. This is because the IDE understands the structure of code, including scoping and naming rules.
Hooray, life is good.
But sometimes I end up writing with other people in their language/editor of choice, and I just think “where are your tools?”.
Today I did a code kata with someone in php using a mixture of gedit and vim. It was nightmarishly tedious to refactor anything. Renaming a variable needed a regular expression. What if a method had a similar name? There are a load of compile errors to fix.
This isn’t the first time I’ve run into this issue – on multiple occasions when I’ve used a different language (PHP, C++, F#) I’ve found the same thing (Java in Eclipse being the exception). Have I just been unlucky, or are lots of people genuinely working without these tools?
Most people who write software are surely bought into the premise that good software can make a job easier and more efficient?
Apply it you your own job, tool up!
Disclaimer: The company I work for does sell tools to help developers – that’s not why I’m writing this.