Thoughts on the factory design pattern
interface IAccessLayer{ string GetQueryResultsAsString(string query); DataTable GetQueryResultsAsDataTable(string query); void ExecuteModificationQuery(string query);}
class MSSQLAccessLayer : IAccessLayer{ ///Implement public contract from IAccessLayer}class mySQLAccessLayer : IAccessLayer{ ///Implement public contract from IAccessLayer}class XMLAccessLayer : IAccessLayer{ ///Implement public contract from IAccessLayer}class OracleAccessLayer : IAccessLayer{ ///Implement public contract from IAccessLayer}
public IAccessLayer GetAccessLayer(string dataAccessMedium){ dataAccessMedium = dataAccessMedium.ToUpper(); if(dataAccessMedium == "MSSQL") { return new MSSQLAccessLayer(); } else if(dataAccessMedium == "ORACLE") { return new OracleAccessLayer(); } else if(dataAccessMedium == "MYSQL") { return new mySQLAccessLayer(); } else if(dataAccessMedium == "XML") { return new XMLAccessLayer(); } else { throw new Exception("Error. " + dataAccessMedium + " is not a valid data access method"); }}