Engineer Atlas
OverviewLearnFollow a RequestBuild /checkoutScale to 1MBreak ItWhy Slow?FinderRoadmap
OverviewLearnFollow a RequestBuild /checkoutScale to 1MBreak ItWhy Slow?FinderRoadmapPracticeInterviewCheat SheetCompareCloud Map
Backend Engineering/Learn/Serialization & DTOs

Serialization & DTOs

Turning runtime objects into bytes and back, what that costs in CPU and allocation, and why the database row is the wrong thing to hand a client.

Serialization: Objects to Bytes

A response is bytes on a socket. The encoder decides which of your runtime's types survive the trip and which quietly change shape.

Q · What actually happens between a handler returning an object and a client reading a field?
Deserialization: Bytes to Objects

Parsing untrusted bytes produces data of a known shape, not data you may trust — and the gap between those two is where mass assignment lives.

Q · What has to happen to untrusted bytes before they are allowed to become a domain object?
What Serialization Costs

CPU proportional to the nodes you visit and garbage proportional to the bytes you produce — paid on every request, amortised by nothing.

Q · Why does an endpoint whose only query is fast still burn CPU and allocate heavily?
Three Models, Not One

The database row, the domain object and the API response answer to different owners and change for different reasons. Collapsing them is a decision, not a default.

Q · Why should the shape a client receives be different from the shape the database stores?
Schema Leakage

Returning the row is publishing the schema. It is a contract you did not write, cannot see, and will be held to.

Q · What exactly do you promise a client when you hand it a database row as JSON?
Engineer Atlas
GitHub·LinkedIn