Software Engineer Interview Question

You inherit a service with no tests and you need to change its core logic. How do you approach it?

What the interviewer is probing, how to structure your answer, and a spoken example you can adapt.

Quick answer

Pin the current behavior before you change it. Write characterization tests at a stable boundary, feeding real inputs and asserting whatever the code does today, bugs included, so you have a net that detects change. Then refactor in small steps with those tests green, extracting the logic you need to touch into something testable. Only once the seam exists do you change behavior, and each change gets its own test.

Why interviewers ask this

Most engineering happens on code you did not write, and this reveals whether you charge in or build safety first. Interviewers listen for characterization tests, for testing at a stable boundary rather than unit testing implementation you are about to delete, and for separating refactoring from behavior change so that when something breaks you know immediately which of the two caused it.

How to structure your answer

  • Refuse to change untested logic without a net.
  • Write characterization tests at the API boundary first.
  • Separate refactoring from behavior change.
  • Use real production data to validate.

Example answer

Spoken example, first person

I do not change logic I cannot verify, so step one is a net. I write characterization tests at the highest stable boundary, usually the HTTP handler or a service entry point, and I assert what the code does right now, including things I suspect are bugs. The point is not correctness, it is detecting change. If I have production access I capture a few hundred real request and response pairs, because handcrafted inputs miss the weird ones and the weird ones are what break. Then I refactor in small steps with the tests green the whole way, pulling the logic I actually need to touch into a function I can call directly. Only then do I change behavior, and each change comes with a real test plus a decision about whether the old behavior was intentional. On a legacy pricing service I did exactly this and the captured traffic exposed two rounding paths that disagreed, which nobody knew about. That is the sort of thing you find with a net and destroy without one.

Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.

See how it works

Follow-up questions to expect

  • How do you handle a bug that customers now depend on?
  • Would you run the old and new paths in parallel?
  • How do you stop the refactor ballooning in scope?

Related software engineer questions

Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.

Predict my questions

Rehearse the hard questions before they are asked

Practise with a live copilot, then walk in ready. A $29 Session Pass gets you through the interview with no subscription and no lock-in.

Get GhostPilot