Behaviour Driven Database Design
When using frameworks in any application we expect certain behavior from them, BDD (Behavior Driven Design) is becoming popular. Database is one component of the application stack that lends very well to be developed in using the behavior driven approach. Database is also one of the components of the application that is least thought about and is assumed not to lend to Agile Development.
Doing BDDD (Behavior Driven Database Design) allows us to codify the behavior of the database as its is expected by the code running against the database, it also allows us to easily refactor the database, it also provides a very easy way to document the database design and behavior.
More clarification based on feedback.
This is how I go about implementing my story (feature).
Story 1245: As a User I should be able to create a Customer and save it.
While Implementing the story: I will have Customer domain object and will have a customer table. now what am I expecting from the Customer table? in other words what is the Behavior, I want from my customer table. Should it not allow NULL customer names? should it not allow Duplicate CustomerID's? Should it allow null email address? so for one and all assumptions of behavior I will write a unit test. Pseudo code below.
testShouldNotAllowDuplicateCustomerId()
{
createCustomerWithId(1);
try { createCustomerWithId(1);
fail(); //should have thrown a exception
}
catch (SqlException e)
{ //PK Violation expected
}
similarly if I encode all the behavior I'm expecting from my database, then I have a comprehensive set of tests to be able to refactor my database and also a extensive behavior spec of my database design.
This workshop features
The session will be an mixture of lecture and hands on demonstration, for example:
- How to automate database tasks - 10 minutes
- How to design a table using BDDD - 15 minutes
- How to design a Index- 10 minutes
- How to design a Referential Integrity Constraint - 15 minutes
- How to design a Constraint on a Column - 15 minutes
- How to include all of the above in Continuous Integration
Questions will be taken throughout the demonstration.
About Pramod Sadalage
Pramod Sadalage is the Co-Author of "Refactoring Databases: Evolutionary Database Development" a Martin Fowler signature series book and "Recipes for Continuous Database Integration". Pramod works as a Data Architect and Developer at ThoughtWorks, Inc, a leading custom e-business application and platform development firm. He works on large J2EE custom dev applications, which use XP, an agile methodology that has not been sufficiently discussed in the context of databases. While on these projects, he pioneered the practices and processes of Agility in the database. Pramod writes and speaks about these concepts and practices in order to make it easy for everyone to use agile practices in regard to use of databases on an agile project. Pramod has written and presented about database administration on Extreme Programming projects, the adoption of agile processes with regard to databases, and agile practices impact upon database administration. Pramod is the owner and founder of agiledatabases yahoo group, moderating discussions and making it easier for new people to learn about agile databases. When he is not working, you can find him spending time with his family and trying to improve his running.
|