Conditions of Coffee Consumption

moreReese
4 min readDec 7, 2020

--

Drinking coffee is a lot like computer programming. And that’s a good thing.

Conditional statements help us to handle events in programming. They say, when this thing happens under these conditions, do this other thing. Or, more simply put: if this, then that.

Conditional statements are ubiquitous in programming. They’re programmatic building blocks in everything from phones to satellites to the microwave that heats your breakfast burrito to delicious perfection. Without conditional statements, we wouldn’t be living in the technological world we are today.

However, conditional statements aren’t limited to the programs in our computers. They’re part of our everyday, non-technological lives. In fact, you don’t have to look too hard to see conditionals in your own life.

For example, if you drink coffee every day in the morning but never in the afternoon, you’re operating under a conditional statement. Implicitly, you’re saying: if it’s the morning, I’ll have coffee. But if it’s the afternoon, I won’t have coffee. In effect, these are rules around your coffee consumption. For me, these rules look something like: I don’t have coffee after 11AM and I limit myself to 2 cups per day. (If I break these rules I can kiss a good night of sleep goodbye.)

You might be thinking, what does this have to do with programming?

A lot. This example illustrates what’s called an if-else statement, one of the most common conditional statements in programming . If-else statements are part of the program that tell the computer, if <this thing> meets <this condition>, then do this thing.

The concept seems straightforward enough. It is straightforward. As a rule of thumb, though, what’s straightforward to us as humans is not straightforward to computers. Computers take things literally so we need to tell them exactly what to do.

Let’s try to illustrate this using my coffee consumption rules example above. Think of my brain as the computer and coffee? as the program, which looks something like this:

Drinking coffee is a lot like computer programming. And that’s a good thing.

Conditional statements help us to handle events in programming. They say: when this thing happens under these conditions, do this other thing. Or more simply put: if this, then that.

Conditional statements are ubiquitous in programming. They’re programmatic building blocks in everything from phones to satellites to the microwave that heats your breakfast burrito to delicious perfection. Without conditional statements, we wouldn’t be living in the technological world we are today.

However, conditional statements aren’t limited to the programs in our computers. They’re part of our everyday, non-technological lives. In fact, you don’t have to look too hard to see conditionals in your own life.

For example, if you drink coffee every day in the morning but never in the afternoon, you’re operating under a conditional statement. Implicitly, you’re saying if it’s the morning, I’ll have coffee. But if it’s the afternoon, I won’t have coffee. In effect, these are rules around your coffee consumption. For me, these rules look something like: I don’t have coffee after 11AM and I limit myself to 2 cups per day. (If I break these rules I can kiss a good night of sleep goodbye.)

You might be thinking, what does this have to do with programming?

A lot. This example illustrates what’s called an if-else statement, one of the most common conditional statements in programming . If-else statements are part of the program that tell the computer, if <this thing> meets <this condition>, then do this thing.

The concept seems straightforward enough. It is straightforward. As a rule of thumb, though, what’s straightforward to us as humans is not straightforward to computers. Computers take things literally so we need to tell them exactly what to do.

Let’s try to illustrate this using my coffee consumption rules example above. Think of my brain as the computer and coffee? as the program, which looks something like this:

morning = 6AM — 11AM
craving = “I want coffee!”
coffee_limit = 2 or less cups
if morning AND craving AND coffee_limit:
drink coffee
else:
don't drink coffee

Let’s break this apart.

Morning, craving and coffee_limit are all examples of another building block of programming: variables. Variables are placeholders for definitions, or value. For example, if I wanted to increase my daily coffee limit to 3 cups, I’d update the coffee_limit variable in my coffee? program.

The conditional aspect of the program is initiated with if. If essentially tells my brain (the computer), check if all three of my variables are true (i.e., it’s between 6AM-11AM and I am craving coffee and I’ve had less than 2 cups). Or else (in other words, if any of my variables are false) don’t drink coffee.

Conditional statements like this are a good thing — for us and computers alike. They provide parameters, or rules under which to operate. They help us to create, reshape, and work within the necessary boundaries of everyday life.

Unlike computer programs, though, we humans have a bit more liberty when it comes to breaking the rules and operating outside of a conditional. So go ahead and have that extra afternoon coffee. Just don’t spill on your computer.

--

--

moreReese
moreReese

Written by moreReese

Writing about DAOs mostly & crypto education

No responses yet