Quick revision
The short answer
I would define a baseline style that most Java developers can read: plain Java with lambdas, streams, records and sealed types used moderately. Teams that own code long-term may use functional libraries such as Vavr inside their modules if they document it, but library-specific types must not appear in shared APIs. I would base these decisions on defect rates, review time and onboarding time rather than preferences, and revisit them as the language adds features like pattern matching and sealed types that cover much of what those libraries offered.
What to remember
In this answer, we saw that style differences become costly when people and code move between teams. The guidance is a readable baseline of modern Java, with records, sealed types, pattern matching, lambdas and streams used moderately; functional libraries such as Vavr are allowed inside modules that a team owns long-term and documents, but never in shared APIs; decisions rest on defect rates, review and onboarding time rather than preference; and the baseline moves forward as language features become final.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would define a baseline style that most Java developers can read: plain Java with lambdas, streams, records and sealed types used moderately. Teams that own code long-term may use functional libraries such as Vavr inside their modules if they document it, but library-specific types must not appear in shared APIs. I would base these decisions on defect rates, review time and onboarding time rather than preferences, and revisit them as the language adds features like pattern matching and sealed types that cover much of what those libraries offered.
Why this question is asked
Style differences between teams usually stay harmless until people and code move. A developer who joins a team using Vavr, monads and point-free style can need weeks before they review confidently, and a module handed from that team to another becomes a maintenance burden nobody wants. Interviewers ask this leadership question to see whether we can resolve a divisive technical debate with a policy that respects both sides and rests on evidence. In this answer, we will look at what the gap looks like in code, define a baseline, decide where functional libraries are allowed, protect shared APIs, choose how to measure, and plan how the guidance evolves.
1What the Gap Looks Like
Here is the same rule, "load the customer, check the credit limit, then place the order", written in the two styles found in such an organisation.
Both are correct, and Team A's version has a real advantage: failures are values in the return type rather than hidden exceptions. But a typical Java hire reads Team B's version at a glance and Team A's only after learning Try, Either, mapLeft and the conventions around them. That difference is the cost the organisation pays every time someone moves teams.
2A Baseline Most Java Developers Can Read
The baseline is the style every team writes in shared code and every developer is expected to read and review. I would define it as modern standard Java: records for data, sealed interfaces for closed sets of outcomes, switch with pattern matching for handling them, lambdas and streams for collection transformations, and Optional for lookup results. It is functional where the language itself is functional, and imperative where a loop or an if is clearer.
Notice that modern Java already offers much of what drew Team A to Vavr. A sealed interface with Success and Failure records gives typed outcomes without any library, and pattern matching handles them readably.
3Where Functional Libraries Are Allowed
Banning Vavr outright would throw away a team's skill and possibly good code. Instead I would allow functional libraries inside a module when the owning team will keep the code long-term, the choice is recorded in a short architecture decision record with the reasons, and the module has a README explaining the main idioms for newcomers. These conditions make the cost visible and keep it with the team that chose it.
The decision becomes harder when ownership changes. If a module is about to move to another team, the receiving team should be able to decide whether to keep the library or convert it, with time planned for that work, rather than inheriting a style they cannot maintain.
- Is the code exposed in a shared API?YesBaseline types only at the APINoContinue
- Will the team own it long-term?YesContinueNoUse the baseline style
- Is the choice documented (ADR, README)?YesAllowed inside the moduleNoDocument first
3 steps in order. Play them, or step through them one at a time.
Library types stay inside the module; the boundary always speaks baseline Java.
4Keep Library Types Out of Shared APIs
The firmest rule concerns shared APIs. If a shared library returns io.vavr.control.Either or takes an io.vavr.collection.List, every consumer must depend on Vavr, learn it, and upgrade in step with the provider when Vavr changes its major version. One team's style choice becomes everyone's dependency.
So shared APIs use baseline types only: JDK collections, Optional, records and sealed result types. A team that uses Vavr internally converts at its module boundary, which is usually a few lines, for example turning an Either into a sealed PlaceResult or a Vavr List into a java.util.List with toJavaList().
5Decide With Evidence, Not Preference
Style debates are endless when argued from taste. I would move the discussion to things we can observe: defect rates in modules written in each style, review time for pull requests, how long new team members take to make their first independent change, and how often code handed between teams gets rewritten. None of these is perfect, but together they show whether a style costs the organisation more than it saves.
If the data shows that the Vavr-heavy modules have fewer defects and normal onboarding times, that is a reason to teach the style more widely. If it shows that onboarding takes twice as long and handovers fail, that justifies narrowing it. Either way, the teams see that the decision followed evidence, which makes it much easier to accept.
6Revisit as the Language Grows
The guidance should be reviewed at least yearly. Java's own features keep closing the gap that functional libraries filled: records arrived in Java 16, sealed types in Java 17, and pattern matching for switch and record patterns in Java 21, which together give typed outcomes and exhaustive handling without any library. As each feature becomes final, I would move the baseline toward it and give library-heavy teams a natural path to converge.
Preview features stay out of the baseline until they are final, because they can change between releases and require special compiler flags. The goal over time is not to win the argument for either camp, but to let the standard language absorb the good ideas so that the argument fades.
7Follow-up questions
Isn't this unfair to the team that invested in functional skills?
Their skill is not wasted; the ideas they value, explicit outcomes and immutability, are part of the baseline in standard Java form. They keep the freedom to use their library internally. The only firm limit is on shared APIs, where their choice would otherwise be imposed on everyone else.
How would you train the imperative team on the baseline's functional parts?
With short internal sessions built on our own code, such as converting a real exception-driven method into a sealed result, and with pairing during reviews. The baseline only uses standard Java features, so ordinary books and documentation apply.
What if a team wants to adopt Kotlin instead?
That is a bigger decision with build, hiring and tooling impact, so it goes through the same evidence-based process, at an organisation level. The shared API rule still applies: Kotlin modules expose APIs that Java callers can use comfortably.
8Conclusion
In this answer, we saw that style differences become costly when people and code move between teams. The guidance is a readable baseline of modern Java, with records, sealed types, pattern matching, lambdas and streams used moderately; functional libraries such as Vavr are allowed inside modules that a team owns long-term and documents, but never in shared APIs; decisions rest on defect rates, review and onboarding time rather than preference; and the baseline moves forward as language features become final.
Open with
I wouldn't pick a winner between the two camps. I'd set a baseline that every team writes in shared code and that a typical Java hire can read: modern standard Java, with records for data, sealed interfaces and pattern matching for outcomes, lambdas and streams used moderately, and Optional for lookups.
Then, if they want more
That already gives much of what draws people to Vavr, like typed success and failure results, without a library. Inside a module, a team that owns the code long-term may still use Vavr or similar, if they record the decision and document the idioms for newcomers. If ownership moves, the receiving team decides whether to keep it, with time planned.
The firm rule is shared APIs: no Either, Try or Vavr collections in signatures, because then every consumer depends on the library and its upgrade cycle. Teams convert at their boundary, which is a few lines.
To keep it from being a taste debate, I'd look at defect rates, review time, onboarding time and how often handed-over code gets rewritten, and adjust the policy based on that.
And I'd revisit it yearly, because Java keeps absorbing these ideas, sealed types and pattern matching for example, so over time the baseline itself covers what people wanted from the libraries.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Java 16, Java 17, Java 21
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- java.util.stream, package documentation, java.util.function, package documentation
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 "Some teams in your organisation write heavily functional Java with Vavr, monads and...": https://scrivio-interview-library.netlify.app/java/functional-design/bd4e8a2a68/