Stop coding right now!
Whatever it is. Whatever you’re working on. Whatever last piece of code snippet you just wrote. STOP! And ask yourself these questions.
Are you solving any real problem? Is this going to be helpful to real people? Are you advancing something, one thing, anything? Is that last line of code you wrote going to make an impact?
Not sure where to start? Try this exercise:
Word of caution
Before doing this, make sure you have time. If you have a deadline coming up, then don’t read this. This is not for you; right now.
Ok, open up your code editor
That’s right. Fire that puppy up, and open that last file you were just working on. To make this easier on yourself, most text editors come with a open recent document
feature so pick one of those that has been the most interesting to you within the last {n} number that are listed.
Now that you have that open, pick a line number between 1 and the total amount shown. Or if you know the document too well and that’s not going to help the random factor
, try scrolling up and down the document using your mouse while keeping your eyes closed. After an arbitrary amount of seconds, stop, then point your finger in the middle of the screen to a line of code.
Now, what’s the sole purpose of that line of code? Why did you write it? Did it solve anything? What about the code that is immediately surrounding it? Is that code solving any real problem?
The point?
This is just a friendly reminder to not forget that writing code should have a purpose. Too often as developers and engineers we get caught up in making things superfluous in our code that we lose site of the actual problems we’re trying to solve. That’s it. That’s all. Now have a good day.




June 22nd, 2006 at 1:38 am
if(nametxt==(”||’ ‘)) nametxt=’zzz’;
I must have been bored
June 22nd, 2006 at 1:46 am
" alt="" class="lead-image" />Absolutely vital to my new wordpress theme. But thanks for interruption, I will attack this day with renewed purpose.
June 22nd, 2006 at 2:07 am
Object.prototype.states=function(){return stateHandler.returnMe(this)}
Working on a state/memento handler for JavaScript objects… Because I’m tired of writing undo/redo functions over and over.
June 22nd, 2006 at 3:55 am
‘This is just a friendly reminder to not forget that writing code should have a purpose.’
Why? If someone’s paying you to write it or depending on you in some way, fair enough. But otherwise?
June 22nd, 2006 at 4:02 am
World.conquer(”less than 5 minutes”);
June 22nd, 2006 at 4:33 am
@order = Order.new
Yup, pretty vital!
June 22nd, 2006 at 5:14 am
@d = @d.line(@graph_left - 10, y, @graph_right, y)
Tweaking Gruff to better layout. If I ever get some free time, I’m going to rewrite it a bit to enhance the functionality, display, etc. and return the code to its author.
Not vital, but it’d be nice if Gruff were a bit more, well, “grown-up”.
June 22nd, 2006 at 5:20 am
$this->pagesTable = $this->ffConf["setPagesTable"];
This line is absolutely necessary, but I shall remember this technique and do it more often :-)
June 22nd, 2006 at 6:14 am
slug = models.SlugField(prepopulate_from=(’title’,))
100% needed. It’s used to map the url.
Thanks for the reminder that every bit (no pun intended) of code matters!
June 22nd, 2006 at 7:15 am
if ( DataStore::hasResults($allBooks) )
Definitely important, checks to see if we have books for listing. hehe.
This is a great post, and should be done more often by developers.
June 22nd, 2006 at 7:17 am
return PathGenerator.getUserKeyvisualURL(userID) + getFilePrefixBuffer();
Um, yeah pretty important.
What about you, Dustin?
June 22nd, 2006 at 7:32 am
function is_malicious($input) {
Yup. Gotta have it. But that was just good timing on my part. I’ll remember this (or put a big posty note on my laptop.) Thanks!
June 22nd, 2006 at 7:36 am
else echo ‘Next ‘ . $len . ‘ Calendar Events:’;
Is quite necessary I suppose :D Just doing some parsing of my 30Boxes calendar using PHP.
June 22nd, 2006 at 8:01 am
Now well that’s pretty obvious isn’t it…
$MyWeb = new Innovation();
June 22nd, 2006 at 8:33 am
typo: “site” should be “sight”.
June 22nd, 2006 at 9:01 am
Wow! What a great turn out. I went ahead and tried it myself following my own instructions exactly. When I opened up a file and scrolled around a bit (my eyes were even closed), I stopped then pointed in the middle of the screen and landed on this of all things!
Go figure. Without that, my code is done for.
June 22nd, 2006 at 9:14 am
I got a question, did you right this after a near-death experience ’cause it sounds like one of those motivational ‘don’t jump’ books for developpers. :p just joking. Good post!
June 22nd, 2006 at 9:43 am
By title, I really thought this article was going somewhere else.. Oh well :P
It took me a while to find a good file.. there is either not enough code in some files or too many comments..
$finder = &$this->getFinder(’thread_tags’);
$tags = &$finder->selectWhere(’COUNT(*) as tag_count’, ”, array(), 1);
I’m sure you can guess what that does ;)
June 22nd, 2006 at 10:34 am
Agreed. There’s a lot of fluff out there that does not enhance the user experience or improve performance. Probably a good exercise in learning, but a useless feature for intended audience: the damn users.
June 22nd, 2006 at 10:41 am
// Useless code below to waste time
Do comments count?
June 22nd, 2006 at 11:40 am
I picked line 40…Turns out, this is what line 40 is:
Basically, blank. :P So I go down one line:
Debugging.
June 22nd, 2006 at 12:21 pm
I just thought I should add, that blank line is also quite important. Just as whitespace is a big part of frontend design, I think whitespace is quite important in the actual layout of one’s code. Good spacing makes things 10 times easier to follow.
June 22nd, 2006 at 1:58 pm
Testing to see if product reviews for a given product are available from multiple partner feeds.
Kinda important, if someone wants to read all the related information and reviews for a tech product
June 22nd, 2006 at 2:47 pm
@repeats_onLine 162 for me! w00t!
Useful? yes. Frustrating? Yes. Point? Make some $$. hehe.
June 22nd, 2006 at 2:51 pm
good grief. no html escaping, dustin??
here’s the code after postable
@repeats_on << Time.utc((y.to_i e.to_i), months_to_num[n], h).to_iJune 22nd, 2006 at 5:56 pm
June 22nd, 2006 at 6:07 pm
rc = fscanf(f, “Drumkit Make:%[^\n]%*c”, dkmake); linecount++;
Hastily written code to read in drumkit file
for a drum machine program. Definitely needed,
though it could certainly be better written.
(I mean fscanf? Really. What was I thinking?
Well, I was thinking “I’ll clean this up later,
right now I just want that drumkit out of that
file and into RAM, and NOW.)
I’m trying to think of an example of writing
code that doesn’t do anything useful. I’m having a hard time imagining the sort of “useless” code… Well, I did add French translations to this program, and I don’t speak French, nor know anybody who does. I let google translate everything, so they are abominable translations to boot. Arguably useless code, LOL. But it’s pretty well cordoned off from the rest, so the whole program isn’t exactly polluted with krufty translation garbage, and arguably the infrastructure could be used to do more translations with trivial effort. Still useless? Probably.
Then there is at least one faild user-interface experiment. I had no way of knowing it was going to fail without trying it out though.
The other sort of useless code I write is little toy programs written purely for entertainment, or education, like a little program to try to use an evolutionary algorithm to produce MIDI music. An utter failure, in that the selection process involved listening to loads of random crap. So it was pretty useless, although I did learn not to attempt that path again, and how to write code that talks to MIDI devices (leading to the drum machine program…)
I don’t think “useless code” is a problem which needs solving any more than “books I find boring” are a problem libraries need to solve.
June 22nd, 2006 at 6:35 pm
Ok, I think this technique can apply to a gigantic print of your current app’s UI: point anywhere with your eyes closed, now ask yourself it those few pixels are doing anything important.
I just couldn’t figure out why would anybody write a single line of code without a purpose? And no, Microsoft’s feature-bloat doesn’t count.
June 22nd, 2006 at 10:20 pm
Sums up what I felt yesterday after trying out Java EE 5 (supposedly, an improvement over J2EE). The sheer complexity of the framework (even after simplification) made me ask myself what problem I was trying to solve.
Now I realize that technology is just a means, not an end. The end is the solution to the problem (if there exists one).
June 23rd, 2006 at 1:25 am
I saw today jQuery library and thought about your post, Dustin. :]
June 23rd, 2006 at 5:39 am
I think this can apply more to a UI design rather than code. Print a really large banner with your current app UI on it, now close your eyes and point somewhere then ask yourself if that particular icon is conveying anything to the user.
I’m not sure than anybody would write *any* line of code without a purpose, even the witty comment. //
June 23rd, 2006 at 6:03 am
First go with some Java servlet code:
Hmm, lets try some JS:
Yes, we need that bit :-)
June 23rd, 2006 at 7:09 am
A good excercise — I immediately found something I did the easy/repetitive way, instead of the “good”/efficient way.
June 23rd, 2006 at 10:44 am
q[igrid]( I1,I2,I3, vc ) = flowParameters.initialData.v;
Great little piece, though. Reminds me of Richard Hamming’s comments… He was running research at Bell Labs and would roam around the cafeteria and sit with random research groups. In no time he would ask the uncomfortable questions:
“What are the most important problems in your field? Are you working on one of them? Why not?”
He’s point was simply that “It is better to solve the right problem the wrong way than to solve the wrong problem the right way.â€
Read his piece on
“You and your research”
June 25th, 2006 at 1:13 pm
Line 52: $_cache[] = (trim_empty($value)) ? ‘true’ : ‘false’;
A function that check which elements of e.g. the $_POST Array are empty.
If all elements are really not empty (no whitespaces etc.) the function returns true, otherwise it returns false.
June 26th, 2006 at 2:21 pm
Hi there!
[…] A very accosting layout and a interesting discussion topic, do you provide any Web-based services to universities or students. […]
Greetings Milos
June 26th, 2006 at 10:30 pm
line:091, This is for rosary (a Catholic prayer said on beads) widget.
this.Beads.OF= ”+spaces+’Our Father,Who art in Heaven,hallowed be Thy Name.Thy kingdom come,Thy will be done on earth as it is in Heaven.Give us this day our daily bread, and forgive us our trespasses,as we forgive those who trespass against us.And lead us not into temptation, but deliver us from evil.Amen.’;
June 27th, 2006 at 7:36 am
Where the questions in this post not rhetorical then?
June 28th, 2006 at 1:00 pm
mov ah,09
lea dx,message
int 21h
:)
June 28th, 2006 at 7:09 pm
Crap.. i am done for…
June 29th, 2006 at 10:12 pm
[...] Stop coding right now! - Dustin Diaz [...]
June 30th, 2006 at 12:20 am
line 584: }
quite important for me.
July 12th, 2006 at 2:24 pm
?php the_content(’Continue Reading?’); ?
I suppose displaying my posts is pretty important, eh?
Great post, BTW :)
July 12th, 2006 at 4:08 pm
intPageSize = 10
Well now that’s boring. And needed in this case.
Thanks for the diversion and chance to get philosophical instead of frustrated.
August 11th, 2006 at 1:55 am
include(’functions.php’);
It may solve a lot of problem, who knows? ;)
August 14th, 2006 at 5:52 am
if (!is_array($aQueryString) || empty($aQueryString))
Yeah, I need that =)
August 24th, 2006 at 5:12 am
tree[tree.length]={name:t3,subs:new Array()};
It might not look much, but I had just realised the vast benefits of using JScript rather than VBScript when my hand is forced to use ASP. Yesterday I was struggling with safeArrays and Dictionary objects, now I’ve a face like a hindu cow in a field of dot notation goodness.