What a Difference 8 Years Makes (In Code)

I spent some time this weekend rewriting 8 year old code. It's interesting to compare the pieces where the core logic resides.

Original:

image

New:

image

 

Now I'd like to jump ahead 8 years to see the code rewritten again (and bring it back with me).

Print | posted @ Sunday, July 04, 2010 9:12 PM

Comments on this entry:

Gravatar # re: What a Difference 8 Years Makes (In Code)
by Rob Seder at 7/4/2010 10:50 PM

Perhaps it will include declaring types again and not use "var". Presumably, the future-versions of us will see the folly of this trend and go back to being explicit, once we realize that "assumptions are the root of all software bugs"!! I'm not picking on you, I'm just saying - I don't agree with this trend... :-)
  
Gravatar # re: What a Difference 8 Years Makes (In Code)
by Chris Airey at 7/5/2010 4:07 AM

Although "var" is not the same as used in dynamic typed languages, eg. JavaScript. I think it really depends on when and where you should use it in C#.
  
Gravatar # re: What a Difference 8 Years Makes (In Code)
by Craig Andera at 7/5/2010 5:30 AM

That's easy: just write it in Clojure. :)

In short, I couldn't agree with Rob less - the code will be *less* statically typed, not more. Especially something like this...
  
Gravatar # re: What a Difference 8 Years Makes (In Code)
by tobi at 7/5/2010 10:08 AM

It seems the two pieces of code are unrelated.
  
Gravatar # re: What a Difference 8 Years Makes (In Code)
by scott at 7/5/2010 10:36 AM

@Rob - I like var, so we'll have to agree to disagree!

@tobi - Right - it's hard to make a 1:1 screen shot. The original solution used a lot more code and never really expresses the essence of the solution, if you know what I mean.
  
Gravatar # re: What a Difference 8 Years Makes (In Code)
by scott at 7/5/2010 10:40 AM

@Chris - right!

@Craig - I think this code would look pretty good in Clojure. Hmm ....
  
Gravatar # re: What a Difference 8 Years Makes (In Code)
by Tuomas Hietanen at 7/6/2010 9:51 AM

In 8 years the code will be useless: M$ have already made it for you out-of-the-box. ;)
  
Gravatar # re: What a Difference 8 Years Makes (In Code)
by beyondChairs at 7/7/2010 7:22 AM

As far as I can tell, neither of these pieces of code is complete, although the first one looks close. The only reasonable comparison is complete correct code A vs complete correct code B
  
Gravatar # re: What a Difference 8 Years Makes (In Code)
by scott at 7/7/2010 9:04 AM

@beyondChairs - That is intentional. If you are looking closely at the code then you are missing the point ... :)
  
Gravatar # re: What a Difference 8 Years Makes (In Code)
by James Curran at 7/8/2010 11:17 AM

@scott - I think you're missing the (your) point. To say "I used to do this; now I do this" isn't really meaningful unless the two examples do the same thing.
  
Gravatar # re: What a Difference 8 Years Makes (In Code)
by Scott Allen at 7/8/2010 12:03 PM

@James, @beyond - ok, point taken.
  
Gravatar # re: What a Difference 8 Years Makes (In Code)
by HMC at 7/28/2010 7:35 AM

This is the emperors new clothes and utterly pointless, but hey, who am I to upset your ego ?
  
Gravatar # re: What a Difference 8 Years Makes (In Code)
by scott at 7/28/2010 10:59 AM

Not possible, HMC ;)
  
Comments have been closed on this topic.