Does anyone have a good suggestion on how to set up the code to efficiently change from the project database to a commercial database? Right now I have a business services layer that has a data layer object reference and simply calls the data layer methods and passes in the data. For example: datalayer.updateData(recordNum, lockCookie);
This works, but I'm sure there must be a better way to setup the application to switch from the homegrown db to a commercial app. Any suggestions?
I have trouble with understanding what your asking.
Now your application works with a flat database file. You have an interface and 1 implementation. If the company decides to use a rdbms (like mysql) instead of the flat database file, you have to implement the given interface a second time. The current implementation (Data class) will be replaced with this new implementation and the application will still keep working.
Sorry about that, I phrased the post poorly. I guess I'm just curious about how other people handled the problem of setting up their application to deal with the issues of using different databases. I know someone (you?) did a dao factory pattern.
David Pantale wrote:I know someone (you?) did a dao factory pattern.
Yes, that was me I stuck very close to the instructions and developed only the "must" requirements, except this dao factory pattern. In my opinion it really has a lot of added value, it gives you tons of flexibility. You can simply extend your application with another DAO (one for customers for example), when you have different DAOs you can easily stick to the one for flat database file for customers and already start using a MySql-based one for bookings,...
Joined: Mar 16, 2010
Could you explain in a little more detail how you did it? I'm thinking maybe I should do the same.
There is nothing much I can tell about it. I just added the dao factory pattern and I use this factory to retrieve the appropriate instance of my dao (data class). So the only public api from the db-package are the interfaces and this factory. So classes from other packages don't know about the existence of the Data class.
I believe I used this link as one of my resources (it has been a long time ago )