4 min read
On this page

Conditionals & Decisions

Conditionals are the "if-then-else" of thinking. They are how you handle situations that require different actions depending on the circumstances. Every decision you make — from what to wear in the morning to how a thermostat controls your home's temperature — is a conditional.

This chapter explores how conditional thinking works in everyday life and in technology, and how to structure decisions clearly.

The Basic Structure

A conditional has three parts:

  1. A condition — something you check
  2. A "then" action — what you do if the condition is true
  3. An "else" action (optional) — what you do if the condition is false
IF it is raining
THEN take an umbrella
ELSE wear sunglasses

This is the simplest form. But real decisions are rarely this simple — they often involve multiple conditions and multiple possible actions.

Everyday Conditionals

Traffic Lights

Traffic lights are a perfect example of conditional logic:

IF the light is green
THEN proceed through the intersection

ELSE IF the light is yellow
THEN slow down and prepare to stop

ELSE (the light is red)
THEN stop and wait

Everyone who drives follows this conditional logic. The light's color is the condition. Your action depends entirely on which condition is true.

Thermostat Logic

A thermostat makes decisions continuously:

Read the current temperature

IF current temperature < target temperature
THEN turn on the heater

ELSE IF current temperature > target temperature
THEN turn on the air conditioning

ELSE
THEN do nothing (temperature is at the target)

Real thermostats add more conditions — time of day, day of week, occupancy — each checked in order, with the first match determining the action.

Eligibility Rules

Many real-world processes are built on conditionals:

Voting eligibility:
IF citizen = true AND age >= 18 AND NOT currently incarcerated
THEN eligible to vote
ELSE not eligible

Library card:
IF resident of the county OR student at a local school OR pays non-resident fee
THEN issue library card
ELSE cannot issue library card

Shipping:
IF order total > $50
THEN free shipping
ELSE IF order total > $25
THEN shipping = $5
ELSE
THEN shipping = $10

These rules may look simple written out, but they govern enormous systems. Tax codes, insurance policies, and legal regulations are all vast collections of conditionals.

Nested Conditionals

Sometimes decisions live inside other decisions. These are nested conditionals:

Choosing what to have for dinner:

IF you are eating at home
THEN
    IF you have ingredients for pasta
    THEN make pasta
    ELSE IF you have ingredients for stir fry
    THEN make stir fry
    ELSE order delivery

ELSE (eating out)
    IF you want something quick
    THEN go to the nearby cafe
    ELSE
        IF you feel like Italian
        THEN go to the Italian restaurant
        ELSE go to the Thai restaurant

Nesting can get deep and confusing. When it does, it helps to break the decision into separate, named sub-decisions:

Step 1: Decide where to eat (home or out)
Step 2a: If home, decide what to cook (based on available ingredients)
Step 2b: If out, decide which restaurant (based on mood and time)

Chains of Conditions

When you have many possible outcomes, you use a chain of "else if" conditions:

Grading scale:
IF score >= 90 THEN grade = A
ELSE IF score >= 80 THEN grade = B
ELSE IF score >= 70 THEN grade = C
ELSE IF score >= 60 THEN grade = D
ELSE grade = F

The order matters here. Because the conditions are checked from top to bottom, a score of 85 hits the first condition it matches (>= 80, since >= 90 was already checked and failed). If you rearranged the conditions, you could get wrong results.

Default Actions

The "else" at the end of a conditional chain is the default — what happens when none of the specific conditions match. Defaults are important because the real world is full of unexpected situations.

Customer requests a refund:
IF purchased within 30 days AND has receipt
THEN full refund
ELSE IF purchased within 30 days AND no receipt
THEN store credit
ELSE IF purchased within 90 days
THEN exchange only
ELSE
THEN no refund (default)

Without a default, you risk having a situation that falls through all your conditions with no defined response. This is a common source of bugs in both processes and software.

Conditionals in Technology

If Statements

The most basic programming construct:

if user has account:
    show their dashboard
else if user is a guest:
    show the public page
else:
    show the login page

Switch / Case Statements

When a single value can match multiple options, a switch structure is cleaner than a long chain of if-else:

Based on the selected language:
  case "English":  greet with "Hello"
  case "Spanish":  greet with "Hola"
  case "French":   greet with "Bonjour"
  case "Japanese": greet with "Konnichiwa"
  default:         greet with "Hello"

This is equivalent to an if-else chain but reads more clearly when you are matching one value against many options.

Business Rules Engines

Large organizations often have hundreds or thousands of business rules — each one a conditional. Instead of writing them all as code, they use business rules engines that let non-programmers define and modify rules:

Rule: Fraud Alert
IF transaction amount > $5,000
AND transaction location is different from customer's home country
AND no travel notification on file
THEN flag transaction for review
AND notify fraud team
AND send alert to customer

Insurance companies, banks, and healthcare systems rely heavily on these engines. The logic is conditionals — the same "if-then-else" thinking — just at massive scale.

Feature Flags

Modern software often uses conditionals to control which features are visible:

IF user is in beta testing group
THEN show new checkout flow
ELSE show old checkout flow

This lets companies gradually roll out new features without deploying different versions of the software. It is conditional logic applied to product strategy.

Common Pitfalls

Missing the else

If you only handle the conditions you expect, unexpected situations slip through. Always consider what should happen when none of your conditions match.

Wrong order of conditions

Conditions are checked in order. If a broader condition comes before a more specific one, the specific one may never be reached:

Wrong:
IF score >= 60 THEN grade = D     <- score of 95 matches here!
IF score >= 90 THEN grade = A     <- never reached for 95

Right:
IF score >= 90 THEN grade = A     <- check most specific first
ELSE IF score >= 80 THEN grade = B
...

Overlapping conditions

When conditions overlap, the same input could match multiple rules. This leads to unpredictable behavior. Ensure your conditions are mutually exclusive, or rely on the order of checking.

Too many nested levels

Deeply nested conditionals are hard to read and prone to errors. If you find yourself nesting more than three levels deep, restructure by using guard conditions, breaking into sub-decisions, or simplifying the logic.

Key Takeaways

  • Conditionals are the "if-then-else" structure that governs decision-making in both everyday life and technology.
  • Every conditional has a condition to check, an action if true, and optionally an action if false.
  • Real decisions often involve chains (else-if) and nesting (decisions within decisions).
  • Always include a default action for when no specific condition matches.
  • In technology, conditionals appear as if statements, switch cases, business rules engines, and feature flags.
  • Guard conditions handle exceptional cases upfront and keep the main logic clean.
  • Order matters: check conditions from most specific to most general.