Scrivio Interview library
LeadershipAdvanced7 min read · updated 12 November 2026

In code reviews across many teams you see strategy interfaces with a single implementation, visitors for three classes, and factories that create one type. How do you set guidance on design pattern use?

Patterns solve specific problems, and an abstraction without a second real use case adds cost without benefit. The guidance we would set is to start with the simplest code and introduce a pattern when a real second variant or real change pressure appears, to prefer language features such as lambdas, records and sealed types over class-heavy pattern structures, and to ask in review what change an abstraction makes easier and whether that change is expected. We back this with good and bad examples from our own codebase in the engineering guide.

Why this question is asked

Overused patterns are a quiet tax on every team. A strategy interface with one implementation means two files to read instead of one, a factory that creates one type means an extra indirection in every stack trace, and a visitor for three classes means boilerplate that nobody wants to touch. Each looks harmless in a single review, but across many teams they add up to slower onboarding and slower changes. Interviewers ask senior engineers this because the answer shows whether they can set standards that change behaviour across teams without becoming a bottleneck or a style police. In this answer, we will look at why these structures appear, what they really cost, the principle we would set, how to turn it into review questions, and how to roll the guidance out.

1Why Pattern-Heavy Code Appears

Most of these abstractions are written in good faith. Developers learn patterns as signs of good design, and interviews reward naming them, so using one feels like doing the job well. Some are written for a future that seemed likely: maybe we will support a second payment provider, so we add a PaymentStrategy now. Others are copied from an older service where the pattern did have several implementations. And some come from frameworks or habits of older Java versions, when a one-method interface plus an anonymous class was the only way to pass behaviour.

Understanding the cause matters for the guidance. If people are doing it to look professional, the fix is to change what we praise in reviews. If they are doing it for an imagined future, the fix is to show that adding the abstraction later is cheap. Telling people they are wrong without addressing why they did it rarely changes anything.

2What Speculative Abstractions Cost

Every abstraction has a cost: one more type to read, one more place to change, and an indirection that hides what the code really does. A pattern earns that cost when it makes an expected change cheaper. A strategy interface with three implementations lets us add a fourth without touching callers; that is a real benefit. A strategy interface with one implementation buys nothing until a second appears, and the guess about what the second will need is often wrong, so the interface has to change anyway.

With IDE refactoring, extracting an interface from a class takes seconds when the second case arrives. So waiting costs very little, while abstracting early costs reading time every day until then, and sometimes forever.

Common over-applied patterns and simpler alternatives
What we seeWhy it costsSimpler first step
Strategy interface, one implementationTwo types, guessed contractOne class; extract the interface at the second case
Factory that creates one typeIndirection, no choice madeA constructor or a static of() method
Visitor for three classesDouble dispatch boilerplateSealed interface with a switch over record patterns
Builder for a two-field objectMore code than the objectA record with a canonical constructor
Observer for one listenerHidden control flowA direct method call

3The Principle: Start Simple, Abstract on Real Pressure

The guidance we would publish fits in one sentence: write the simplest code that solves today's problem, and introduce a pattern when a second real variant exists or when the same kind of change has hit the code more than once. That second variant must be real, a ticket or a requirement, not a possibility someone imagines.

The second part of the principle is to prefer language features to class structures where they suffice. Modern Java removes the need for much of the pattern boilerplate. A strategy can be a lambda passed to a method or stored in an enum. Data carriers can be records instead of hand-written value classes with builders. A small closed hierarchy can be a sealed interface, and a switch with record patterns gives the same exhaustive handling a visitor provides, with the compiler checking that every case is covered.

Java
// Instead of a Visitor interface, accept() methods and three visitor classes:
sealed interface Shape permits Circle, Square, Rect {}
record Circle(double r) implements Shape {}
record Square(double side) implements Shape {}
record Rect(double w, double h) implements Shape {}
double area(Shape s) {
return switch (s) { // compile error if a case is missing
case Circle c -> Math.PI * c.r() * c.r();
case Square sq -> sq.side() * sq.side();
case Rect(double w, double h) -> w * h;
};
}
area(new Rect(2, 3)); // 6.0

The visitor still makes sense when the hierarchy is open, defined in a library we cannot change, or when traversal is complex, as in compilers. For three records in our own module, the sealed switch is shorter and just as safe.

4Turning It Into Review Questions

Guidance only works if it shows up where code is written, which is code review. Instead of a list of banned patterns, we give reviewers a few questions to ask about any new abstraction. What change does this make easier? Is that change expected, with a ticket or a history of similar changes? What would the code look like without it? If the author has a clear answer, for example that three other payment providers are already planned this quarter, the pattern stays. If the answer is maybe someday, we suggest the simpler version and note that extracting the interface later is a one-minute refactoring.

The tone matters. These are questions, not rejections, and we apply them in both directions: a 400-line method with six branches that keep changing is also a design smell, and a reviewer should suggest a strategy there. The goal is fitting the structure to the actual pressure, not minimising patterns.

Step throughReview questions for a new abstraction
  1. What change does it make easier?Ask the author to name it
  2. Is that change real or expected?A ticket, a roadmap item, repeated history
    YesKeep the patternNoNext question
  3. Would a language feature do?Lambda, record, sealed type, switch
    YesSuggest the featureNoSuggest the plain class
  4. Record the exampleGood or bad, for the engineering guide

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

5Rolling Out the Guidance Across Teams

We would write a short section in the engineering guide with the principle, the review questions, and, most importantly, examples taken from our own codebase: a before and after of a single-implementation strategy turned into a class, a visitor replaced by a sealed switch, and also a case where a pattern clearly paid off, such as our payment providers. Real examples from code people know persuade far better than textbook ones.

Then we spread it through the people who review most. A short session with the senior engineers of each team, a few paired reviews, and a channel where people can post a borderline case and get a quick opinion. We avoid mass rewrites of existing code, which carry risk without user value; instead, we simplify over-engineered code when someone is changing it anyway. After a quarter we look at a sample of merged changes to see whether the questions are being asked, and adjust the guide.

6Follow-up questions

Are you not just discouraging good design?

No. Good design means the structure fits the forces acting on the code. A pattern applied where those forces exist is good design; the same pattern applied where they do not is cost. The guidance explicitly asks reviewers to suggest patterns when real change pressure shows, such as a conditional that keeps growing.

What about abstractions needed for testing, like an interface so we can mock a class?

Modern mocking libraries can mock concrete classes, so an interface purely for tests is rarely needed. Where a seam is useful, for example a Clock or an external API client, the second implementation is the test fake, which is a real use case, so the interface is justified.

How do you handle senior engineers who disagree?

We discuss concrete cases rather than principles, because disagreement about abstractions usually disappears when we look at a specific diff and the expected changes. Where reasonable people still differ, the guide states a default and leaves room for judgment, and the author of the code makes the call with a short reason in the review.

7Conclusion

In this answer, we saw why single-implementation strategies, small visitors and one-type factories appear, and why they cost reading and changing time without a real second use case. The guidance is to start simple, introduce a pattern when real variation or change pressure appears, prefer lambdas, records and sealed types over pattern class structures, ask in review what change an abstraction makes easier, and anchor all of it in examples from our own codebase.

What to say in the interviewAbout 100 seconds aloud

Open with

I would start by saying patterns are tools for specific problems, and an abstraction that has no second real use case is pure cost: more types to read, more indirection, and usually a guessed contract that changes anyway.

Then, if they want more

Extracting an interface later is a one-minute refactoring, so waiting is cheap. The guidance I would set has three parts. First, write the simplest thing and introduce a pattern when there is a real second variant or the same kind of change keeps hitting the code.

Second, prefer modern language features: a strategy can be a lambda or an enum field, data can be a record, and a small closed hierarchy can be a sealed interface with a pattern-matching switch, which gives the exhaustiveness of a visitor without the boilerplate.

Third, in reviews, ask questions instead of banning patterns: what change does this make easier, is that change expected, and what would it look like without it. I would apply that in both directions, so a method with six growing branches gets a suggestion to use a strategy.

To make it stick, I would write it up in the engineering guide with before and after examples from our own code, including a case where a pattern paid off, and spread it through the senior reviewers of each team rather than through a mandate.

I would not run a rewrite campaign; we simplify existing code when we touch it, and I would check a sample of reviews after a quarter to see if the questions are being asked.

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 "In code reviews across many teams you see strategy interfaces with a single...": https://scrivio-interview-library.netlify.app/java/behavioral-patterns/03aca7fe21/