Currently accepting inquiries for Webflow Websites and SEO Projects for Q2.

Think Like a Developer

November 12, 2021
Updated:
May 1, 2023

Think Like a Developer

A programmer's wife sends her husband to the store to get some bread. She adds "Oh, and if they have eggs, get a dozen." Her husband comes home with a dozen loaves of bread.

Get it? Good. Don't get it? Don't worry. By the end of reading this, you should be up to speed.

This joke is not only good for a cheap laugh (at least in my case), but also helps to highlight how developers, and more importantly computers, 'think' about tasks. Computers may seem hyper-intelligent and extremely powerful tools. And with the right software, it CAN be the case. But that's what matters here. The software was designed to be powerful. The computer that runs said software, however, is spectacularly stupid. It needs to be told exactly what to do, under what exact parameters, and exactly how to do it. So let's revisit the joke.

The "go get bread" statement seems pretty simple. In programming, this would just be a function that tells the software to go do something, like retrieve bread. But the issue arises with the additional parameter of "if they have eggs", and then the unfortunately vague (at least in the eyes of a computer) of "get a dozen". Now to you every-day folk, it's painfully obvious that the wife wants a loaf of bread and a dozen eggs. But the wife wasn't specific enough. Here's how the computer reads it.

Go to the store and get a loaf of bread - Go to the store and get X number of loaves, and set X to be equal to 1. We are getting one loaf of bread.

If they have eggs - Okay, so we have a conditional statement.

Get a dozen - Well, I wasn't told what to get a dozen of, so I'm assuming loaves of bread. I checked for eggs, they are available, so X is now set to 12. I will retrieve 12 loaves of bread.

Or if we were to put it into code:

loafCount = 1;

if ( store has eggs) { loafCount = 12; }

getBread(loafCount);

So that "if" statement is the condition under which a part of the software may change, even if in a minor way. But without properly spelling it out, your software is going to either do it's best to guess what it is you need to be done, or it's going to throw it's hands up (crash) and send you back to the drawing board to figure out a more specific way to bend humanity's most un-intelligent tool to your will.

Thinking like a developer means thinking like a computer. Sure, you need to know the programming language you'll be using for whatever project you're building. But the biggest part of being a talented developer is the ability to anticipate how a computer will react to the commands you give it. The better you can do this, the fewer bugs you'll have to fix.

Related Articles