|
-
June 21st, 2010, 07:53 AM
#1
choose implementation at link time
Hi,
I've got a pretty generic problem.
Suppose that there's some functionality that can be implemented in several independent ways, for example you need a database and there are several technologies to implement it (MySQL, SQLite, etc.). The different implementations share a common interface though, for example a function to delete or update a database record.
Now, you'd like to make your source code as unaware as possible from the implementation you choose. The easy way to do this is to create an interface (in C++ terms, an abstract class with pure virtual functions) and for each implementation have a class that implements the interface, and to have one single point where you decide which kind of object to use. The Factory design pattern is applicable here.
However, I'm looking for a way to do this at link time: have different implementations, for example provided as libraries, among which you choose one to link with the rest of the application. The source code of "the rest of the application" would be unaware of exactly which implementation has been chosen.
Does anyone have any ideas on how to do this?
If anything is unclear in my explanation above, please let me know.
Cheers
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|