Get A Quote

Think Like a Developer

Nik Kenney - June 12, 2018
Facebook
Twitter
Pinterest
LinkedIn

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.

Red Shark Digital is a superior full-service digital marketing agency that specializes in Web Design, SEO, Branding, and Digital Advertising. With offices across North Carolina including Raleigh, Greenville, and Wilmington, our team of digital marketing specialists are able to create catered solutions for your business needs. Our clients have allowed us to push the boundaries of web and creative design, while building innovative results for their company and their brand. These clients have encompassed multiple industries including higher education, healthcare, and major commercial franchises. Our wide range of clientele has allowed us to craft specialized strategies for businesses of all sizes while conveying our knowledge across a variety of platforms. We always strive to connect brands to customers, learn what we can do for your business today.

Join Our Newsletter