Fighting the monster Agile development on top of a legacy database Gojko Adzic XpDay 2007 – London
Two recurring patterns Redundant and Inconsistent interfaces –organic growth over the years –requires authors to be available Unstable foundation – breaks compatibility without warning
Build a solid foundation Simplify legacy interfaces Not really nice –keeps the rest clean Anti-corruption layer Extensive test coverage
Why are Databases not Agile? Tools are years behind OO Object-relational mismatch DB Code is hard to test DB developers not aware or discard agile practices
Fight the attitude Fundamental change requires enthusiasm Reduce the amount of dull work! TDD is a good solution
FIT+FitNesse+DbFit = excellent DB unit test tool Tests in tabular form Easier to use than manual tests No Java/.NET knowledge required Fits into agile environment
Hit the nerve Spread to other projects Released under GPL Used by banks, insurance companies, bookmakers… Oracle, SQL Server, MySQL Java/.NET integration tests
Fight duplication Database is the master source Does not have to be binary –“Create” scripts better Generate everything you can – especially inter-layer code
Going for the kill “Create” scripts make DB build automation easy DbFit+FitNesse verify functionality CI with Cruise Control Not everything is automated –but is good enough
Conclusions Agile makes as much sense for DB code as for anything else –Just harder to implement To get people enthusiastic, focus on reducing dull work
Conclusions Build a reliable foundation Simplify legacy APIs Kill code ownership Use version-control friendly files Generate glue between layers
Some links for the end