Should I bind directly to objects returned from the web service?

Do I have to bind directly to objects returned from the web service, or do I have client-side objects that I bind to my gridcontrols? For example, if I have a service that returns a Car object, if I have a client-side car object that I populate with values ​​from the Webservice Car object? What is considered best practice? In C #, do I need to mark my classes as serializable or do something special for them?

+3
source share
5 answers

This is a good question that follows the sames lines as the two questions I asked myself:

.

:

  • - . , .
  • , raw xml ( ).

, , , xml. , xml . (- ) DLL , -. , .

( Car):

  • - (CarFactory) BuyCar(string make, string model) - factory, .
  • Mechanic, Car , -.
  • Garage . - CarFactory, , Mechanic , factory, .
  • , CarFactory.BuyCar("Audi", "R8"), Mechanic.Inspect(myAudi), , Car CarFactory.Car Car, ?

, , :

  • Car DLL. / XML .
  • - CarFactory, DLL, -, XML.
  • Garage, Mechanic, Car DLL - CarFactory. BuyCar, , Car, . Mechanic Car's , ( DLL?):)
  • , , , , DLL, - .

: Facade , XML.

, , , , , , .

+2

, -. , , , . , , .

/ ? , .

, , -, .

, , , , , , , , .

0

, , - , -, , , - . - .

0

-, . - , , .

, , - .asmx , WCF ? , , WCF .

, - . , , , .

0

- .
, - , , ( ), - -.
Rob Cooper, xml - XML, .
Visual Studio 2005 (, 2008 ), -, : - Visual Studio 2005

That way you can tell VS to use your own classes instead of generating a proxy class.

Well, when I think about it, this is almost the same solution proposed by Rob Cooper, with a slight twist, that you will not write the Facade layer yourself but will use VS as this layer.

0
source

Source: https://habr.com/ru/post/1697276/


All Articles