Getting It Working First vs Writing Clean Code From the Start in Timed Mocks
Once you know your approach, a quieter decision shapes the rest of the round. You can get it working first—short variable names, everything in one function, tidy later if there is time—or you can write clean code from the start, with clear names, small helpers, and readable structure as you go.
Candidates argue about this a lot, and both sides have a point. Interviewers often say they care about readable code. They also need to see a solution that works before the time is up. The habit you practice at home usually decides which one you sacrifice under pressure.
This is a workflow comparison, not a scoring rubric. Companies weigh code quality differently, and some rounds are explicitly about maintainability. What stays the same is that you have one clock, and every minute spent polishing is a minute not spent solving or testing.
At a glance
| Category | Working first, tidy later | Clean from the start |
|---|---|---|
| Time to a working solution | Usually faster | Slightly slower |
| Readability during the round | Lower until cleanup | High throughout |
| Ease of debugging mid-round | Harder with cryptic names | Easier |
| Risk | Cleanup never happens | Polishing before it works |
| Best for | Hard problems, tight clocks | Medium problems, quality-focused rounds |
| What it trains | Speed to correctness | Readable code under pressure |
What working-first looks like
A typical flow:
- Plan the approach and say its complexity.
- Code quickly with short names and minimal structure.
- Dry-run a normal case and an edge case.
- Once it works, rename unclear variables and pull out a helper if one is obvious.
- Mention anything you would clean up with more time.
Honest strengths. You reach a correct solution sooner, which matters most on hard problems and multi-part rounds. You do not get stuck deciding what to call things before you know what they do. And saying "here is what I would refactor" at the end still shows the interviewer that you know what good code looks like.
Honest limits. In practice, the cleanup step is the one that gets cut when time runs short, so the interviewer remembers the messy version. Cryptic names make your own bugs harder to find mid-round, and harder for the interviewer to follow while you narrate. Some interviewers also read messy code as a signal of how you work day to day.
When working-first wins: the problem is hard and correctness is in doubt; the round has several parts; you have a strong habit of finishing with a cleanup pass; or the interviewer has said speed matters more than style.
What clean-from-the-start looks like
The other habit builds readability in as you go.
- Plan the approach and name the main pieces out loud, for example "a helper that checks whether a cell is valid."
- Use descriptive names from the first line:
left,right,seen,window_sumrather thani,j,s,t. - Split out a small helper when a block has one clear job.
- Keep the main function short enough to read on one screen.
- Dry-run and fix with the same structure.
Honest strengths. The interviewer can follow along easily, which makes your narration land and makes hints easier to give. Bugs are easier to spot when names say what values mean. It reflects how you would write code on the job, which some interviewers weigh heavily. And there is no cleanup step to run out of time for.
Honest tradeoffs. It can slow you down at the start, especially when you are not yet sure of the approach. Some candidates over-engineer—classes, extra helpers, early abstractions—on a problem that needed twenty lines. And naming things well while nervous is a skill of its own; if you have not practiced it, it can turn into hesitation.
When clean-from-the-start wins: the problem is medium difficulty and you are confident in the approach; the round is described as practical or quality-focused; or you know interviewers at that company care about readability.
Practicing the balance in timed mocks
The useful middle ground is "clean enough as you go": good names always, structure only where it is cheap. Timed mocks are where you find your own version of it.
- Pick one unseen problem and set a timer to your real round length.
- Use descriptive names from the first line. This costs almost nothing once it is a habit.
- Do not add helpers or structure until the main logic works, unless one block is obviously separate.
- Reserve the last three minutes: dry-run first, then one quick cleanup pass.
- Afterward, write one line: would a stranger understand this code without your narration?
Optional companion: Luna Interview is a Chrome extension framed as a practice / calm side panel—not a substitute for knowing the material, and never an "undetectable" live cheat. Keep it beside the editor during the mock while you own the design, the code, and the cleanup.
Decision table for candidate situations
| Your situation | Prefer working first | Prefer clean from the start |
|---|---|---|
| Hard problem, unsure of approach | Strong fit | Good names only |
| Medium problem, confident | Light | Strong fit |
| You often run out of time | Fit, with a short cleanup pass | Names only, skip extra structure |
| Practical or pairing-style round | Light | Strong fit |
| You debug slowly in your own code | Light | Strong fit |
| Multi-part problem | Strong fit for early parts | Fit for the final part |
| Day before the interview | One timed mock with the three-minute reserve | Same |
A fair practical method (combine both in one week)
Timed mocks (three a week): One unseen problem each, with descriptive names from line one and the three-minute reserve at the end. Track whether you finished with working code, and whether you got to the cleanup pass.
Naming drill (one short session): Take three of your old solutions and rename every variable so the code reads without comments. Notice which names you reach for again and again; those become your defaults under pressure.
Speed check (one short session): Solve one problem as fast as you can with no concern for style, then compare the time to your normal mock. If the gap is small, clean-as-you-go is costing you very little.
Common mistakes / when NOT to use each
Skip working-first when you know you never get to the cleanup, when your own short names are confusing you mid-round, or when the interviewer has signaled that readability matters.
Skip clean-from-the-start when it turns into designing classes for a twenty-line problem, when you are stuck choosing names instead of solving, or when correctness is still in doubt.
Skip timed-mock theater when you pause the clock to refactor, pick problems you have already solved, or code in silence. Also skip any practice-tool framing that promises stealth help in a real employer interview—that is the wrong goal and the wrong integrity bar.
Soft close
If your bottleneck is finishing with code you are proud of before the clock runs out, Luna Interview is a Chrome side panel built for that practice loop, not for cheating or replacing study. Soft trial path: https://lunainterview.xyz/
Use good names always. Add structure when it is cheap. Practice until working and readable stop feeling like a trade.
Rehearse with an AI interview copilot, then browse commonly reported interview questions.