← Questions

Implement team-style business logic with OOP, then roll out an API change

0
MicrosoftCodingLast asked Apr 2026

A coding interview question asked in Microsoft's technical phone screen, last asked Apr 2026. It tests object-oriented design, api design and release process.

A practical backend round in two parts. First, the interviewer describes a piece of business logic like what the team builds and asks you to implement it in an existing backend service with clean object-oriented design. Second, you must change a public API that clients already use, and explain how you would release that change safely.

Part 1: the business logic

Identify the core domain objects and their responsibilities, separate orchestration (loading data, calling services, saving) from the business rules, and make the result testable and easy to extend. If the interviewer does not give a domain, use this one: an order service applies discounts (percentage off, buy-two-get-one, a loyalty tier) to a cart, and new discount types arrive every quarter.

Unless you agree on a different interface with the interviewer, assume:

  • Cart(items: list[LineItem], customer: Customer)
  • DiscountRule.apply(cart: Cart) -> list[Adjustment] — one class per rule type.
  • PricingService.price(cart: Cart) -> Receipt — loads the active rules, applies them in a defined order, returns totals and the adjustments that explain them.

Part 2: releasing an API change

You need to change an existing public endpoint, for example to return the list of adjustments and rename total to total_amount. Walk through the release: compatibility, versioning, testing, rollout, monitoring and talking to clients.

Clarifying questions

  • Which parts of the logic change most often?
  • Can rules interact (stacking, exclusivity), and who decides the order?
  • Who calls the public API: our own apps, partners, unknown third parties?
  • How long must the old behaviour be supported?

What a strong answer covers

  • A small domain model where each rule is a class behind one interface (strategy pattern), with the rule order and conflict policy explicit rather than buried in if chains.
  • Pure business logic with no I/O, so it is unit-testable; orchestration in a service that is tested with fakes.
  • Extension by adding a class and registering it, not by editing the core.
  • Additive changes first: add total_amount and adjustments alongside total, never repurpose a field; a new version only for breaking changes.
  • Contract tests against recorded client requests, a feature flag, a canary and staged rollout, dashboards on error rates and field usage, and a rollback plan.
  • Communication: a changelog, deprecation headers, a sunset date, and reaching the remaining callers of the old field.

Follow-ups

  • A new rule must see the result of the others ("cap total discount at 30%"). How does your design accommodate it?
  • Some clients ignore deprecation notices. How do you find them and what do you do on the sunset date?
  • How do you test that the new version gives the same totals as the old one for real traffic?

Where it's asked

What it tests

object-oriented design · api design · release process

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding