XPO (ORM) vs ADO.NET?

I recently responded to a question on a newsgroup regarding what to use for persisting data - XPO (an Object/Relational Mapper (ORM) tool) or Microsoft's ADO.NET.  The question was from a Delphi developer new to .NET.  For posterity, I've included my response below.

Updated 23-Jul-06: added inline links and a link summary

Fundamentally, ADO.NET is a library that supports access to data. In order to simplify development, ADO.NET includes infrastructure that supports Microsoft's implementation of the disconnected recordset pattern i.e. DataSets.  That pattern is just one way to access data through ADO.NET, and is one that particularly suits simple RAD type applications driven through a tool like Visual Studio.  You don't need to use that pattern, indeed, it is not suited to applications with complex domains - applications that include a business domain layer modeled through objects.

Most .NET applications that use DataSets have no domain layer. Rather there is a triangular relationship between the Presentation/Logic layer, data access and the DataSet as shown below. They are generally modeled in terms of data not behavior - they are not object oriented solutions, but rather data-centric entity type ones.

 


Nevertheless, one can quickly get a simple application up and running through the visual tools, wizards and code generation found in tools like VS. Essentially just like you could in MS Visual Basic (version 3?) - which is no surprise as the majority of VS users come from a VB RAD background.

That does suit many simple applications, however, as domain complexity rises one needs to look to different patterns to connect the in-memory domain modeled through objects, to persisted data.

But, modeling complexity through objects in the domain layer has the problem that objects don't map well to most persisted data models - whether hierarchical, relational or other.

So the issue is how does one "map" objects to data?

One can look to a number of architectural patterns including Active Record (a la Ruby on Rails) through to data mapping through ORM (object/relational mapping) solutions.

XPO is an ORM tool. It portends to allow one to concentrate on modeling your application through objects, without regards to persistence. It is object-centric unlike popular ORM tools like LLBLGen Pro that is entity-centric and is more suited to the enterprise where schema already exists.

"XPO vs MS ADO.NET for the Delphi Programmer"? The real key is that there is no silver bullet - different patterns and approaches suit different projects.

My advice?  Learn and use both!

Links: Developer Express XPO | LLBLGen Pro | Active Record Pattern (1) (2) (3) | Ruby on Rails | ADO.NET | .NET Definition | ORM

No Comments