views:

85

answers:

2

I have inherited a suite of .Net c# applications from a developer which talk to an Informix database on a unix server.

Instead of using the usual practices for managing the database connections (disposable pattern / "open late / close early"), the code seems to open one ODBC connection when each app loads and doesn't close it.

Is there any way of seeing how many ODBC connections are open?

I am trying to make a case for refactoring the code in the applications to use .NET best practices but I am meeting with resistance because the current code works.

+1  A: 

you could enable ODBC tracing in the ODBC Administrator, start the application which should then open the pooled ODBC connections requested. Edit the ODBC trace file file and could the number of SQLConnect or SQLDriverConnect calls made to give the total number of ODBC connections made by the application. Any occurrences of SQLDisconnect indicates a connection was closed and this should be taken of the total number on connects ...

hwilliams
Thanks.I did this and was able to see that opening some of the applications simultaneously, over 25 connections were being held open on my own machine.
Beansy
+1  A: 

"but I am meeting with resistance because the current code works."

+1 for those giving the resistance.

If it really is the case that the required functionality is properly supported, and moreover there aren't any performance problems or so, then nothing is broken, and if nothing is broken, nothing needs to be fixed.

I've seen too many coding yuppies screw up working systems because they thought they knew a "better" way to organize the code.

If you are convinced that your way of organizing the code (your alleged "best practices") has any benefits compared to the one applied in the existing systems, demonstrate that to the business by applying it in a new project. If indeed there are noticeable benefits, then trust me, the users WILL notice. If there isn't, then you have been taught a very important lesson about the non-importance of "which way to code is the best".

Erwin Smout
When I say the current code works, this project is ongoing and the product has not been released to users yet. New features in the roadmap are becoming more difficult to implement as a result of the way the existing codebase has been designed / implemented.The reason I want to refactor the the code is to make it more maintainable and enable us to introduce unit testing as I believe this will save us time and money in he future.Thanks for the rant though...
Beansy