What type of return to use between layers

  • Thread starter Thread starter Sylvain Larin
  • Start date Start date
S

Sylvain Larin

My business object (BO) need to pass a table to the GUI. The BO and the
GUI will reside on the same computer and will not use .NET remoting or
web service for now, but will need to support .NET remoting and a web
interface in the future. What return type should I use?

1) DataSet
2) DataTable
3) XML

With the first 2 options, does .NET do the plumbing of transfering the
table in XML format between the layers or it simply pass the object?

With the XML option, do you define the return type as string? How do you
return the XML with the XSD?

TIA
 
Are these just different objects running in the same process? If so,
there is no need to do any "plumbing" to transfer to/from XML between
the layers (since the layers are really just logical).

If you want to send XML that is defined by an XSD, you probably want to
use a typed DataSet. The framework will handle the serialization to XML
and back.

You can also use your own custom collection types, with the appropriate
serialization attributes - no need for a DataSet.

I would definitely not return data as a String data type if it really
contains structured data.

But remember - you only need to serialize to XML if you are transferring
data out of process.

Joshua Flanagan
http://flimflan.com/blog
 
Thanks Joshua. The objects are running in the same process for now, but
they will be in a distributed architecture (.NET remoting) for the next
version.

There is also a chance that the BO may be accessed with web service
and/or a GUI other than .NET in the future. In that scenario, would
returning a DataSet still be wise?

Sylvain
 
Back
Top