Tuesday, February 20, 2007

Early Access Program: NHibernate in Action ... and some DataSet-bashing for my part.

According to Amazon NHibernate in Action is going to be released in July. I am looking forward to get a copy.

But you can already start reading the book today through the Manning Early Access Program.

The first chapter is free. Chapters 2–4 are available if you are willing to pay for the Early Access Program.

If OR-Mapping is not completely new territory for you, the first chapter does not offer much. It is basically an introduction to OR-Mapping and the concepts around OR-Mapping (Domain-Model, Layered-Architecture, some Patterns and the Impedance Mismatch). You can find the same information in several other books like Java Persistence with Hibernate, Hibernate in Action, Applying Domain-Driven Design and Patterns and POJOs in Action.

However there is one interesting difference to the books above: It discusses OR-Mapping as alternative to DataSets.

The book points out, that DataSets are a very efficient way to implement an initial Data-Access-Layer and for displaying (tabular) data in a GUI. But DataSets do heavily restrict your freedom in modeling the business domain and applying OO-Analysis and OO-Design.

These summarizes the feeling I have about datasets. I hope I will find the time to explore the reasons behind this, and write a post about it.

But for now lets look at the good and the bad of DataSets

  • good: helps with DB-access and Data binding -> these are both technical/infrastructure-concerns
  • bad: limits modeling in your business logic -> for non-trivial applications this should be your main concern!

So if your application has no business logic, then Dataset are optimal: The GUI is basically directly bound to the database, although DataSets make it possible to have several layers/tears between database an GUI, you basically don't do anything of business value (security, distribution, transactions, basic validation do not count as business value they are technical/infrastructure-concerns).

But if you have non-trivial business logic, you have to decide where your priorities lie. Is it more important to easily solve the technical/infrastructural-concerns or is it more important to develop an elegant, maintainable and extensible business-model?
You don't have to answer right now ;-) but put into consideration that DB-access and Databinding without DataSets is not as hard as it used to be some years ago (thinking of NHibernate, Genome, OpenAccess and Object-DataBinding) … well, can you guess my answer to the above question? ;-)

I think DataSets are still very popular, because for non-experienced programmers they allow to quickly develop a vertical prototype for an application. The goal of the vertical prototype is often to prove that the technical concerns can be solved. So the prototype is mostly about infrastructure. The prototype seldom provides a lot of the business functionality (well after all its a prototype ;-), and it certainly does not have to manage complexity, maintainability and extensibility.

Problems arise only later when the application should evolve horizontally and provide the real business functionality. But at this point the architecture is often fixed, and the door is closed: Welcome in a world of pain!

So here my final blow for today: DataSets are misleading, they promise a multi layered/multi tiered architecture but basically the programming model is the same as in a client-server app with the business logic in the database. With DataSets the code is just not executed in the database but in some other layer/tier but even that is questionable a good thing…



No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...