InterviewStack.io LogoInterviewStack.io

Maintainability and Legacy Code Questions

Covers strategies and principles for evolving codebases safely and keeping them easy to understand and change over time. Topics include design principles such as Single Responsibility, Open Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion, removing duplication, establishing appropriate abstraction boundaries, separation of concerns, identifying and remediating code smells, incremental refactoring approaches, regression risk mitigation via tests and feature toggles, backward compatibility and migration strategies, and prioritizing technical debt reduction. Interviewers assess the candidate ability to plan pragmatic refactors, minimize risk during change, and improve long term health of a codebase.

HardTechnical
0 practiced
Design a consumer-driven contract testing strategy for a large organization where teams use multiple languages. Explain contract storage, provider verification workflows, CI/CD integration, contract versioning, and strategies to handle flaky or network-dependent contracts.
HardTechnical
0 practiced
A hot-path Java method in a high-throughput service allocates many short-lived objects causing GC pressure. Refactor or propose optimizations for the following code to reduce allocations and explain how you'd measure the improvement.
java
public String formatUser(User u) {
    StringBuilder sb = new StringBuilder();
    sb.append("Name:").append(u.getName()).append(";");
    sb.append("Age:").append(u.getAge()).append(";");
    sb.append("City:").append(u.getCity()).append(";");
    return sb.toString();
}
Discuss trade-offs between micro-optimizations and maintainability.
HardTechnical
0 practiced
Discuss the trade-offs between introducing additional abstraction layers (for testability/maintainability) versus the cognitive and runtime overhead they add. As a Solutions Architect, what quantitative and qualitative factors do you consider when choosing the right abstraction level for a system?
HardSystem Design
0 practiced
Design an observability and tracing plan to detect regressions introduced during refactors in a microservice architecture. Define key business and technical metrics, distributed tracing strategy, sampling, tagging (e.g., deploy IDs, toggles), dashboards, alert thresholds, and runbooks to map an outage back to a refactor change.
EasyTechnical
0 practiced
Refactor the following Python function to remove duplication, improve readability, and make it easier to unit test. Preserve behavior and performance. Provide the refactored code and one representative unit test.
python
class Order:
    def __init__(self, id, price, shipping_cost, promo=False):
        self.id = id
        self.price = price
        self.shipping_cost = shipping_cost
        self.promo = promo

def process_orders(orders):
    result = []
    for o in orders:
        if o.promo:
            price = o.price * 0.9
            shipping = 0
        else:
            price = o.price
            shipping = o.shipping_cost
        result.append({'id': o.id, 'total': price + shipping})
    return result
Language: Python.

Unlock Full Question Bank

Get access to hundreds of Maintainability and Legacy Code interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.