Women in Technology

Hear us Roar



Subject:   Performance?
Date:   2003-02-10 09:51:19
From:   neh123us@yahoo.com
The reflection will impact performance. There is a trade off between flexibility and performance. If performance is more important and you know that you will be limited to a small number of different platforms or atleast adding additional platforms more rarely, then there is a less flexible approach that would not rely on reflection.


In the GetConnection and GetDataAdapter methods, rather than searching through each of the referenced for the object type that is referenced in a config file, you could hard code object types against the valid values for the DbType. Using this approach, you may want to convert the DbType to an enumeration. The code would look similiar to this:


public static IDbConnection GetConnection (DBTypes dbType)
{
IDbConnection NewConnection;
if (dbType == DBTypes.SQL)
{
NewConnection = new SqlConnection ();
NewConnection.ConnectionString = ConfigurationSettings. AppSettings["SQLConnectionString"];


}
if (dbType == DBTypes.Oracle)
{
NewConnection = new OracleConnection();
NewConnection.ConnectionString = ConfigurationSettings. AppSettings["OracleConnectionString"];
}
return NewConnection;
}


It is important to always keep in mind which is more important speed, flexibility, maintainability, development time, etc.


I hope this helps,
Nick