This post originated from an RSS feed registered with Java Buzz
by Vinny Carpenter.
Original Post: Refactoring Tools & Testing
Feed Title: Vinny Carpenter's Blog
Feed URL: http://www.j2eegeek.com/error.html
Feed Description: Welcome to my blog. I am a total Java geek that lives in Milwaukee, making my living as an architect/developer, spending all my time with Java, J2EE, OO, Linux, and open source. In my spare time, when I am not in front of my computers, I spend every other minute with my other loves: My wife, books, music, guitars, Formula-1 racing and StarGate. Check out my blog @ http://www.j2eegeek.com/blog
I've noticed a subtle change in my development process over the years and I finally connected the dots a few months ago.
I've always been a big fan of unit testing and writing or using developer-testing tools. I love the idea of writing tests to validate my code and I take pride in writing enough tests to validate my system in terms of unit as well as regression testing to test the system from front to back. I never bought into the whole 'write-tests-first' idea. I am not knocking it and if it works for you, more power to you but I just could not wrap my puny little mind around that idea. I like the cause and effect approach in reverse where I write my code to do something and I then I want to test it to make sure it does what it is supposed to do. What!! Is that reverse? Now I'm confused. I hope you know what I mean.
I love the idea of Test-Driven Development where you write tests to validate your code. The promise of unit testing and software testing in general is to allow you to write robust code that's being validated every time you run your tests. Another major benefit that's always mentioned in context of unit tests is the idea of refactoring. Martin Fowler defines refactoring as a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior. Refactoring is a very important and powerful technique and most developers will spend a significant amount of their time refactoring existing projects and products as part of bug fixes, feature additions and enhancements.
The ability to 'refactor at will' is one of the major promises of unit testing and a benefit held up pretty significantly. But I have found that using IDEA over the last 3 years has changed the way I write code. With the refactoring capabilities built inside IDEA, I find that I am able to very quickly refactor and change significant amounts of code with ease. I am finding that I am now writing significantly less amount of unit-tests. I don't mean to suggest that it is a good thing, but it's just what is really happening. IDEA's refactoring support is just so awesome and things like 'programming by intention' have made me dumber over time. I think I have gotten stupider for using IDEA and I think that's the mark of a great tool. I still write unit-tests but I find that I am not as thorough as I used to be.
One of the things I noticed in the past was that I would refactor my code a lot to allow it to be tested, which led to much cleaner and loosely coupled code. Now that I am writing fewer unit tests, I'm guessing my code cohesion and coupling has gone up. I guess I am going to have clean up my act and revert back to my old ways and write more unit tests and not rely on IDEA for intelligence. Given the meteoritic rise of Eclipse, I may soon work on a project that requires or mandates the use of Eclipse and all my cool IDEAism's will no longer be there to rescue me, from myself.