Friday, June 1, 2012


In a recent post titled "No DB", Uncle Bob Martin strongly advocates against making the database integral to a system's design:
The center of your application is not the database. Nor is it one or more of the frameworks you may be using. The center of your application are the use cases of your application.

If you get the database involved early, then it will warp your design. It’ll fight to gain control of the center, and once there it will hold onto the center like a scruffy terrier. You have to work hard to keep the database out of the center of your systems. You have to continuously say “No” to the temptation to get the database working early.

What is the best time to determine your data model? When you know what the data entities are, how they are related, and how they are used. When do you know that? When you’ve gotten all the use cases and business rules written and tested. By that time you will have identified all the queries, all the relationships, all the data elements, and you’ll be able to construct a data model that fits nicely into a database.
I agree with Uncle Bob and I've previously posted about early database design problems here.  In my experience, early database design leads to the domain being altered to fit a solution.

No comments: