In Eurocenter currently we are preparing for a new project-kickoff which is going to be based on the .NET platform. Among many other design decisions we are currently considering an implementation technology for our domain model. We have to decide between "typed datasets" and "custom entities". Both the methods has their own pros and cons. I have done a small research on this and I thought of sharing those information through this blog post.
Here are some major reasons where I think datasets are better in some situations.
- Database integration of the domain objects is very simple. DataAdaptor classes take care of the most of the database operations of the dataset. Also dataset has ability to remember the original values making the dirty object identification very easy.
- Easy serialization of data entities to XML
- Easy binding to most of the UI components
- Easy integration with other tools and components (E.g. Biztalk Server)
- Very good documentation and community support
Datasets makes the system less object oriented (as business methods are separated from the domain model)
Too much of generated code of datasets causes code duplication and lesser maintainability.
Exposing datasets as SOA can make services less interoperable.
Custom class approach is much cleaner and clear.
Unit testing is pretty much easy with custom class approach as data is easily bound to the operations.
Use of DataReaders, SPs and Custom Entities seems to perform better in the sense of memory usage and data fetch time.
In my opinion, we need to make sure that we use right tool at the right scenario. In a complex application (lots of integrations), I would prefer going with custom entities. If the application is a data driven or when the application is a disconnected data centered desktop application I would consider using datasets.