From: Steve F. <st...@m3...> - 2004-03-27 23:53:16
|
It sounds like you're trying to write this bottom-up, that is implement a generic db layer and then apply it. You might want to think about writing your persisitence services from the viewpoint of its clients, one case at a time, and then refactoring. Take a case where you need some kind of persistence. Write an interface that provides that persistence /in terms of the client/, using mocks to get you through the test. Now that interface becomes the client of the next persistence layer, gradually becoming more general until you hit JDBC. Combined with Remove Duplication, and Tell, Don't Ask, this should generate a persistence library. Either that, or use something like Hibernate... S. Graham King wrote: > I have been trying to abstract away database (JDBC) access using these > two principles: http://www.mockobjects.com/wiki/OnlyMockYourOwnInterfaces > http://www.mockobjects.com/wiki/MockableAdapter > > Not being able to find a practical example to plagiarise I tried writing > my own. A database basically allows the 'put'ing of data and the > 'get'ing of data (save / load or executeUpdate / executeQuery). > So first cut is (with verbosity removed): > > public interface Database { // Or should it be DatabaseAdapter ? > ReturnType get(String sql); > int put(String sql); // Returns number of rows affected > } > [...] |