RSS Feed
19
July
2004

The benefit of encapsulating database access: Testability

Some people ask why to put an abstraction layer above the database at all. Their typical argument is that a relational database is not object oriented at all. Selecting only certain fields of various tables combined in a join is a good example. So this argument seems to make sense at first. But let's assume a rather large project with lots of pages. Now what if you change the structure of a table in use? How do you find the affected pages? By centralizing the SQL code in DAO objects the solution is trivial. But if you spread the SQL code over multiple pages this task will become tricky. Of course you could write a bunch of scripts for checking every single page of your project but I think it's definitely easier to test only a handful of DAO objects :-)

Comments

1. Anthony Eden
Or you could use the handy-dandy Search feature of your text editor. Your text editor does have that, right? ;-)