Blog Index » Long Live the Objects!

Long Live the Objects!

The debate has gone on for a very long time: Should application developers use Objects (or Business Entities) or DataSets to create their applications. Until a few years ago, the answer was DataSets 98% of the time if a database was involved. MSDN Magazine even spent a whole issue on the debate (August 2005). In DataSets vs Collections by Dino Esposito, the Business Entities won a great victory when sent over a network because of the bloat associated with XML serializing an entire DataSet.

Until recently, the use of business entities in high-performance applications has been limited due to 2 reasons:
  • Firstly, databases required large amounts of hand-written, or [error prone] tool-generated code, or an Object-Relational Mapper (like Hibernate or nHibernate) to smooth the road. These solutions took a lot of time and energy to implement, debug, and run. So, naturally, Enterprise application developers have just gotten used to using DataSets to pass data arround a distributed system.
  • Secondly, UI and font-end engineers could not make use of automatic field data-binding capabilities in their forms and dialogs. If they used DataSets, wiring a text box to a value took only a few clicks. If they used business entities, it took up to 3 or 4 lines of code per field.

Now there are some solutions. db4o is a next-generation object database: designed for object-oriented environments, and optimized for an object-oriented world. Now the database gives you objects. Put your hands up and rejoice!

But wait! What about the second point? Those lazy UI engineers still don't want to write code! Well, they won't have to. You just need to think ahead, and do a few things to your classes before handing them over to those monkeys. That same MSDN Magazine issue also has an article on getting Design-Time databinding to work with custom collections and business entities instead of DataSets. (Give Your Everyday Custom Collections a Design-Time Makeover by Paul Ballard, August 2005)

After reading just half of the article on databinding, I was able to create a complete application that employed simple data binding to my custom object. A few more lines of code in my business entities, and the objects even managed to keep the database syncronized. Amazingly, I think the code that I wrote totaled about 6 lines to get all the functionality that would normally have taken 40 lines, and most of a day. The entire application took about an hour.

The application and code that I wrote will be published soon on the db4o web site. Look for it coming soon!

    0 Comments:

    Post a Comment