Friday, December 5, 2008

Lots of Little Things

When you've been working for a while, you build up quite a crop of tools, utilities, scripts, etc. These are the little helpers that make things easier. Maybe one grabs all the logs from all the machines you were using and puts them in a central location. Maybe another creates a ticket from an automated test. A third might give you a list of all failures in last night's test run. A fourth might move a machine into the "I'm broken please fix me" queue so no other tests can grab it and fail.

All the little scripts are great, but it gets really easy to make a mess with them. Let's say I have a scenario:
I want to take all failures from last night's run, grab their logs, create tickets, and move the machines they were using into the "I'm broken" queue.

That's just a compendium of my little tools - awesome! Should be easy to write a script that ties each of these together...

And wind up with a mess.



All those utilities and scripts can be combined, sure, but unless you're really careful how you do it, you're going to wind up with layers of flakey, kinda crufty scripts that barely hang together.

Think of it like painting a room. You can paint one wall (call it your "accent wall" - and for the record this is one of those things I find kind of odd, but it's an analogy so we'll go with it). Then you can paint the rest of the walls a different color. Then you paint the trim. And then, well, maybe the accent wall would look better the same color as the other walls, so you paint it. And before you know it you've got a lot of thick, cracking, probably peeling paint. Not good.

The proper way to paint a room includes stripping the old stuff before you write the new stuff. And the proper way to write code includes refactoring to accommodate new needs rather than just adding more. This applies to your quick little tools, as well.

No matter how small your script is, if you're modifying it, consider refactoring it. It'll keep your tools useful for a lot longer.

No comments:

Post a Comment