Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What design patterns should I apply in application with database access

I will start to develop an application that has to access to database. What kind of design patterns area usually need to be implemented to make my application more flexible for example changing DB client from SQL to Oracle.

I believe to perform execution of some query I can implement Template Method Pattern. And to get connection a singleton pattern with double check would be sufficient.

Is there anything else I should know before starting?

Application will be developed in C#, so there is support for object inheritance and polymorphism.

Any help is appreciated.

like image 698
aumanets Avatar asked Apr 14 '11 15:04

aumanets


1 Answers

Make sure all your code is encapsulated in a data access layer. Code against interfaces so that if you need to write a new data access library, you don't have to change all calling code. This will at least isolate all data access into on library. How likely is the changing of database to be? Don't make the software complex for the what-ifs as this will just make life more difficult.

like image 199
Tomas McGuinness Avatar answered Oct 27 '22 11:10

Tomas McGuinness