0

I ran in to a fellow programmer and was discussing a method i needed to write, and in an OOP aspect, the a Dictionary<T,U> is perfect. But, i voiced concerns about the XML size and structure that it is translated to during serialization. So my buddy, in a very direct manner, said i should be using a wrapper object that contains the key and value, and return a list of them instead of a dictionary. Are there some .NET objects that just shouldnt be serialized over SOAP, and simpler, custom objects should be created instead?

Jacob
  • 77,566
  • 24
  • 149
  • 228
Mike_G
  • 16,237
  • 14
  • 70
  • 101
  • possible duplicate? http://stackoverflow.com/questions/495647/serialize-class-containing-dictionary-member – aqwert Mar 31 '11 at 21:55

1 Answers1

1

The main things you need to worry about are:

  1. Don't send unnecessary information.
  2. Dont make too many service calls.

Try to balance size of data against number of calls (optimally reduce both of these to a minimum).

As a rule most people avoid passing data structures which contain complicated logic, such as Dictionary.

Serializing a List is fine (it will be serialized as an IEnumerable).

Don't feel that your data objects have to look like your Entity objects - think of packets of information rather than Entities. When you receive the data at the client end you should convert it into Entity objects.

Greg Sansom
  • 20,442
  • 6
  • 58
  • 76