Free Ebook cover Programming Logic Foundations: Thinking Like a Programmer

Programming Logic Foundations: Thinking Like a Programmer

New course

10 pages

Thinking Like a Programmer: From Real-World Tasks to Precise Procedures

Capítulo 1

Estimated reading time: 7 minutes

+ Exercise

Programming logic is a way of thinking that turns a vague intention into a procedure you can execute and verify. In everyday life, we often start with fuzzy goals (“get organized”, “eat better”, “be on time”). A programmer’s approach is to translate that fuzziness into statements that are specific, measurable, and testable: inputs are known, rules are explicit, and “done” has a clear definition.

What “thinking like a programmer” means

To approach a problem with programming logic is to:

  • Remove ambiguity: replace words like “soon”, “better”, “clean”, “organized” with measurable conditions.
  • Define terms: ensure everyone means the same thing by “urgent”, “cheap”, “important”, “nearby”.
  • State assumptions: what you’re allowed to use, what constraints exist, what you’re ignoring.
  • Make success checkable: you should be able to answer “Did we succeed?” without debate.

This is not about writing code; it’s about writing a precise problem statement that could be coded (or followed by a person) without guesswork.

A repeatable problem-framing template

Use this template whenever you encounter a messy request or a vague goal:

SectionWhat to writeExample prompts
GoalThe outcome in one sentence.What do we want to happen? For whom?
DefinitionsKey terms and how to measure them.What does “cheap” mean? What counts as “done”?
AssumptionsConstraints, resources, and what’s out of scope.Budget? Time? Tools? Data available?
Success criteriaChecklist of verifiable conditions.How do we test it? What must be true at the end?

When you fill this in, you’re building a “contract” between the messy real world and a precise procedure.

Continue in our app.

You can listen to the audiobook with the screen off, receive a free certificate for this course, and also have access to 5,000 other free online courses.

Or continue reading below...
Download App

Download the app

Scenario 1: “Make a shopping list”

Messy description

“Make a shopping list so we can cook this week.”

What’s ambiguous?

  • How many days is “this week”?
  • What meals count (breakfast/lunch/dinner/snacks)?
  • Dietary rules? Budget? Store availability?
  • Do we already have ingredients at home?

Rewrite using the template

Goal: Create a shopping list of ingredients needed to cook dinners for 5 days.

Definitions:

  • day = one dinner meal for 2 people
  • ingredient needed = not currently in pantry/fridge in required quantity
  • shopping list item = ingredient name + quantity + unit

Assumptions:

  • We will cook 5 dinners (Mon–Fri) for 2 people.
  • Budget limit: $80 total.
  • No seafood; vegetarian meals allowed.
  • We can shop at one store; ignore coupons.

Success criteria:

  • List contains all missing ingredients for the 5 selected recipes.
  • Each item includes quantity and unit (e.g., 2 cans black beans).
  • Total estimated cost is ≤ $80 (rough estimate is acceptable).
  • No item duplicates (combine quantities).

Step-by-step procedure (one possible approach)

  1. Select 5 dinner recipes that satisfy constraints (no seafood, within budget).
  2. For each recipe, write required ingredients with quantities.
  3. Check pantry/fridge; subtract what you already have.
  4. Combine same ingredients across recipes (sum quantities).
  5. Optionally estimate cost and adjust recipes if over budget.

Notice how the rewritten version makes it possible to verify completion: you can check whether every recipe is covered and whether each line item is complete.

Scenario 2: “Sort these papers”

Messy description

“Sort these papers and make them organized.”

What’s ambiguous?

  • What categories should exist?
  • What does “organized” mean (alphabetical, by date, by topic)?
  • What about duplicates, junk mail, or documents with missing dates?
  • Where should the sorted papers go?

Rewrite using the template

Goal: Sort a stack of papers into labeled folders and discard items that are not needed.

Definitions:

  • needed = must be kept for legal, financial, medical, or warranty reasons
  • folder = physical folder with a label and a date range (if applicable)
  • discard = shred if contains personal info; otherwise recycle

Assumptions:

  • We will use 6 folders: Taxes, Banking, Medical, Home, Work/School, Manuals/Warranties.
  • Tax documents older than 7 years can be discarded.
  • Anything without a clear category goes into a temporary To Review folder.

Success criteria:

  • Every paper is either placed into exactly one folder or discarded.
  • Folders have consistent ordering rules (e.g., newest-to-oldest within each folder).
  • To Review contains only items that truly require a decision (not laziness).

Step-by-step procedure

  1. Create the folders and labels.
  2. Process papers one by one:
  3. For each paper, decide: discard vs keep.
  4. If keep, assign to exactly one folder; if unclear, place in To Review.
  5. Within each folder, sort by date (newest first). If no date, place behind dated items.

The key programming-logic move is defining categories and rules so two different people would sort the same stack similarly.

Scenario 3: “Get ready faster in the morning”

Messy description

“I want to get ready faster in the morning.”

What’s ambiguous?

  • Faster compared to what baseline?
  • Which steps are included (shower, breakfast, commute prep)?
  • What constraints exist (must pack lunch, must walk dog)?

Rewrite using the template

Goal: Reduce the time from waking up to leaving the house from 75 minutes to 55 minutes on weekdays.

Definitions:

  • start time = alarm off and out of bed
  • end time = door locked and leaving
  • weekday = Monday–Friday

Assumptions:

  • Must include: shower, get dressed, basic breakfast, pack bag.
  • Cannot skip shower; cannot prepare breakfast that requires cooking in the morning.
  • Evening prep is allowed.

Success criteria:

  • On at least 4 of 5 weekdays, total time ≤ 55 minutes.
  • Breakfast is eaten and bag contains required items (keys, wallet, phone, work badge).

Step-by-step procedure (measure, then change)

  1. For 3 mornings, record durations of each step (shower, dressing, breakfast, packing).
  2. Identify the top 1–2 time consumers.
  3. Apply one change at a time (e.g., pack bag at night; set clothes out; switch to grab-and-go breakfast).
  4. Re-measure total time for a week and compare to success criteria.

This illustrates another programming habit: you can’t optimize what you haven’t defined and measured.

Scenario 4: “Clean the kitchen”

Messy description

“Clean the kitchen so it looks nice.”

What’s ambiguous?

  • What areas count as “kitchen” (stove, fridge interior, floor)?
  • What does “nice” mean (no dishes, no crumbs, no stains)?
  • How long should it take? What cleaning supplies are available?

Rewrite using the template

Goal: Clean the kitchen to a defined standard in 20 minutes.

Definitions:

  • countertops clean = no visible crumbs/stains; wiped with cleaner
  • sink clean = no dishes; basin rinsed; faucet wiped
  • floor spot-cleaned = visible debris removed in main walking area

Assumptions:

  • Deep cleaning (inside oven/fridge) is out of scope.
  • Supplies available: dish soap, sponge, all-purpose spray, paper towels, trash bags.

Success criteria:

  • All dishes are either in dishwasher (running if full) or hand-washed and put away.
  • Countertops and stove surface wiped.
  • Trash taken out if bag is ≥ 80% full.
  • Sink empty and wiped; floor debris removed in main area.

Step-by-step procedure (time-boxed)

  1. Start a 20-minute timer.
  2. Clear dishes: load dishwasher first; then hand-wash remaining.
  3. Wipe stove and countertops.
  4. Empty trash if needed.
  5. Rinse and wipe sink; quick sweep/spot-clean floor.

By defining “clean” as a checklist, you remove the endless-loop feeling of “keep cleaning until it feels done.”

How to rewrite a messy request: a quick method

When you’re handed an unclear task, use this mini-process:

  1. Underline vague words (better, soon, organize, optimize, nice, enough).
  2. Ask “How would we measure that?” Replace vague words with measurable conditions.
  3. List inputs and constraints (time, budget, tools, allowed actions).
  4. Write success as a checklist that a stranger could verify.

If you can’t fill in a section, that’s not failure; it’s a signal that you need a decision or a question answered.

Practice: rewrite messy descriptions into precise tasks

For each prompt, produce a problem statement using Goal, Definitions, Assumptions, Success criteria. Keep it short but checkable.

  • “Plan a fun weekend.”
  • “Fix my computer; it’s slow.”
  • “Organize my photos.”
  • “Eat healthier.”
  • “Make sure the team communicates better.”
  • “Clean up my email inbox.”
  • “Find a good apartment.”
  • “Study for the exam efficiently.”

Now answer the exercise about the content:

Which rewrite best applies programming logic to turn a vague goal into a checkable task?

You are right! Congratulations, now go to the next page

You missed! Try again.

Programming logic removes ambiguity by defining measurable terms, stating assumptions and constraints, and making success testable with a checklist.

Next chapter

Problem Decomposition and Subproblems in Programming Logic

Arrow Right Icon
Download the app to earn free Certification and listen to the courses in the background, even with the screen off.