Scrivio Interview library
ScenarioFoundations7 min read · updated 12 November 2026

As a senior developer, you find that every change to the pricing module of your Spring Boot service takes days because of duplicated logic and missing tests. How would you make the case to your team lead to fix it?

We make the case with evidence rather than frustration: how long recent pricing changes took, which bugs the duplicated logic caused, and how often the module is touched. Then we propose a small, specific plan, characterisation tests first and then removing one duplicated rule at a time, with an estimate of the effort and the time it should save, done incrementally alongside feature work in that area, and we write it up in a short note or ADR so the team lead can decide quickly.

Why this question is asked

Every developer has worked in code that slows everything down, and most have complained about it. Complaints rarely change anything, because a team lead hearing 'the pricing code is a mess' has no way to weigh it against the features on the roadmap. Interviewers ask this to see whether a senior developer can turn a technical problem into a decision someone can make. In this answer, we will gather evidence, look at the code problem itself, propose a safe plan with characterisation tests, estimate cost and benefit, suggest doing it incrementally and write the short note that makes the case.

1Collecting Evidence

We start by looking at the last few months of work in the pricing module. The ticket tracker and the git history tell us a lot: how long each pricing change took from start to release, how many bugs were reported in pricing, and how often the module was changed compared with the rest of the service.

Properties
# How often each file changed in the last 6 months (top of the list)
git log --since="6 months ago" --name-only --pretty=format: -- src/main/java | sort | uniq -c | sort -rn | head -5
# 41 src/main/java/com/shop/pricing/PriceCalculator.java
# 37 src/main/java/com/shop/pricing/CartPricing.java
# 35 src/main/java/com/shop/checkout/CheckoutPricing.java
# 12 src/main/java/com/shop/orders/OrderService.java
# 9 src/main/java/com/shop/catalog/ProductService.java

Notice that three pricing files dominate the list. Combined with the tickets, the picture in our example is: eight pricing changes in six months, taking 4.5 days on average against about 1.5 days for similar changes elsewhere, and five production bugs where a discount rule was updated in one place but not in the others. That is evidence a team lead can use, and it took an hour to gather.

2Understanding the Code Problem

The duplication typically looks like this: the same discount rule written in the cart, the checkout and the order confirmation, each slightly different because each was copied and then patched separately.

Java
// CartPricing
if (customer.isLoyal() && total.compareTo(new BigDecimal("100")) > 0) discount = total.multiply(new BigDecimal("0.10"));
// CheckoutPricing
if (customer.isLoyal() && total.compareTo(new BigDecimal("100")) >= 0) discount = total.multiply(new BigDecimal("0.10"));
// PriceCalculator (used by order confirmation)
if (customer.getTier() == Tier.GOLD && total.doubleValue() > 100) discount = total.multiply(new BigDecimal("0.1"));
// For a loyal customer with a total of exactly 100.00:
// cart: no discount checkout: 10.00 discount confirmation: depends on the tier

So a customer sees one price in the cart and another at checkout, and every change to the rule must be made three times, carefully, with no tests to say whether the three still agree. That explains both the slowness and the bugs. It also shows why we cannot just merge the three copies: we do not know which behaviour is correct, and some customers may depend on the current results.

3Proposing a Small, Safe Plan

The plan has two steps. First, characterisation tests: tests that record what the code does today, whatever that is, so that we notice any change in behaviour while refactoring. We run a set of realistic carts through each pricing path and lock in the results.

Java
@ParameterizedTest
@CsvSource({
"LOYAL, 99.99, 0.00",
"LOYAL, 100.00, 0.00", // cart behaviour today: no discount at exactly 100
"LOYAL, 150.00, 15.00",
"NEW, 150.00, 0.00"})
void cartDiscountAsToday(CustomerType type, BigDecimal total, BigDecimal expected) {
assertThat(cartPricing.discount(customer(type), total)).isEqualByComparingTo(expected);
}
Step throughRefactoring the pricing module safely
  1. Characterisation testsrecord today's results per path
  2. Pick one duplicated rulee.g. loyalty discount
  3. Do the copies disagree?
    YesAsk product which is correctNoMerge directly
  4. Extract one shared rule classall paths call it
  5. Update tests on purposeonly for the agreed difference
  6. Release, then next rulesmall PRs, one at a time

6 steps in order. Play them, or step through them one at a time.

Second, we remove the duplication one rule at a time. We pick the loyalty discount, ask the product owner which behaviour at exactly 100 is correct, put that single rule into one class such as LoyaltyDiscount, and make the three paths call it. The characterisation tests then change in exactly one place, on purpose, with the product owner's answer as the reason. Then we move to the next rule. Each step is a small pull request that can be reviewed and released on its own.

4Estimating Effort and Expected Savings

A team lead needs a cost and a benefit. For the cost, we estimate the characterisation tests at about three days and each extracted rule at about one day; with six duplicated rules, roughly nine to ten days in total, spread over several weeks. For the benefit, if pricing changes drop from 4.5 days to about 2, and we expect around 16 such changes a year, that saves roughly 40 days a year, plus fewer pricing bugs reaching customers. The payback period is about a quarter.

These numbers are estimates and we say so. The point is to show the order of magnitude and the reasoning, so the team lead can challenge specific assumptions rather than having to trust our feelings about the code.

5Doing It Incrementally With Feature Work

Asking for two weeks with no features is the hardest request to approve. Asking to do the work alongside features is much easier. Pricing changes arrive regularly, so each time a feature touches a rule, we extract that rule as part of the feature, with its characterisation tests first. The roadmap barely moves, and the code improves exactly where change is happening. The characterisation test suite can be a small first ticket on its own, since every later step depends on it.

6Writing It Down

Finally, we put the case into a short note or an ADR, an architecture decision record, which is a short document recording a decision, its context and its consequences. One page is enough: the problem with the evidence, the proposed plan, the estimate, how it fits with feature work and the risks. Writing it down helps the team lead, who can read it in five minutes, share it with their own manager and refer back to it later. It also helps us, because writing forces us to check that the argument really holds.

Outline of the one-page note
SectionContent
Problempricing changes take 4.5 days vs 1.5; 5 bugs from inconsistent rules
Cause6 discount and tax rules duplicated in 3 classes, no tests
Proposalcharacterisation tests, then extract one rule at a time
Costabout 3 days for tests plus 1 day per rule, over several weeks
Benefitabout 40 days a year saved, fewer pricing bugs
Risk and mitigationbehaviour changes caught by tests; product confirms each rule

7Follow-up questions

What if the team lead still says no?

We ask what would change their mind, perhaps a smaller first step or a specific deadline passing. Often the characterisation tests alone can be approved as part of the next pricing feature, and the measured benefit of that step makes the next conversation easier.

Why not rewrite the pricing module from scratch?

A rewrite has to rediscover every rule and edge case the old code handles, without tests to compare against, and delivers nothing until it is finished. Incremental refactoring behind characterisation tests delivers value with each step and keeps behaviour under control.

What exactly is a characterisation test?

It is a test that captures what existing code currently does, rather than what it should do. We run the code with many inputs, record the outputs as expected values, and use the tests as a safety net while changing the structure. If a test fails, we have changed behaviour and must decide whether that was intended.

8Conclusion

In this answer, we made the case for fixing a slow, duplicated pricing module. We collected evidence from git history and tickets, showed how the duplicated rules cause both delay and bugs, proposed characterisation tests followed by extracting one rule at a time, estimated the effort and the yearly savings, suggested doing it alongside feature work, and wrote it up in a one-page note so the team lead could decide quickly.

What to say in the interviewAbout 80 seconds aloud

Open with

I'd bring evidence rather than just say the code is bad. From the tickets and git history I'd show how long recent pricing changes took, say four and a half days against one and a half for similar changes elsewhere, how many bugs came from rules being updated in one copy but not the others, and that the pricing files are the most frequently changed in the service.

Then, if they want more

Then I'd propose a small, specific plan. First, characterisation tests that lock in today's behaviour for each pricing path, so refactoring can't silently change prices.

Then remove the duplication one rule at a time: pick the loyalty discount, ask the product owner which variant is correct where the copies disagree, extract it into one class, and make every path call it, as a small pull request.

I'd estimate the cost, roughly three days for the tests and a day per rule, against the benefit, maybe forty days a year saved plus fewer customer-facing bugs, and say clearly they're estimates. I'd suggest doing it incrementally, extracting a rule whenever a feature touches it, so the roadmap barely moves.

And I'd write it up as a one-page note or ADR so my lead can read it quickly and share it.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "As a senior developer, you find that every change to the pricing module of your Spring...": https://scrivio-interview-library.netlify.app/architecture/technical-leadership/7de0b020e0/