I've been working a lot on prosper lately (this means that if you want to play around with it, get the bleeding edge on GitHub). I recently added a lazy loading feature, mostly to facilitate unit testing, and pretty soon I will be adding some unit testing. I was able to take care of some things recently that have bugged me for a while, and its because of ruthless refactoring.
Refactoring is not black magic, it just means taking some code and reworking it, rename a function here, encapsulate some functionality there, done. The sticky part is that refactoring is a compounding problem. Things that should be refactored build up on each other, so if you put off refactoring for too long you will have a real mess on your hands. Refactoring can be painful but should never be put off, you see a function named poorly but know that it is used in 20 places, get it now, don't put it off, because by the time you get around to renaming it, it will be in more places.
A good IDE will help you in your refactoring process, the one that I love is (surprise, surprise) Eclipse. Eclipse is brilliant at refactoring, probably because it keeps semantic knowledge with symbol names. Rename the function foo to bar and you don't have to worry about Eclipse destorying all those variables named foo (ps. if you have variables named foo you have refactoring to do!). Eclipse (and other IDEs) are great at all kinds of refactoring, renaming, extracting and encapsulating, pull up, push down, etc. Get to know these tools, get comfortable with using them, and refactor without fear.
Wait, change big chunks of code without fear, how!? Well you should have tests, be they unit or functional. I'm introducing unit tests into prosper, but for the time being I have a local version of todo list case study. The todo list application is pretty good because it exercises all the important bits, if I change something and everything in there keeps working, I haven't broken anything too badly.
The reason I want to introduce unit tests though is that I've introduced regressions even with the todo list humming along, some dark corner of prosper has started shooting out unicorns, but I haven't noticed, until I see some bit of code that I know can't be doing the right thing. Test coverage allows you to refactor without fear, and if you want to have a living project that people might someday use, you need to refactor without fear to keep things current.
That's it for the technical part of this blog post, I would like to announce a few things though.
- The move to GitHub has been completed and I'm starting to get into the workflow of using it now.
- The new skunkworks project is nearing a beta release, so keep an eye out.
- Development on the new project has spurred improvements in prosper, there will be a point release (0.6) soon
- There probably won't be a post tomorrow as I'm traveling with Heather, my beautiful girlfriend, up to see my family in Cleveland.
That's all for now, I will have something up Black Friday more than likely, until then, Happy Turkey Day everyone, safe travels, see you after I put another couple of pounds on.
No comments:
Post a Comment