~One Paragraph Blog: How scary is the rewrite?

Posted on February 18th, 2008 by Chris.
Categories: Chris, Programming.

Do you work in software engineering? Have you ever heard a coworker say, “I’d do X, but then I’d have to rewrite everything?” Truth is, it’s easier to rewrite everything than make small changes sometimes.

How could I justify something so outlandish? Simple. The difficulty of a change (how many hiccups, how many bugs) depends not so much on its scope as it does on how well planned it is. Inevitably, we underestimate how much planning small changes take, and overestimate when we see big, scary changes. Does this mean rewrite is easy? Of course not. But it’s not impossible, or as costly as we think, and just the opposite is true for minor changes.

*The usual caveats: If you have a problem that can be solved with a small change, I recommend sticking to that before resorting to bigger changes. But once you start seeing so-called small changes multiply, you may have hit the stall point.

1 comment.

And you thought Terms of Service were bad…

Posted on February 10th, 2008 by Chris.
Categories: Chris, Politics, TOS Collection.

I could use a good translation for this.

0 comments.

I <3 LINQ

Posted on February 5th, 2008 by Tim.
Categories: General/Misc..

I just started a little pet project, and figured this would be a good time to start training myself to think in terms of LINQ. I started out writing a function that looked sort of like this:

public double Length
{
  get
  {
    double max = 0;
    foreach (FunctionClip clip in _clips)
    {
      max = Math.Max(max, clip.End);
    }
    return max;
  }
}

Then I noticed that there was an extension method called Max on arrays. As a result, the above function simplifies to:

public double Length
{
  get
  {
    return _clips.Max(f => f.End);
  }
}

Six lines of code suddenly turned into one! At this point, the gears were turning in my head. Suddenly, the foreach construct seemed less elegant:

foreach (FunctionClip clip in _clips)
{
  clip.RenderTo(data, freq);
}

Could this be made simpler? Sure, check it out:

_clips.ForEach(c => c.RenderTo(data, freq));

Not quite as dramatic as before, but in raw number of lines we’ve still reduced by a factor of four. Making code more compact increases readability, which in turn leads to less bugs. LINQ FTW!

6 comments.