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.
What role do linters, formatters, and static analysis play in keeping a codebase clean? Name a couple of representative tools and explain the difference between what runs locally (pre-commit) versus in CI, and why that split exists.
You want to introduce mandatory linting and a consistent style guide across a codebase (or many repos) that has never had one, without drowning teams in noisy diffs or blocking urgent work. Describe your rollout plan: scope, sequencing, and how you handle legacy code that fails the new rules on day one.
Plan a migration of a large Android app from an MVC-ish pattern (Activities/Fragments holding logic) to MVVM using Jetpack components. How do you keep the app releasable at every step of the migration?
Unlock Full Question Bank
Get access to all 19 Clean Code, Refactoring, and Maintainability interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.