Scott Hanselman

The "I'll have Larges Fries and a Diet Coke" Style of Programming

June 18, '04 Comments [13] Posted in ASP.NET | Web Services
Sponsored By

I was at a local fast food joint today and a fairly large individual in front of me order a Double Cheeseburger, Large Fries, and a Diet Coke.  The irony was as big as his backside.

An hour later at work a fellow identified an opportunity to reuse some code (Diet Coke = Good) but in the interest of schedule, ease of deployment, the differenting contexts the original code was used in, changes to the installer, etc. etc., the quickest way to use the code was by copying and pasting (Large Fries = Bad) from one subsystem to the other.

Ordinarily this would have killed me a little inside, but...sigh...at least it was a Diet Coke.

Was I wrong?

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb
Saturday, 19 June 2004 00:01:15 UTC
Drinking Diet Coke has nothing to do with 'diet'. It's all about the caffeine.
Saturday, 19 June 2004 00:20:09 UTC
Touché! As a diabetic, I DO drink only Diet Rite or Caffeine Free Diet Coke. ;)
Scott Hanselman
Saturday, 19 June 2004 05:11:48 UTC
If you are really referring to the code, then I have to suggest that purity will often give way to practicality.

If you were REALLY referring to the Diet Coke, then I have to say I know folks who only drink Diet b/c they think it tastes better than the original.

Saturday, 19 June 2004 05:43:55 UTC
I drink Diet Coke because I prefer the tast. Chris, have we met?
Saturday, 19 June 2004 06:35:30 UTC
Same here. I drink Diet Coke mainly because I don't really like the sweet stickyness of regular soda. So, I'm the one who also goes for the Big Mac, Fries, Apple Pie and Diet Coke.
Saturday, 19 June 2004 07:59:23 UTC
I have to vote for the taste, too. It's what I learned to caffeinate on.
Saturday, 19 June 2004 18:33:21 UTC
Sigh...apparently the analogy didn't work. -1 for my failed Programming metaphors. :)
Scott Hanselman
Sunday, 20 June 2004 06:14:48 UTC
(The web site is still under construction)
I think I see where your comming from with you thoughts on this. For myself, this low carb kick of flagging what is good and what is bad on the menu board took less brain power than lifting a morning cup of coffee. With only thirty minutes to eat between work and class, these easy-to-learn flags are all most anyone needs.
For the gentlemen who's irony was thicker than his backside, attention to atleast some of this detail may not be such a bad idea.
Sunday, 20 June 2004 19:51:13 UTC
I think I understand your point.
Copy and paste a code is not a good idea, but it's the simplest way.
But at least it was a diet coke .... But at least it was a good code.
Depending on the deadline, sometimes we have to give up the elegance.
JG
Monday, 21 June 2004 15:08:03 UTC
THANK you JG. Yes, the analogy was:

* Copying and Pasting code is bad, much like an order of Large Fries.
* Attempting to reuse some code is good, much like ordering a Diet Coke, rather than a Regular Coke.

The question then is, is it good that the programmer attempted to reuse code? Or bad that he just copy/pasted?
Scott Hanselman
Monday, 21 June 2004 17:50:03 UTC
Reuse is not about copying and pasting. Any text editor will allow you to copy\paste to your hearts content without regard for the quality of the code. Reuse is about designing interfaces and libraries of implementation that are well designed, stable, and solve a general enough problem that they can be pulled into projects as needed and increase the productivity and\or efficiency of the team (since they would otherwise have to implement it anyhow). I liked your "simile" and it got the point across and probably made some people think. That is always a good thing. ;) However, IMHO, this isn't a question of reuse as much as a practical application of using a piece of code that the developer thought would save them time. We've all done it. It's like using a template (not generics) and there are several companies that even make a profit of(f) it. In that regard, it's a good thing. The real question is was the code that they copied the right solution or not?
Darin Creason
Monday, 21 June 2004 17:56:22 UTC
Touché and gracias! http://www.purchon.co.uk/poetry/simile.html

Analogy? :)

Ya, the good was good, the idea was good, the issue was that they could copy/paste in 15 seconds, or take 4 hours and refactor the code they needed from where it was to a utility class that wasn't bound to a particular context. So, then punted and copy/pasted with a few changes.
Scott Hanselman
Thursday, 24 June 2004 23:27:07 UTC
i understood the point perfectly. just so you know that the analogy wasn't lost on everyone. ;+)

regarding this:
>The real question is was the code that they copied the right solution or not?

no the issue here is that even if the code is the right solution, by copying it all future maintenance is made harder because there are now two places to maintain the same code.

cheers
leon
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.