Search code examples
wcfbusiness-objectsdatacontractarchitecture

Should a business object know about it's corresponding contract object


I have some business objects and some very similar corresponding data contract objects for getting data across the wire via WCF service.

What mechanism should I use to get populated data contract objects from business objects?

In an ideal world, should the data contract layer know about the business layer?

or

Should the business layer know about the data contract layer?

or

Should there be another mapping layer that has static methods like GetDataContractFromBusinessObject?


Solution

  • I am a big fan of the "mapping layer with static methods" technique you mention. Then, your business objects and data contracts don't depend on each other either way.