Geek Noise
Rants, rambles, news and notes by Peter Provost
27

More Software Architecture Stuff

Thursday, 27 February 2003 13:24 by Peter Provost

In response to my post asking why he was using DataSets instead of collections of model objects, Justin responded:

Why I want to pass DataSets to the web tier.

Peter asks why I want to do this.

I've actually been asked that a few times. So here goes...

We (my current gig) just had a rule passed down that all grids be sortable by any column both ascending and descending.

ADO.NET has all these nice features for sorting (i.e. the DataView). So if I give data back as a DataTable, then the UI can decide how they want to sort independent of how I want to sort. Sure I could do this with custom implementations of IComparer. But my typical object has 6 columns that are shown on the screen. So, in the worst case (but most OO case), I would have twelve comparers (one for each column and order combination). I could go with a somewhat simpler approach and have one comparer per column and have it know whether or not it should be ascending or descending. And I could finally have one comparer per object where the UI passes in the sort direction and field to sort by. But this uber comparer for the object would be huge and have bunches of switches. I'm sure there are other ways to implement a comparer, but those are the 3 I came up with with a few minutes thought.

Of course, the idea of returning datasets might be moot once I finish my ObjectComparer (sort any object by one of it's fields using reflection).

[News from the Forest]

That is an excellent idea. Why didn't I think of that. Hopefully either Justin or I will publish one soon.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Technology
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed
Comments are closed