Home > Articles > Programming > Windows Programming

  • Print
  • + Share This
From the author of

The Usual Type of Client-Side Code

And now, as usual, some code from the client-side. To browse through the information in the custom classes, the code could look Listing 6.

Listing 6—Code for browsing through an Order and its OrderLines

Dim anOrder As NewArchOrder = _
_GetRandomId()) _id = anOrder.Id _customerId = anOrder.CustomerId _orderDate = anOrder.OrderDate Dim anOrderLine As NewArchOrderLine For Each anOrderLine In anOrder.OrderLines _productId = anOrderLine.ProductId _priceForEach = anOrderLine.PriceForEach _noOfItems = anOrderLine.NoOfItems _comment = anOrderLine.Comment Next

In Listing 6, you find exactly the same client-side code as for custom classes (discussed last time). The only differences are the type names: NewArchOrder and NewArchOrderLine instead of Order and OrderLine. So, the simplicity at the client-side is still there, and that's very important, in my opinion.

Support Rich Databinding

One major advantage of the DataSet is its built-in support for rich databinding. You get rudimentary databinding automatically when inheriting from CollectionBase or using ArrayList, for example; but that is much weaker than what the DataSet provides. For example, assume that you bind a grid to a DataSet in a Windows Form. The user edits one of the rows, but then presses Escape. The DataSet then knows how to translate that event and cancel the edit. That's just one example of the way a DataSet can give a rich user interface experience.

I haven't put any energy at all into adding rich databinding support in my new architecture yet, but my plan is to use the Decorator pattern. (See Gamma, Helm, Johnson, Vlissides, Design Patterns. Addison-Wesley, 1995, ISBN: 0201633612.) I will decorate (wrap) collections and entity instances at the client side with rich databinding support.

If you find rich databinding important, you should read Rockford Lhotka's great book (Rockford Lhotka, Visual Basic .NET Business Objects. APress, 2003.) He discusses how to add support for rich databinding to a Domain Model at length.

  • + Share This
  • 🔖 Save To Your Account