Clean Code, Refactoring, and Maintainability Questions
Writing code that other people can read, change, and keep alive over time: naming, function and module decomposition, avoiding duplication, readability, disciplined use of language idioms and design patterns, and recognizing code smells, extending into working effectively in large, aging, or unfamiliar codebases through safe incremental change, refactoring under test coverage, and managing technical debt. Covers both authoring professional-grade code beyond mere correctness and improving code you cannot rewrite without breaking it. Spans the coding-round quality signal and the seniority signal of leaving a codebase healthier than you found it.
You are given a function that has grown to do five unrelated things (for example: parsing input, validating it, running business rules, persisting results, and sending notifications) in a single 400+ line block. Walk through how you would decompose it into small, well-named, independently testable pieces, and what you would check before and after to confirm you did not change behavior.
You inherit a large, legacy codebase with virtually no automated tests and frequent production bugs, and you're on a deadline. Describe your pragmatic, incremental plan to make it safer to change: where you start, how you add tests before refactoring, and how you keep shipping while doing it.
Notebooks are great for exploration but not always for production. What concrete criteria would tell you it's time to convert a notebook into a script or package, and what's your incremental plan to extract stable functions without breaking whatever already depends on the notebook?
What does 'intent-revealing naming' mean, and why does it matter more as a codebase and team grow? Give two examples of a poor name and a clearer alternative, and explain what made the better name easier to work with.
Describe a real situation where you accepted a more complex, less readable implementation for a genuine performance gain. How did you document the trade-off in the code itself so a future reader (including you) understands why the 'ugly' version is there on purpose?
Unlock Full Question Bank
Get access to all 9 Clean Code, Refactoring, and Maintainability interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.