Scott Hanselman

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

June 19, 2004 Comment on this post [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
Hosting By
Hosted in an Azure App Service
June 19, 2004 4:01
Drinking Diet Coke has nothing to do with 'diet'. It's all about the caffeine.
June 19, 2004 4:20
Touché! As a diabetic, I DO drink only Diet Rite or Caffeine Free Diet Coke. ;)
June 19, 2004 9:11
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.

June 19, 2004 9:43
I drink Diet Coke because I prefer the tast. Chris, have we met?
June 19, 2004 10:35
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.
June 19, 2004 11:59
I have to vote for the taste, too. It's what I learned to caffeinate on.
June 19, 2004 22:33
Sigh...apparently the analogy didn't work. -1 for my failed Programming metaphors. :)
June 20, 2004 10:14
(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.
June 20, 2004 23:51
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
June 21, 2004 19:08
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?
June 21, 2004 21:50
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?
June 21, 2004 21:56
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.
June 25, 2004 3:27
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.