Slugging Through Other’s Brittle Code isn’t Fun

For the last few weeks I've been slugging through a lot of code written by guys that are a little junior, and end up making junior-level mistakes. These aren't horrible problems, but they certainly have set me back a bit as far as getting the project done. Each time I run into a style of problem, I try to point it out to the guys to say why this is a problem, and why not to write code this way in the future. I have a feeling this has mixed reception, but I'm trying to help them become better at this craft, but it's often a painful process - for them and me.

Today was some really brittle code. Make one little change to one method, and I have to change another. This is often the sign of bad interfaces. If an object is well-defined and it's methods are well thought-out, then you usually add methods to a class, or make different classes. But when it's sort-of thrown-together, you have to change the calling parameters for some methods, and pass in complete objects, to get the added behavior.

This is brittle code. It's incapable of being stretched, expanded, changed, without major changes to the surrounding code.

It's hard to work with this, and while I'll end up re-writing it all in the end, for now, I need to work with it - if I can, and get something working in the short-run. But it's all a bunch of mental notes for what to come back and clean out after the initial release is over.