Search code examples
winformswcfuser-interfacedata-bindingdatacontract

Extending WCF DataContract just to use it in GUI layer?


Is this valid? or does it smell? What I'd want to do is:

  • Have a datacontract object that holds a friendly object tree that can be saved by the service layer without the GUI not having to worry about it.
  • At the GUI level I make heavy use of databinding and also have some GUI specific logic (like cloning, flagging as deleted, basic validations, INotifyPropertyChanged etc).

I'd like to extend this DataContract class so I just have to add BindingLists, or my specific GUI logic and then send this object without the need of translating it to the WCF service layer.

Maybe composition is a better approach than extending? any ideas?


Solution

  • I wouldn't extend the DataContract class. I would create a Facade that added the extra functionality that I needed and could also handle communicating back down through the DataContract transparently.