Skip to main content
DevHivesBlog

Search the blog

Find a post by title, tag or topic

Ask Why Before Coding: The One Question That Saves First-Job Weeks

Before you touch any code, ask: "What is this actually for?" This one question saves days of wasted work, as a fresher learned after five days of optimizing the wrong thing. Trace your task backwards with five whys, confirm the real goal with your lead, and start shipping work that actually counts.

Arnab Biswas9 min read
WhatsApp
A large question mark, symbolizing the crucial question a fresher should ask before coding.

Say a developer spends five days making a dashboard faster. He tuned queries, reworked the front-end, and refactored the rendering logic. His lead took one look at the result and asked a single question: "Who told you this was the problem?" He had no answer. The task got thrown away.

Before you touch any code, ask: "What is this actually for?" The one question that saves days is not about how to build it, but why it matters. State the real goal in one sentence and confirm it with your lead before you optimize anything.

Ask what it is for before touching code

The question that reveals the real goal is: "What is this actually for?" It sounds almost too simple to matter. But it separates the work that gets shipped from the work that gets deleted.

Say your lead tells you to "make the dashboard faster." That sounds like a clear instruction, but it is not specific enough to act on. You open the codebase and start profiling. But the words are only a clue about the real problem, not the problem itself. Good analysts treat stated requirements as clues and keep asking why until they reach the actual business purpose. That method exists because people describe what they think the solution is, not what they actually need.

The "make it faster" request could mean a dozen real goals. Maybe the sales team loses deals because the dashboard takes a few seconds to load. Maybe the CEO wants a snappier demo for investors. Maybe an internal report that runs for four hours is blocking the night shift. In Rahul's case, the sales team was losing deals because the report took four hours to generate, and the front-end was not the cause. Each of those goals points to completely different work. The first means optimizing the front-end bundle. The second means polishing the animation timeline. The third means fixing the database query, not the dashboard at all.

When you skip the question, you are guessing. And guessing in optimization usually means polishing the part that was never broken. Rahul, a fresher at a Kolkata startup, spent five days rewriting the front-end of a sales dashboard. On Friday, his lead asked one question: "Who told you the dashboard was slow?" It turned out the real delay was a database query missing an index. Rahul's work was discarded.

The five-whys trace finds the real target

Trace the task backwards with five whys until you reach the business purpose. This technique comes from Toyota, where Sakichi Toyoda developed it and Taiichi Ohno used it as the basis of the company's scientific approach. The idea is simple: when a problem appears, ask why it exists, then ask why about that answer, and keep going.

Here is how the trace works on Rahul's dashboard example. It takes about three minutes on paper and saves days of code:

  1. Why faster?

    To reduce the load time for the team.

  2. Why reduce load time?

    Because users are complaining about slow access.

  3. Why are they complaining?

    Because generating the report takes a few minutes.

  4. Why does the report take that long?

    Because the data aggregation step is the slow part.

  5. Why is aggregation slow?

    Because the database is missing an index on the join column. Open your database console and run EXPLAIN on that query; if it shows a full table scan on the join column, that's your proof.

The real problem was a missing index, not the dashboard front-end. Rahul spent five days making the interface render faster, but the interface was never the delay. The user waited for the data, not the pixels. One five-whys trace would have pointed the whole week in the right direction.

The trace works because every answer is a fact you can check. If the first answer is "to make it look professional," you trip over a vague statement and know to dig deeper. If you reach a specific technical cause, you have found your target. Stop there, confirm it, and start working.

Why premature optimization wastes your week

Optimizing before you know the goal is wasted effort; Knuth called it the root of all evil. In his 1974 paper on structured programming, Donald Knuth wrote that we should forget about small efficiencies, most of the time, because premature optimization causes more problems than it solves. He added that we should not pass up the meaningful opportunities in the critical few percent. Premature optimization is widely cited as a source of wasted effort.

The point is not that optimization is bad. The point is that most optimization is aimed at the wrong target. Knuth's principle connects to the common observation that a small portion of code is responsible for most of the execution time. If you optimize the other four fifths, you burn effort and get nothing measurable.

That is the real danger for a fresher. You want to impress people, so you optimize everything you see. You rewrite a loop that runs a dozen times. You cache a value that is already cheap to compute. You spend a day trimming a few milliseconds from a screen that already loads fast. None of that matters, because the user was never waiting on those parts. Freshers typically over-optimize the wrong things: micro-optimizing utility functions, pre-maturely adding caching layers, or polishing code paths that run only during setup. None of that moves the metric users care about.

Knuth's quote is not a license to write slow code. It is a warning about where your time goes. The critical slice of code is the one that users actually wait on, and you can only find it after you have traced the task to its real goal. Rahul optimized the simple case of the front-end. The users were stuck on the aggregation query, which his week of work never touched. The principle saved him nothing because he applied it to the wrong layer.

Confirm the goal with your lead before you start

State the real goal as a one-sentence confirmation and get a yes from your lead. The five-whys trace gives you a hypothesis, but a hypothesis is not a fact until someone who owns the product confirms it. Confirm it with your lead to ensure you are working on the right target.

The phrasing matters less than the structure. You are not asking for permission to skip work. You are showing that you found the true target and you want to make sure you are aiming at it. A good confirmation sounds like this: "So the real goal is to cut the report generation time, not the dashboard render. Should I focus there?"

A good response is a direct yes, or a correction that names the actual goal. Either way, you win. The yes means you can start working on the right thing with confidence. The correction means you just avoided a wasted week.

What if the lead is vague? You will occasionally get an answer like "just make it better" or "figure out what's wrong." Push once, gently, with the trace you already built. Say you traced the slowness to the aggregation step and ask whether that matches what users report. If the lead still gives you nothing, narrow your scope to the part of the system that is objectively slow, measure it, and present the evidence with your question. A concrete number beats an abstract request every time. For example, say: "The EXPLAIN shows a full table scan; adding an index cut the query from four hours to ten seconds."

Common mistakes when you ask why

Asking why too late, asking it once, or asking it in the wrong tone loses the benefit. The question is powerful, but the timing and delivery decide whether it helps or hurts you.

First, asking after days of work is the most common mistake. You build the optimization, present it, and only then discover the target was different. The entire effort is scrap. The question costs a few minutes. The guess costs a week. Ask the question before you open your editor, not after you have already "solved" the wrong problem.

Second, stopping at the first why (asking it once) leaves you with a surface answer. "Why faster?" gets you "because users complain," and that sounds like a complete answer. It is not. The first why describes the symptom. The fifth why names the cause. If you stop early, you optimize the symptom and leave the cause untouched. Follow the chain all the way down.

Third, sounding like you are challenging authority backfires. If you walk in and say "this task is pointless, the real problem is different," you sound like you are arguing. Instead, frame the question as your attempt to do the work correctly. You are not questioning whether the task matters; you are asking for direction so your effort lands. "I want to make sure I optimize the right layer, so I traced the slowness to the aggregation step. Is that what users are hitting?" That is a teammate asking for clarity, not a junior picking a fight.

The tone matters because your lead is your ally, not your opponent. A lead who hears a thoughtful question will usually help you refine the target. A lead who hears a challenge will defend the original instruction, and the conversation turns into a contest you cannot win.

Your next step: on your next task, before writing any code, write down the answer to "What is this for?" and send it to your lead for confirmation. If they say yes, you are working on the right target. If not, you have saved yourself days. The habit takes three minutes, and it is the difference between work that ships and work that gets thrown away. If you want to practice the skill before your first job, use the same trace on your take-home assignment and link to the five-whys method for reference. If you want to practice the skill before your first job, use the same trace on your take-home assignment.

ShareWhatsAppLinkedInX

Picked from the tags and topic of this post.

A table with one highlighted row, symbolizing the deep SQL knowledge required for senior roles.
career growth11 min read

SQL Interview Questions for 5 Years Experience

Interviewers for 5+ years of experience score depth, not syntax: window functions, index design, reading EXPLAIN and thinking in sets. The 30 questions below are grouped into six topics, each showing how to structure an answer that proves your experience.

Arnab Biswas