M
Mike
Hi,
I am writing a data access layer that would allow connecting to various database systems, such as SqlServer, MySQL, Oracle, Ms Access, etc. Since I also would like to use providers specific to each database system's type, I created a main interface, called IConnectionFactory, with the signatures of the methods. I then implemented it in the different classes, such as MySqlConnectionFactory. However, I have the impression of duplicating the code in every specific provider's class to meet the provider's types. Graphically:
IConnectionFactory <- - - - - - - SqlServerConnectionFactory
IConnectionFactory <- - - - - - - MySqlConnectionFactory
Is there a better pattern to avoid code duplication (for methods like "Open", "Close", etc.)? What about "generics"? Any link or suggestion is appreciated.
Thanks a lot.
Mike
I am writing a data access layer that would allow connecting to various database systems, such as SqlServer, MySQL, Oracle, Ms Access, etc. Since I also would like to use providers specific to each database system's type, I created a main interface, called IConnectionFactory, with the signatures of the methods. I then implemented it in the different classes, such as MySqlConnectionFactory. However, I have the impression of duplicating the code in every specific provider's class to meet the provider's types. Graphically:
IConnectionFactory <- - - - - - - SqlServerConnectionFactory
IConnectionFactory <- - - - - - - MySqlConnectionFactory
Is there a better pattern to avoid code duplication (for methods like "Open", "Close", etc.)? What about "generics"? Any link or suggestion is appreciated.
Thanks a lot.
Mike