Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 475751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:25:12+00:00 2026-05-13T00:25:12+00:00

After spending a couple months studying DDD methodology, I’ve now began to apply these

  • 0

After spending a couple months studying DDD methodology, I’ve now began to apply these concepts into actual products at my company. In fact, I’ve been tasked with creating a suitable and maintainable architecture for future development.

We have decided to make use of the following technologies: EF4 (really v2), Unity

The amount of information I’ve obtained has been most enlightening, however, I’m left with several questions in best practice:

Question #1: DTOs – Best Practices

I have my domain objects (POCO classes). There are several ways to implement these classes.

  1. Traditional Approach: Create POCO classes which contain public getters/setters, Validation, & appropriate business logic. Also create DTOs and use mapping techniques to manage them. (Automapper)
  2. Traditional – DTO: Create POCO classes like stated above, however, use your POCOs as transfer objects. It’s my understanding that business objects should never leave the domain though.
  3. Hybrid: I stumbled upon an interesting blog post in which the author creates his POCO objects and DTOs. Inside of his domain object he creates an instance of the DTO. This allows for easier maintainability as you’re not duplicating your properties like in #1. Like so:
public abstract class POCOBase<T> : ValidationBase, IPOCO where T : DTOBase, new()
{

 public T Data { get; set; }

 public POCOBase()
 {
     Data = new T();
 }

 public POCOBase(T dto)
 {
     Data = dto;
 }
  }

  public class SomePOCO : POCOBase { }

  public class SomeDTO : DTOBase

  {

 public String Name { get; set; }

 public String Description { get; set; }

 public Boolean IsEnabled { get; set; }
}


// EXAMPLES
// POCOBase<SomeDTO> somePOCO = new SomePOCO();
// somePOCO.Data.Name = "blablabla";
// somePOCO.Validate();
// return somePOCO.Data;

Question #2: What objects should be returned by the UI/Service Layer?

This is the whole point of the DTO. A very simple, light-weight object containing just the bare attributes. It’s also not containing any Validation results in it. If I am serializing my DTOs back to the client, it should be assumed the client needs any Validation results like an InvalidRules collection.

For instance, say I’m working with Amazon’s API. I would like to add a book to my personal store. If I try to add a book without sending its ISBN, the service would probably return some kind of response group which contains Validation result errors.

Am I missing something? I was under the impression (at least from DDD “purists”) that DTOs should contain no business logic. It seems to me DTOs do not provide enough information as transfer objects. Either that or I need a new type of Response object which encapsulates the DTO and Validation results.

Question #3: How much IoC is too much?

It seems apparent to me that I should follow the golden rule:

“Identify the parts of the application
that vary, and separate from those
that stay the same.”

To me this makes sense in terms of applying IoC. To reduce dependencies, my Presentation, Business Logic, and Data Access layers all communicate via an IoC container. My Application layer contains common interfaces and abstractions. It seems overkill to use IoC much more than this. I love the fact that I can create mock test Repositories – and by simply changing Unity’s configuration, I can make use of TDD.

I hope I’ve stated these questions clearly. Thanks for your help in advance!

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T00:25:12+00:00Added an answer on May 13, 2026 at 12:25 am

    I’ll try to address your questions one at a time.

    Answer 1

    DTOs are orthogonal to DDD because they serve a different purpose in a different place in an application’s architecture. That said, DTOs have no place in a Domain Model because they have no behavior and will thus lead to Anemic Domain Models.

    POCOs with Persistence Ignorance is the way to go. Jeremy Miller has a good article that explains this concept.

    Answer 2

    Layers that sit on top of the Domain Model will often need to return their own objects that are tailored for the purpose in question.

    For UIs, the MVVM pattern works particularly well. This article introduces MVVM for WPF, but the pattern also works like a charm in ASP.NET MVC.

    For web services, this is where the DTO pattern applies. WCF Data Contracts are DTOs, in case you were wondering 🙂

    This will require a lot of mapping going back and forth between the service interface and the Domain Model, but that’s the price you have to pay for Supple Design. You may find AutoMapper helpful in this regard.

    Answer 3

    The more IoC (really: DI) the better, but one thing about your question struck me: A DI Container should only wire up the object graph and then get out of the way. Objects should not rely on the DI Container.

    See this SO answer for more details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After just now spending too much time debugging why my jQuery animate() calls stopped
After becoming somewhat estranged open source, and spending some years developing web applications in
after spending hours of figuring out how to sign an app (at last i
I've just started looking at PHP Frameworks after spending loads of wasted time doing
After reading the Head First Design Patterns book and using a number of other
After the suggestion to use a library for my ajax needs I am going
After reading this question , I was reminded of when I was taught Java
After upgrading to the latest version of TortoiseSVN (1.5.2.13595), it's context menu is no
After being told by at least 10 people on SO that version control was
After lots of attempts and search I have never found a satisfactory way to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.