开发者

Working with objects received from web services

When working with web services, is it a good practice to have some sort of converter that converts the object from the web service to your domain object even if they have almost the exact prope开发者_Python百科rties? If it is not a good practice, why not?


I generally do this conversion in my code primarily because I prefer to completely abstract the web service and any evidence of it, essentially not wanting to use the objects exposed by the service in my domain. Tools such as AutoMapper are useful in this practice, though I often just do it manually. My preference is just to abstract the external web service behind an internal service or repository interface and have as little code actually depend on the external service as possible (even if the service is also one I wrote and is being used in the same enterprise environment).

Just think of it from the perspective of future re-factoring. If anything in the service ever changes, how much of the consuming application's code will be affected?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜