2
votes

I used to have my DTOs declared in the Domain Layer. But that was before I later understood that the Application Layer should pass in primitives to the Domain Layer to instantiate Domain Model Entities, not DTOs. Now that I know this, I have no use for DTOs being declared in the Domain Layer.

Since my Application Layer has Application Services which convert data to and from DTOs to get data to various layers, I'm thinking that the DTO's might as well be declared in the Application Layer.

So, is the Application Layer typically where the DTO's should be declared?

Thanks in advance.

Update: 02/25/2016 I will be defining the interfaces for my Application Services in the Application Services Layer based on the following quote from the .NET Application Architecture Guide, 2nd Edition: "Within the service layer, you define and implement the service interface and the data contracts"..

1

1 Answers

2
votes

As DTOs are used for transferring data from your application to e.g. client applications, they should be declared in the layer that handles the service calls to your application (the outermost layer). Whether you call it application layer or something else (at my company we call it 'service layer') is up to you.