How do you know when to “cut and run?”

Should it be saved?

I recently got an object lesson (pun intended) in when to start over on something. When a deadline rears its ugly head, that’s usually the best time in the project to “slow down to hurry up.” The more pressured and frazzled you get, the more mistakes you make. The more you keep thinking “just this one last fix (and this slightly wonky design will work).” Easier said than done.

The past two weeks of my work life have been invested in debugging something that was “99% done” pretty much the whole time. But after this huge waste of time, this area of the product was ultimately redesigned and rewritten in two days and now has no significant bugs. This kind of “we’re almost there” failure mode reminds me of mistakes people make in the stock market trying to “wait out” bad investments. Just because the stock you bought is going down, doesn’t mean you shouldn’t sell it.

In this particular “bad investment,” the trouble was that the underlying model was wrong. And the reason it was wrong was because our original conception of the problem was wrong. And the reason that was wrong was that we rushed at the start of the project to start coding when we didn’t really have the requirements down as fully as we thought we did. Under deadline pressure, who wants to go back and re-examine the foundations of your model when it’s almost working? Sound familiar?

Our particular issue stemmed from thinking that certain concepts were related when they weren’t related enough. This can be a really tricky thing in OO programming because it can initially look like like B extends A and C extends A is a good model, simply because B and C have some things in common. But in some cases this can be a trap where you slowly discover that they aren’t really the same concept. And unfortunately, in the meantime, you’ve wrecked a good chunk of your codebase (well, at least polluted it with a lot of unnecessary code).

I’m curious if any readers out there have ideas about how to identify when code should be saved and “remodeled” and when it should be leveled and rebuilt from the ground up. How do you know when to “cut and run?”

I’m also curious if people have interesting ideas about how to identify inheritance schemes that have run amok. Do you also find that too much adherence to DRY sometimes leads to unnecessary or unwise inheritance?

This entry was posted in Uncategorized. Bookmark the permalink.

One Response to How do you know when to “cut and run?”

  1. Ian Marshall says:

    I can only contribute the following factors (which are probably obvious to most people) in making the decision whether to amend or construct again from scratch:

    · (Forecasting from the current trend). Is the code getting more and more complicated?
    · (Forecasting). What is the forecast stream of future modifications? How well will the existing design cope with likely future changes?
    · (The organisation’s current effort trade-off policy of long-term v. short-term). How much time is available in the short term to allow an investment of a re-design?
    · What are the risks of re-design (if any)?

    I trust that others have more comprehensive lists.

    Sometimes. I have found myself a couple of times repeating my code, but I had make a definite decision to do this rather than inherit. Why did I decide to do this? It was probably nothing more than a gut feel in those particular cases to override what I knew to be good usual practice. (It is likely that the classes involved were too separate to use a common chunk of code.)

    For me, this is in the same vein as the rôles of advisors and deciders: advisors advise, and deciders decide. Normally, a decider does well by following the specialist advice, but sometimes the decider exercises the right to differ.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s