Example Code, Redux

I’m still trying to rationalize the existence of example code. You know, the poison pills programmers copy and paste into an otherwise healthy body of software.

Sometime today, I was thinking back my first physics class, and of three key idealizations. These idealizations have helped students learn physics since the debut of Principia Mathematica in the 1680s.

The idealizations are:

  The immoveable object.
  The irresistible force.
  The frictionless surface.

Of course, nobody actually builds bridges or launches rockets using irresistible forces and frictionless surfaces, but the concepts do make the first chapters in a physics textbook easier, and we learn from them. If there are parallels to these idealizations in the sample code on MSDN, in books, and on this blog, they would be:

  The never-null parameter.
  The always-on network.
  The perfect string of user input.

We learn from them.

Print | posted @ Thursday, March 31, 2005 5:12 AM

Comments on this entry:

Gravatar # re: Example Code, Redux
by Darrell at 3/31/2005 4:18 PM

The perfect string of user input, good one. :)
  
Gravatar # re: Example Code, Redux
by yipyip at 3/31/2005 5:38 PM

But in physics, the student does proceed through more complex and more accurate models of the real world until one is able to build a bridge, as you say. Friction is introduced, for example, way back in high school.
<br>
<br>In software, where is the corresponding learning/training curve? Where does Joe self-taught or Bob university student go to develop his abilities from the frictionless ideal to the real-world mess?
<br>
<br>What I'm trying to say is that for the vast majority of people in the world who write software, they're not lucky enough to be mentored by competent, experienced people. So they turn to examples to see what they should be doing.
<br>
<br>But there are just about no examples between the &quot;immovable force&quot; and &quot;bridge building&quot; levels in software.
  
Gravatar # re: Example Code, Redux
by bill at 4/2/2005 4:23 AM

You deserve a nobel prize - this post is brilliant!
  
Gravatar # re: Example Code, Redux
by Brian H. Madsen at 4/2/2005 6:14 PM

Scott:
<br>
<br>What i found funny here is that you actually see people using the exact same code as is found in books in full faith that it's &quot;good&quot; code.
<br>
<br>If ever you confronted a developoer on the topic and you get the &quot;bleary/blank eyes of no compute&quot; from the developer, you know you've found yourself a person who simply does not know what he/she is coding up.
<br>
<br>shame really - i mean, example code is just that, examples..
<br>
<br>anyways, last comment..&quot;the perfect string of user input....&quot;...OMG!! i'm going to have to print that and hang it on my office wall!
  
Gravatar # re: Example Code, Redux
by Beth at 4/8/2005 9:07 PM

the never-null parameter. HA HA!
<br>
  
Gravatar # re: Example Code, Redux
by Tobin Titus at 7/24/2005 2:12 PM

amen brother! thank you!
  
Comments have been closed on this topic.