Quick revision
The short answer
I would standardise on annotated controllers as the default, because most Spring developers know them and documentation tools, validation and exception handling support them out of the box, while allowing functional endpoints where explicit routing or composition brings a clear benefit, such as small edge services or routes built from configuration. Consistency matters more than which style wins, because shared error handling, security and documentation patterns depend on it. So teams that take the functional exception follow documented conventions, and before we commit to the standard we check that our tooling for OpenAPI generation and testing handles both styles.
What to remember
In this answer, we chose annotated controllers as the organisation's default because they are familiar to most Spring developers and best supported by documentation, validation and error-handling tools, and allowed functional endpoints where explicit routing and composition bring a clear benefit. We argued that consistency matters more than the choice, since shared error handling, security and documentation depend on it, wrote conventions for the functional exception, and checked OpenAPI and testing tooling before committing.
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 standardise on annotated controllers as the default, because most Spring developers know them and documentation tools, validation and exception handling support them out of the box, while allowing functional endpoints where explicit routing or composition brings a clear benefit, such as small edge services or routes built from configuration. Consistency matters more than which style wins, because shared error handling, security and documentation patterns depend on it. So teams that take the functional exception follow documented conventions, and before we commit to the standard we check that our tooling for OpenAPI generation and testing handles both styles.
Why this question is asked
Choosing between annotated controllers and functional endpoints looks like a matter of taste, and in a single service it mostly is. Across an organisation with dozens of services, it becomes a question of shared libraries, onboarding, documentation pipelines and how quickly an engineer can find their way around a service they have never seen. Interviewers ask this leadership question to see how we weigh developer familiarity, technical fit and tooling against each other. In this answer, we will recap the two styles, weigh the factors one by one, explain why consistency outweighs the choice, write the exception rule, and check the tooling.
1A Quick Recap of the Two Styles
Annotated controllers declare routes with annotations such as @GetMapping on methods of a @RestController, and Spring resolves arguments like @PathVariable and @RequestBody automatically. Functional endpoints declare routes as code, a RouterFunction that maps request predicates to handler functions taking a ServerRequest and returning a ServerResponse. Both exist in Spring MVC and Spring WebFlux, so this decision is independent of the choice of web stack.
2Weighing the Factors
Familiarity comes first because it affects every engineer every day. Nearly every Spring developer and nearly every tutorial uses annotated controllers, so a new hire can read and change them on day one. Tooling comes second: springdoc generates OpenAPI from annotated controllers automatically, @Valid validates bodies, @ControllerAdvice maps exceptions, and IDEs show endpoints in their tool windows.
Functional endpoints have real strengths. Routing is explicit and lives in one place, so we can read a service's entire API surface in one file. Routes are values, so they compose: we can nest them under a version prefix, apply a filter to a group, or build them conditionally from configuration. Handlers are plain methods with no reflection, easy to unit test, and the style avoids some annotation-processing overhead, which matters little for most services. These strengths fit small services, gateways, and composition-heavy designs best.
| Factor | Annotated controllers | Functional endpoints |
|---|---|---|
| Familiarity of developers | very high | lower; must be learned |
| OpenAPI generation | automatic | needs @RouterOperation or builder |
| Validation and error mapping | @Valid, @ControllerAdvice | wired by hand |
| Seeing all routes in one place | spread across classes | one router definition |
| Composition and dynamic routes | limited | natural: nest, filter, conditions |
| Unit testing handlers | via WebTestClient or MockMvc | plain methods, or bindToRouterFunction |
3Why Consistency Matters More Than the Choice
Most of the organisation's investment around web endpoints is shared: a library that maps exceptions to a standard ProblemDetail format, a security configuration, a documentation pipeline that publishes every service's OpenAPI to a portal, contract tests, and the templates new services start from. Each of those has to be built and maintained for every style in use. With one style, a shared error library is one @ControllerAdvice; with two, it is an advice plus a filter or a WebExceptionHandler, kept in step.
So even if functional endpoints were slightly better for some team, a fleet where every service follows one pattern is easier to secure, document and operate than one where each team chose differently. The value of the standard is the shared patterns it makes possible.
4The Exception Rule and Its Conventions
The standard allows functional endpoints where they bring a clear benefit, and says what clear means: a gateway or edge service whose routes are built from configuration, a service whose routes need to be composed and filtered in groups, or a very small service where the whole API fits in one readable router. A team choosing the functional style follows documented conventions: one router bean per resource, handlers in separate classes, the organisation's shared WebExceptionHandler for errors, an explicit validation helper, @RouterOperation documentation for every route, and the same contract tests as annotated services. The reason for each convention is the same: a functional service should look, fail and document itself exactly like an annotated one from the outside, so the shared platform pieces keep working. Mixing both styles inside one service needs a stated reason in the design note.
- Start from the defaultannotated controllers
- Routes built from config or composed in groups?YesFunctional style allowedNoKeep the default
- Does it follow the functional conventions?YesApprove and record in the design noteNoAdjust before approval
- Run the shared contract testssame errors, security, docs as other services
4 steps in order. Play them, or step through them one at a time.
5Checking the Tooling Before Committing
Before publishing the standard, we test the tooling against both styles in our actual pipeline: does our springdoc version produce complete OpenAPI for router functions with @RouterOperation, does the API portal show them correctly, do our contract-testing tools and security scanners discover functional routes, and do the observability conventions, such as route names in metrics and traces, work the same way. If any of those fail for functional endpoints, the exception rule must include the extra work, or the gap becomes a reason to stay with the default. The standard has an owner and is reviewed when Spring or the tooling changes significantly.
6Follow-up questions
Would you ever choose functional endpoints as the default?
Possibly, for an organisation whose services are mostly small edge or gateway services built by a team experienced with the style, and whose documentation tooling handles router functions well. The criteria are the same; they would simply point the other way.
What about existing services in the other style?
We do not rewrite them for the standard. A working service in the other style stays, and teams adopt the standard style when they build new services or substantially rework old ones. The shared error, security and documentation patterns are applied to both in the meantime.
Does the choice affect performance?
Not noticeably for typical services. Functional endpoints avoid some reflection and annotation processing at startup and per request, but the cost is tiny compared with I/O, serialization and business logic. Performance is rarely a good reason to choose either style.
7Conclusion
In this answer, we chose annotated controllers as the organisation's default because they are familiar to most Spring developers and best supported by documentation, validation and error-handling tools, and allowed functional endpoints where explicit routing and composition bring a clear benefit. We argued that consistency matters more than the choice, since shared error handling, security and documentation depend on it, wrote conventions for the functional exception, and checked OpenAPI and testing tooling before committing.
Open with
I'd standardise on annotated controllers as the default and allow functional endpoints by exception. The main factors are familiarity and tooling. Almost every Spring developer knows annotated controllers, so new people are productive immediately, and the ecosystem supports them out of the box: springdoc generates OpenAPI automatically, @Valid validates bodies, @ControllerAdvice maps exceptions, and IDEs list the endpoints.
Then, if they want more
Functional endpoints have real strengths: all routes are explicit in one place, they compose, you can nest and filter groups of routes or build them from configuration, and handlers are plain methods that are easy to test. Those strengths fit gateways, small edge services and composition-heavy designs. But the bigger point is that consistency matters more than which style wins.
The organisation's shared pieces, the ProblemDetail error library, security configuration, the OpenAPI publishing pipeline, contract tests and service templates, all have to be built per style. With one style they're simple; with two they drift.
So the standard would say: annotated by default; functional allowed when routes are built from config, composed in groups, or the service is very small, and then the team follows documented conventions, a shared WebExceptionHandler, an explicit validation helper, @RouterOperation on every route, and the same contract tests. Mixing styles in one service needs a stated reason.
Before publishing it, I'd check that our springdoc version, API portal, scanners and metrics handle router functions properly, and I'd give the standard an owner who reviews it when Spring or the tooling changes.
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 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
- Spring Framework reference, Spring WebFlux, Project Reactor reference guide
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 "Should your organisation standardise on annotated controllers or functional endpoints...": https://scrivio-interview-library.netlify.app/spring-boot/webflux/2cec8f9394/