Disclaimer: this post is all about DD on .Net 3.5 not .Net 4.0, I’ve not had a chance to play with the .Net 4 version yet.
Now DD provides an excellent way to build CRUD applications against a database, in a matter of moments you can have a functioning application and as its Asp.Net you can easily customise the application to add security, change its appearance, etc and through its Meta data driven buddy classes it becomes easy to alter what DD renders.
However, it is when you want to extend a DD application to do more than its simple CRUD operations you start to run into its limitations. If using Linq-to-sql, without extending the entities, then you are effectively forced to work in a Transaction Script style which is fine for simple applications but very quickly you start to struggle as the complexity rises, plus, it is almost impossible to do TDD with DD & Linq-to-sql combination.
If you extend the entities in Linq-to-sql or use Entity Framework then you can start to work in an Active Record style but due to the intertwined nature of the logic and the data its still almost impossible to do TDD (an interesting aside is this post I found which mentions ‘the Active Record Anti-Pattern’ which is the first time I’ve heard of one of the main architectural patterns described as an ‘anti-pattern'). By extending the entities you do gain the ability to add logic to them making some tasks easier but as the complexity continues to rise you again run into problems trying to make what should be easy work for you.
An example: In my last job the final piece of work that the team worked on we decided to use DD as it provided us the opportunity to get the site working in a short period of time. Now everything started fine we got the site working quickly, styled it appropriately and it all looked good, then the changes began. With each change the logic that was required increased in complexity and if we hadn’t been using DD we could have had a nice suite of tests to help us test the logic but we didn’t, so we could only perform functional testing which meant that the boundary and corner cases were difficult to test and mistakes were made.
What I and my previous team learnt from this is that when using DD there is a tipping point you reach where the functionality DD provides is outweighed by the complexity of extending it.
So should you use Dynamic Data? As with most things it depends – if you only need CRUD actions like a simple data entry application then its perfect, but if you know that you’ll need to extend or implement complex logic I would suggest that you use standard Asp.Net web forms or MVC as it will ultimately be quicker and easier for you to develop and test.
I’d love to hear from anybody who has experience from using DD and how they got on.