Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Services are not object-oriented. Suppose I have a OOAD based design. We can convert it into DTO (that does not have any behavior) using a Translation Layer. But this can cause be very big increase in amount of code. What are the alternative ideas for this in WCF (via C#)?

Please have your comment whether it is good idea to have such a transition between SOA and OOAD. Should we avoid OOAD altogether when we have SOA or use such mapping techniques?

Is it a good idea to create "Operation Specific DTO" rather than creating "DTO directly from domain after removing behavior" ? Is there any tool for the "Operation Specific DTO Approach"?

Does AutoMapper produce "Operation specific DTO" or "DTO from domain without behavior"?

Note: Operation specific DTO approach can be referred in the answer in “Do not use Abstract Base class in Design; but in Modeling/Analysis”

Extract from Service Layer Guidelines

Design transformation objects that translate between business entities and data contracts.

REFERENCES:

  1. How to restrict web service data contract properties based on user role
  2. SOA Question: Exposing Entities
  3. What is the best way of using DTOs in a SOA application?
  4. WCF Message & Data Contract, DTO, domain model, and shared assemblies
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
312 views
Welcome To Ask or Share your Answers For Others

1 Answer

As with everything else in software development (and particularly architecture), there's not a single, correct answer to those questions. It depends upon the architectural goals and constraints.

WCF works with DTOs. While it's possible to drop down to a more primitive layer and work directly with messages, for all practical concerns, DTOs are a fundamental part of working with WCF. Since WCF seems to be one of the architectural constraints in this case, there's really no practical way to avoid DTOs.

The question then becomes: should there be a mapping layer or not?

That question is fairly easy to answer if we can answer another question: mapping from what?

If you already have an existing system, you'd need to translate between the existing system and the WCF boundary. In such a case, a translation layer is required.

If you are building a completely new system, perhaps it'll be easier not to translate.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...