Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
316 views
in Technique[技术] by (71.8m points)

.net - Alternatives for Translation Layer in SOA: WCF

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

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

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...