views:

50

answers:

1

Hi,

I often need, depending on cases, of several DTOs for a same resource.

Take the example of photo Albums. Depending of what i want to display, i'll need different data into my DTOs (creation thru a form, list, details, etc.).

I will have an albumFormDTO to create an album, an albumDTO collection for a list of albums, and an albumDetailDTO for a detailed album.

For each, i need a specific assembler. It seems really heavy of doing it that way.

Does it seem stupid ?

Thanks, Cya Benjamin.

+1  A: 

Nope, doesn't sound stupid.

The alternative to what you suggested is creating a "super-dto" which is used for multiple purposes. and on which only some fields are used for each purpose.

This quickly becomes ugly and unmaintainable, as the dto grows large and it becomes unclear which fields are necessary for which purpose. It is hard to refactor and difficult to understand.

Daniel Alexiuc