first_page

Rocky’s Data Binding Frustration

Buy this book at Amazon.comIn spite of the fact that there is a virtual machine in my cube with Visual Studio 2005 installed, I still need the heavy hitters like Rockford Lhotka to get into platforms like ASP.NET 2.0 and point out their shortcomings to prevent developer suffering. When you work for the company that sells and markets these products, it is difficult for various reasons (including an expensive education at obedience school and a financially healthy paranoia about shareholder interests) to point out what is wrong with these products—until, of course, the next version ships. In “ASP.NET 2.0 Data Binding Frustration” Rocky writes about data-binding objects:

First, ASP.NET insists on creating instances of your objects at will – using a default constructor. CSLA .NET follows a factory method model where objects are always created through a factory method, providing for more control, abstraction and flexibility in object design.

Second, when updating data (the user has edited existing data and clicked Update), ASP.NET creates an instance of your object, sets its properties and calls an Update method. CSLA .NET objects are aware of whether they are new or old – whether they contain a primary key value that matches a value in the database or not. This means that the object knows whether to do an INSERT or UPDATE automatically. But when a CSLA .NET object is created out of thin air it obviously thinks it is new – yet in the ASP.NET case the object is actually old, but has no way of knowing that.

More details about Rocky’s business object framework are available online. An important bit mentioned in the post is that ASP.NET 2.0 data binding technology is very friendly to “Data Transfer Objects” (DTOs). Rocky considers these objects extremely limited because they have no methods or “behaviors.” This may be unfortunate for me because my data access design features DTOs. In fact, there are two sets of DTOs, one optimized for SQL Server and one optimized for serialization. There is a separate class that defines a “data manager” that knows about the database. It looks like Rocky wants every business object to contain data and methods to handle the DBMS it represents. Am I on the wrong track here? Whatever the outcome, Rocky’s framework reveals the “known issues” of ASP.NET 2.0.

rasx()