Scrivio Interview library
LeadershipAdvanced7 min read · updated 12 November 2026

Your organisation has a large shared 'commons' library used by 200 services that contains utilities, HTTP clients, security filters and domain models. It is now hard to change. How would you restructure shared code?

I would split the commons library into small, focused modules with clear owners, such as an observability starter, a security starter and client libraries, and remove the domain models entirely, because services should own their models and share contracts, not classes. Where possible I would prefer configuration and standards over shared code, publish a BOM so compatible versions are used together, and deprecate the old library in stages with migration guides and automated changes.

Why this question is asked

A commons library starts small and helpful: a few string utilities, a standard HTTP client. Over the years everything that more than one team needed goes into it, until 200 services depend on one jar that contains utilities, HTTP clients, security filters and domain models. Then every change risks breaking someone, releases slow down, and services cannot upgrade one part without taking all the others. Interviewers ask this to see whether a senior engineer understands why shared code becomes coupling, and how to unwind it without stopping 200 services. In this answer, we will see why the library became hard to change, split it by purpose and owner, take the domain models out, replace some code with standards, tie versions together with a BOM, and plan a staged retirement.

1Why the Commons Library Became Hard to Change

A library is hard to change when many consumers depend on many unrelated things in it. Our commons jar mixes four kinds of code with very different lives. Utilities rarely change. HTTP clients change when partner APIs change. Security filters change when policies or vulnerabilities change, and must be rolled out fast. Domain models, classes like Customer or Order, change whenever any team's business rules change.

Because they are in one jar with one version, a security fix forces every service to also take the latest domain model changes and client changes. A service that cannot accept a new Order class cannot get the security fix either. The coupling is not in the code; it is in the packaging and the version.

What is in commons today and where it should go
PartChanges whenNew home
String, date and collection helpersrarelySmall utils module, or the JDK and existing libraries
Logging, metrics, tracing setupplatform changesacme-observability starter
Security filters, token checkspolicy or CVEacme-security starter, fast patch releases
Partner HTTP clientspartner APIs changeOne client library per API, owned by its team
Customer and Order classesany business changeRemoved: services own models, share contracts

2Splitting by Purpose, With an Owner for Each Module

We split the library into modules that each have one purpose and one owning team. The observability starter, owned by the platform team, configures logging, metrics and tracing the company way. The security starter, owned by the security engineering team, provides filters and token validation, and can release patches within hours. Each partner client library is owned by the team that knows that partner API best.

Owners matter as much as the split. A module without an owner becomes the next commons library: everybody adds to it and nobody maintains it. With an owner, each module has someone who reviews changes, writes release notes and decides compatibility, and its version can move at its own pace.

3Taking the Domain Models Out

Shared domain classes feel efficient: every service uses the same Customer class. In practice they couple release cycles. When the billing team adds a field the shipping team does not need, the shipping team still has to upgrade, rebuild and sometimes change code. Worse, the shared class encourages services to rely on another service's internal view of a concept, which makes both harder to change.

Java
// Before: every service uses the shared class
import com.acme.commons.model.Customer; // 40 fields, changed by 9 teams
// After: billing owns its model; the contract is the API, published as OpenAPI
// billing-api.yaml -> generated client in the consuming service
public record BillingCustomer(String id, String name, String vatNumber) {} // only what billing needs

The rule is to share contracts, not classes. A contract is the description of an API or event, such as an OpenAPI document or an Avro or JSON schema in a schema registry. Each service generates or writes its own classes from the contract, with only the fields it needs. Contracts are versioned and evolve compatibly, for example by adding optional fields, so producers and consumers can upgrade independently.

4Preferring Configuration and Standards Over Code

Some of the shared code does not need to be code. A standard log format can be achieved with Spring Boot's structured logging configuration rather than a custom appender. Standard HTTP timeouts and retries can be documented defaults in configuration rather than a wrapper class. Many utilities duplicate what the JDK or well-known libraries now provide, such as java.time for dates or String methods added in recent Java versions.

Every piece of shared code is something a team must maintain and every service must upgrade. A written standard plus a small amount of configuration, checked in CI where possible, often achieves the same consistency without the coupling. So for each part of commons we ask first whether it can disappear, then whether it can become configuration, and only then which new module it belongs in.

5Publishing a BOM So Versions Fit Together

Splitting one library into several creates a new problem: which versions of the modules work together? A BOM, a bill of materials, solves it. It is a Maven pom, also usable from Gradle, that lists compatible versions of all our modules, plus the Spring Boot version they were tested with. Services import the BOM once and then declare modules without versions.

XML
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.acme</groupId>
<artifactId>acme-platform-bom</artifactId>
<version>2026.11.0</version> <!-- one version to upgrade -->
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.acme</groupId>
<artifactId>acme-security-spring-boot-starter</artifactId> <!-- version from the BOM -->
</dependency>
</dependencies>

Modules can still release independently, and a service can override one version for an urgent security fix. But the default is one BOM version that the platform team has tested as a set, which keeps 200 services from each inventing their own combination.

6Retiring the Old Library in Stages

We cannot delete commons on a Friday. We retire it in stages over several months, with help at each stage. First, the new modules are released and the old classes in commons are marked @Deprecated, pointing to their replacements. Then a migration guide shows each change with before and after code, and OpenRewrite recipes, automated code changes, rewrite imports and calls, opened as pull requests across repositories by a bot.

Step throughRetiring the commons library
  1. Release new modules and BOMobservability, security, clients
  2. Deprecate old classes in commonsJavadoc points to replacements
  3. Migration guide and OpenRewrite recipesbot opens PRs in all 200 services
  4. Freeze commonssecurity fixes only, no new features
  5. Still used by any service?
    YesyesNohelp those teams directly
  6. Remove commons from the BOMafter the announced date

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

Freezing commons is an important step. As long as new features can be added to it, teams have a reason to stay. Once only security fixes go in, and the replacements are better, migration becomes the obvious choice. We track remaining usage from dependency data, help the last teams directly and announce the final date well in advance.

7Follow-up questions

How do you decide what goes into a shared module at all?

Shared code should be behaviour that must be consistent inside every process and changes slowly, such as security checks or observability setup, and it should have a clear owner. Business logic and domain models should stay in the services. If something is shared only to save a few lines, copying it is often cheaper than coupling 200 services to it.

What about utilities many teams use, like a date helper?

First check whether the JDK or an established library already does it, since many old helpers predate java.time and newer String or collection methods. If a real gap remains, a small, stable utilities module with an owner is fine, as long as it has no dependencies on the rest of the platform and changes rarely.

How long should the retirement take?

Long enough for teams to plan it, typically two to four quarters for 200 services, but with a fixed end date. Automation keeps the effort per service small, and the freeze keeps the old library from growing in the meantime.

8Conclusion

In this answer, we restructured a commons library used by 200 services. We saw that it was hard to change because unrelated code shared one version, split it into focused modules with owners such as an observability starter, a security starter and client libraries, and removed domain models so services own their models and share contracts. We replaced code with configuration and standards where possible, tied module versions together with a BOM, and retired the old library in stages with deprecation, migration guides, OpenRewrite recipes and a freeze.

What to say in the interviewAbout 90 seconds aloud

Open with

The core problem is that one jar with one version couples very different kinds of code. Security filters need fast patches, partner clients change with partner APIs, and domain models change with every team's business rules, so a service cannot take a security fix without also taking unrelated changes.

Then, if they want more

I would split commons by purpose, and give each new module an owner: an observability starter owned by the platform team, a security starter owned by security engineering that can release patches quickly, and one client library per partner API owned by the team that knows it. Domain models I would remove entirely.

Services should own their own models and share contracts, like OpenAPI documents or event schemas, and generate their own classes with only the fields they need, so they can release independently.

For each part I would also ask whether it needs to be code at all: logging formats, timeouts and many utilities can be configuration, a written standard, or something the JDK already provides. Then I publish a BOM so services import one version that is tested as a set.

Finally, I retire commons in stages: release the replacements, deprecate the old classes, publish a migration guide and OpenRewrite recipes that a bot runs as pull requests, freeze commons to security fixes only, help the last teams directly, and remove it on an announced date.

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 "Your organisation has a large shared 'commons' library used by 200 services that...": https://scrivio-interview-library.netlify.app/architecture/platform-and-governance/c8db1a25de/