Scrivio Interview library
LeadershipPrincipal6 min read · updated 12 November 2026

Over twenty years your company has used Java serialization, XML, SOAP, JSON and now Protobuf. What principles should guide the next data format decisions so migrations cost less?

The principles are to keep data formats independent of any language's class structure, to choose formats with explicit schemas and documented evolution rules, and to separate the wire format from domain models with mapping layers so either can change alone. We standardise a small set of formats and their tooling instead of letting each team choose, and we plan for long retention, because archived data outlives the code that wrote it. Migrations get cheaper when formats are boundaries we designed, not side effects of our classes.

Background to this question

Twenty years of formats, Java serialization, XML, SOAP, JSON and now Protobuf, is a normal history for a large company. Each move was reasonable at the time, and each left behind data, services and integrations that had to be migrated or kept alive. The useful question for a senior engineer is not which format is best, but why each migration was so expensive and how to make the next one cheaper. In this answer, we will look at what made the past migrations costly, turn that into five principles, show what the mapping layer looks like in code, and describe how to apply the principles to the next decision.

1What Made Past Migrations Expensive

Looking back, the cost rarely came from the new format itself. It came from how deeply the old format was tangled into everything else. With Java serialization, the format was the class: domain classes were the wire format, so changing either meant changing both, and non-Java consumers were impossible. With SOAP, generated classes from WSDL files leaked into business logic, so replacing SOAP meant touching code far from the edge. With early JSON, there was often no schema at all; the contract lived in the code of whoever produced it, and migrating meant reverse-engineering what consumers relied on.

There was also a breadth problem. Each team picked its own library and conventions, so a company-wide move meant dozens of different migrations. And old data, in archives, caches and queues, stayed in the old format long after the code that wrote it was gone.

Why each past migration hurt
Format eraWhat it was tied toLesson
Java serializationJava class layout and versionsformats must not mirror classes
XML and SOAPgenerated classes inside business codekeep generated types at the edge
Early JSONno schema; contract only in codewrite the schema and evolution rules
Per-team choicesmany libraries and conventionsstandardise a small set
All of themarchives in formats nobody readsplan for retention from day one

2Principle 1: Keep Formats Independent of Class Structures

A data format should describe the data, not the in-memory objects of one language. That means no class names, no language-specific types and no layout that changes when we refactor. The test is simple: could a team using another language read and write this format from its documentation alone? If not, the format is really an implementation detail of one codebase that happens to travel over the network.

3Principle 2: Explicit Schemas With Written Evolution Rules

Every format we adopt must have an explicit schema, Protobuf files, Avro schemas, JSON Schema or similar, kept in version control and ideally in a registry. Alongside it, the evolution rules are written down and checked by tools: which changes are compatible, such as adding optional fields, and which are forbidden, such as reusing a field number or changing a type. Explicit schemas make the contract visible, so a future migration starts from a document instead of an investigation, and automated checks stop accidental breaks from piling up.

4Principle 3: Separate the Wire Format From Domain Models

The most valuable principle is a mapping layer at every boundary. Generated classes for the wire format live at the edge of the service; the domain model is ordinary code that knows nothing about Protobuf, JSON or SOAP. A small mapper converts between the two.

Java
// Edge: generated from order.proto, never used outside the adapter package
OrderPlacedProto proto = OrderPlacedProto.parseFrom(bytes);
// Mapper: the only class that knows both worlds
final class OrderMapper {
static Order toDomain(OrderPlacedProto p) {
return new Order(new OrderId(p.getOrderId()),
Money.ofMinor(p.getAmountMinor(), p.getCurrency()),
Instant.ofEpochSecond(p.getPlacedAt().getSeconds()));
}
}
// Domain: no format types anywhere
record Order(OrderId id, Money total, Instant placedAt) {}
Step throughA service with a mapping layer
  1. Wire formatProtobuf, JSON or whatever comes next
  2. Adapters and generated typesparse and write the format; nothing else uses them
  3. Mappersthe only code that knows both sides
  4. Domain model and business logicplain types; unchanged by format migrations

4 layers, from the top down. Step through them one at a time.

Notice what this buys. If the company moves from Protobuf to the next format in ten years, only the edge and the mapper change; the business logic and its tests stay as they are. And when the domain model is refactored, the wire format does not move, so consumers are not affected. The mapping code costs a little every day, and it repays that cost many times at the next migration.

5Principle 4: Standardise a Small Set of Formats and Tools

Instead of letting each team choose, the company standardises a small set, for example JSON with JSON Schema for public and browser-facing APIs, Protobuf for internal service calls and events, and Parquet or Avro for analytics and archives. For each one, a platform team provides the libraries, code generation, registry integration, linting and documentation. Teams can propose an addition through a lightweight review, but the default answer is one of the standard formats.

Standardising reduces the number of future migrations, because a change of direction becomes one coordinated programme with shared tools instead of fifty independent projects. It also makes skills portable between teams.

6Principle 5: Plan for Long Data Retention

Code is replaced every few years; data is often kept for seven, ten or more. Every format decision therefore includes a retention question: in which format will this data be stored long term, and how will someone read it after the producing service is gone? We archive in self-describing formats such as Avro or Parquet with schemas stored alongside the data, never in language-native serialization, and we regularly test that old archives can still be read. When a format is retired for new traffic, we decide explicitly whether old data is converted or kept with a supported reader.

Step throughChecklist for the next format decision
  1. Readable from documentation alone, any language?
    YescontinueNoreject: tied to one language
  2. Explicit schema and checked evolution rules?
    YescontinueNoadd them or reject
  3. Fits a mapping layer at the edge?
    YescontinueNoredesign the integration
  4. One of the standard formats?
    Yesuse shared toolingNopropose an addition with reasons
  5. Retention plan for stored data?
    YesadoptNowrite the plan first

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

7Follow-up questions

Is it worth adding mapping layers to services that already use generated classes everywhere?

Not as a big-bang rewrite. We add them when a service is touched for other reasons and always in new code, starting with the services that expose public contracts or are likely to change format soon. Over a few years, most boundaries get a clean edge at little extra cost.

How do we stop the standard set from going stale?

We review it every year or two against real needs, such as performance, new languages and ecosystem health, and we treat adding or retiring a format as a planned change with a migration path. Standardising does not mean freezing; it means changing together.

Would choosing the best possible format now avoid the next migration?

No format is permanent, and Protobuf will not be the last. The goal is not to pick the final format but to make the next migration a change at the edges, which is what independence from classes, explicit schemas and mapping layers achieve.

8Conclusion

In this answer, we traced the cost of past migrations to formats tangled with class structures, generated types spread through business code, missing schemas, per-team choices and forgotten archives. We turned that into principles: formats independent of language classes, explicit schemas with checked evolution rules, mapping layers that separate the wire format from domain models, a small standard set of formats with shared tooling, and a retention plan for every stored dataset, so the next migration changes only the edges.

What to say in the interviewAbout 90 seconds aloud

Open with

Looking back over Java serialization, XML, SOAP, JSON and Protobuf, the expensive part of each migration was never the new format; it was how deeply the old one was tangled into our code and data.

Then, if they want more

So my principles are about keeping formats at the edges. First, formats must be independent of any language's classes: no class names, no language types, and readable by another team from the documentation alone. Java serialization failed that completely.

Second, every format has an explicit schema in version control or a registry, with written evolution rules that tools check, like only adding optional fields and never reusing a field number. Then the contract is visible, and a future migration starts from a document instead of reverse engineering. Third, and most important, separate the wire format from the domain model.

Generated classes stay in an adapter package, a mapper converts to plain domain types, and business logic never sees Protobuf or JSON types. Then a future format change touches only adapters and mappers.

Fourth, standardise a small set, for example JSON for public APIs, Protobuf for internal calls and events, Parquet or Avro for analytics and archives, with shared tooling owned by a platform team, so a change of direction is one programme instead of fifty.

Fifth, plan for retention, because data outlives code: archive in self-describing formats with schemas stored alongside, and test that old archives remain readable.

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.
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 "Over twenty years your company has used Java serialization, XML, SOAP, JSON and now...": https://scrivio-interview-library.netlify.app/java/serialization/745f6c6b73/