Coding Required

Data Transfer Object

2025-11-241 min read

Here's the thing about frontend code that drives me crazy.

Three API calls. Three different shapes of data. Smashed together inside a component. Conditionals everywhere. Null checks. Format conversions. A mess.

At YoPrint, we don't do that.

We created a DTO layer. One function takes raw API responses and transforms them into exactly what the component needs to display. Nothing more. Nothing less.

UserProfileDTO = transform(userApi, ordersApi, settingsApi)

Now we have two things we can test independently.

The transform logic. Pure function. No UI. Does transform(mockApiData) return the right display format? Unit test it. Done.

The component. Does it render the DTO correctly? Pass in a hardcoded DTO. Visual test it. Done.

Our components are dumb. Beautifully dumb. They just render what we give them.

Our tests are simple. Isolated. Fast.

When the API changes? We fix the transform. Component doesn't care.

When the design changes? We fix the component. Transform doesn't care.

We didn't invent this. We just use it.


The ugliest bugs hide where data meets UI. DTOs are the firewall.

Anbin Muniandy
CEO & Principal Engineer, YoPrint