DataSets V Custom Objects

M

Moe

Hi All,
I have read a lot of articles about datasets, strongly-typed datasets
and customer objects but am still at a loss on which is the best
solution.
We are building a 3-tier application that uses Webservices as our
middle-tier. The Webservices will hold the DataAccess layer
(communicates with the DataSource and returns the requested data).
These services will be used by Windows/Web forms.

Our problem is this

1. What is the best way to return data to pass data between tiers.
a)My first option was to use a dataset but the overhead is a killer
expecially in cases where only one record is required.

b) Option two is to write custom objects, but changes in schema means
a continous change in both the webservice and the client that receives
the data.
Anyway round this?
Are there any tools I can use to generate customer objects using
tables from the datasource and then tweak it?

Example :
A CRM solution with objects
Customer
CustomerNo
FirstName
LastName
Address

Orders
Order
ID
ProductID
Quantity

The customer object is pretty much single instance so a dataset is an
overkill I believe
For Orders will be a collection. So a dataset could do since it will
return multiple records.

I hope this explains my situation. Any help is welcome.

Thanks
Moe
 
W

W.G. Ryan eMVP

I'm not sure about the architecture of your application, but if you can use
..NET Remoting it may be(and in many instances is) a far better fit
perforamnce wise than WS. I don't think I ever met a web service I didn't
like, but I used WS exclusively for a long time and ignored remoting and I
really regret that.

I don't think one is better than the other across the board in regard to
custom objects or datasets but, using datasets there's a lot of built in
functionality that may end up coming in later. Yes, if you are just
changing one row at a time then you can probably implement it with a lot
lighter objects although there's a lot of wiggle room in this last
statement. Transaction volume is one of the big factors here because I've
used WS as the communications layer and done a tremendous amount of volume
with them, even passing in single records and wasn't killed by the overhead.
The data transfer is usually what gets to be a bear but again, it really
depends on the situation. You can use both approaches however, there's no
rule that says you have to use one or the other.

As far as products that take care of this for you -There are two products
that I firmly believe in and while they are both essentially object
relational mappers, they are a lot more than that. www.deklarit.com is the
first one and I'd recommend checking out the demo they have on the site. Of
all products I've personally used, I think their stuff is as good as
software gets. However there's a slight learning curve associated with it,
particularly if you're going to take advantage of some of the more advanced
features like its remoting functionality. Conversely, I will say that they
bend over backwards and then some to help you learn how to use their stuff
correctly and any orm tool (or super ORM tool+ in this case) has a learning
curve.

LLBLGenPro http://www.llblgen.com/defaultgeneric.aspx is the other one. I
haven't used it nearly as much because I had come across Deklarit first.
However, I have a few friends that use it and live and die by it. The guy
that wrote it, Frans Bouma is a real class act and probably one of the most
well versed people on the subject you'll come across and he frequents the
NG's quite a bit.

Stated simply, I know over 10 people that use each product respectively and
each group is pretty partisan about their given product. I have yet to meet
anyone that's used either product and not absolutely loved it. If nothing
else, I'd encourage you to take a look at them because I think you'll find
them pretty impressive.
 
S

Sahil Malik

Moe,

In a distributed architecture, I would recommend against using Datasets or
strongly typed datasets for the following reasons -

a) Bloat Bloat Bloat. Even if you use BinaryFormatter in a remoting
architecture to serialize your datasets, the dataset will still be
serialized using XmlFormatter internally, which is different entirely from
both SoapFormatter and BinaryFormatter. ADO.NET 2.0 has a
Dataset.RemotingFormat property, but still .. read the other reasons. (Not
to mention I haven't used RemotingFormat yet).
b) By sending a DS over a webservice, you loose portability with other
platforms (viz. Java? .. ewww LOL)
c) Serialization of datasets involving serializing SO MUCH that you will
never need.
d) Strongly typed datasets have a weird null handling behavior. Extremely
unpredictable (like it takes decisions for you at times, like .. oh I have a
zero here, I guess I'll put a null instead .. ) I don't exactly remember
what was the exact case, but there was an issue definitely.
e) There are better devised serialization mechanisms devised over the years,
but each of their own problems. Look up datasetsurrogate on MS knowledgebase
for example. I had written a custom remoting formatter once to compress all
data in a true binary form for low bandwidth connections - but that was
nothing but problems because no matter what I did, the code just got too
picky about things like calling AcceptChanges before sending the data over
the wire. I could not come up with an easy enough solution around the
problem; and dude, the extents to which I went to to make it work were
ridiculous in the first place.

I had once written a small tool which would take a strongly typed dataset
XSD, and convert it into a C# fairly simple business object with no logic
inside, just a simple representation. You could obviously then customize
that object on a case per case basis, but why bother :-/. I'd just put the
Serializable attribute on top and avoid delegates and stuff, but if I wanted
to, I could customize to my heart's content (read last line of my message).

If you are using Remoting, it is a bit easier to transfer objects over the
remoting layer. A technique I have used before is to implement the right
interfaces and the custom logic stays only on the client; and as long as the
right interfaces are represented on either side, everything works. I try and
keep the custom behavior on the objects by using this technique, so I am
fairly isolated on either side from the other.

In WebServices, you loose a little bit flexibility in the kind of object
that will transfer - atleast not painlessly, but you gain easier xml based
compatibility ; and strangely I have heard talks about a webservice not
performing too bad compared to a remoting architecture - though I find that
hard to believe, but people have results to prove. Anyway, I haven't tried
that myself and I feel that is a largely case per case basis argument. If
you donot need to worry about anything outside .NET and anything outside
your company, stick with remoting (but I am open to what others might
recommend). .. also an example of where a webservice could get anal compared
to remoting - if you have a business object representation that implements
an interface, you will have to modify the auto generated .cs proxy file ..
and that file is scary. LOL. Another problem with a webservice, try writing
up a small sample webservice that exposes your custom object with two
properties, one being readonly, and another being a standard object, and add
reference to a windows form - and you'll know what I mean.

I could keep ranting about this for hours, but bottom line - custom
objects - you'll be happier. Also, google for "ObjectSpaces" .. that's ultra
delayed, but people have come up with clones. Like William Ryan above
mentioned, I also like Deklarit.

Another big advantage of Custom objects - You can customize the
serialization behavior to your heart's content. That's a BIG DEAL when the
system finally rolls into prod. and you have a trifling performance problem.

Hope that helped :)

- Sahil Malik
You can reach me thru my blog at
http://www.dotnetjunkies.com/weblog/sahilmalik
 
M

Moe Baby

Thanks for your reply.

We were looking into remoting however after doing some reading it
appears remoting is not optimised for across server processes. IT seems
it was more for service-service or application-application interactions.

The architecture is such that both Web applications and windows
applications will be served via the same set of services. This was why
we went with the WS option.

From the info above about our architecture would you still say we should
look at remoting instead of WS?

If we do go with remoting will datasets still be okay for transporting
data b/w laters?

Thanks
Moe
 
S

Sahil Malik

We were looking into remoting however after doing some reading it
appears remoting is not optimised for across server processes. IT seems
it was more for service-service or application-application interactions.

Uhhmm .. can you post me a link to what you read? I find that not true, but
maybe I donot understand what you meant over there.
The architecture is such that both Web applications and windows
applications will be served via the same set of services. This was why
we went with the WS option.

Remoting and Web Apps work together, as do windows.
From the info above about our architecture would you still say we should
look at remoting instead of WS?

Yes (also read my other message).
If we do go with remoting will datasets still be okay for transporting
data b/w laters?

No (read my other message).

- Sahil Malik
You can reach me thru my blog at
http://www.dotnetjunkies.com/weblog/sahilmalik
 
W

W.G. Ryan eMVP

AFAIK, WS uses Remoting underneath the covers and you'll get better
performance out of remoting. As far as using the same services to serve
Winforms apps and Web apps - absolutely - I do it quite a bit these days.

What shortcoming were you referring to specifically? I'd definitely be
interested in seeing what it said
 
S

Sahil Malik

I wanna give a slight twist to "WS uses Remoting underneath the covers and
you'll get better performance out of remoting" .. Web Services is a special
flavor, or special case of remoting. More politically correct I guess ;)

- Sahil Malik
You can reach me thru my blog at
http://www.dotnetjunkies.com/weblog/sahilmalik
 
M

Moe Baby

Thanks William and Sahil for all the info..
As per the article about remoting and web services will post the link
when I dig it up.

Thanks a lot again!!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top