InterviewStack.io LogoInterviewStack.io

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.

HardTechnical
37 practiced

Implement a strategy for gracefully handling missing or extra fields in JSON requests to a model-prediction API. Include code showing validation, defaulting, and the distinction between a warning and an error, and show how you would return a helpful client error response while keeping detailed server-side logs for debugging.

MediumTechnical
37 practiced

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.

MediumTechnical
32 practiced

Edge cases like NaNs, infinities, and zeros in a denominator often break analytical code. For a function that accepts a file path to a CSV and returns a pandas DataFrame, list the checklist of checks and transformations you would include at the start of a preprocessing pipeline to handle these numeric and categorical edge cases robustly, and explain when you would impute, clip, or drop a value and how you would record that decision for reproducibility. Then describe the pytest unit tests you would write to validate an imputation function against edge cases such as an all-NaN column, mixed dtypes, and a DataFrame with no missing values, making sure the original DataFrame is not mutated in place.

HardTechnical
31 practiced

A function has cyclomatic complexity over 20 and is hard to test or safely change. Propose a concrete plan to bring the complexity down while the team keeps shipping features around it, including how you'd verify you haven't changed behavior.

HardSystem Design
38 practiced

Design a code-review process for a large, distributed engineering organization (100+ engineers) that keeps quality high without becoming a bottleneck. Cover reviewer selection/ownership, SLAs, automation, and how you'd know if the process itself needed fixing.

Unlock Full Question Bank

Get access to all 16 Clean Code, Refactoring, and Maintainability interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.