Novice question on Performance

  • Thread starter Thread starter CSharper
  • Start date Start date
C

CSharper

I have been writing code for sometime, but I always get a hang up on
performance. I can't tell which implementation is good and which is
not. I have two scenarios down and I would like your expert opinion on
this
1. I have a situation where I need to read in the arguments passed to
the program and then validate it and parse it to an array. What I did
was to create a class which performs all these tasks as separate
methods. I did it in TDD and everything is fine. After writing I was
wondering is it a right way to do it? Since it is a class, there is a
cost associated with instantiating the class and the heap memory also
GC overhead. What if I would attempt it in Static method?? It also has
the same problems. Not sure about that.
2. I have to read sql database using stored proc. In this also I wrote
a class which perform connection, execution and result. Since this SP
is used more than once opposed to (1), I could create a Extented
method (using static method on string, where I preserve the SQL
connection) or using a static class for the SQL operations.

What is the best way to do it?

Thanks,
 
I have been writing code for sometime, but I always get a hang up on
performance. I can't tell which implementation is good and which is
not. I have two scenarios down and I would like your expert opinion on
this
1. I have a situation where I need to read in the arguments passed to
the program and then validate it and parse it to an array. What I did
was to create a class which performs all these tasks as separate
methods. I did it in TDD and everything is fine. After writing I was
wondering is it a right way to do it? Since it is a class, there is a
cost associated with instantiating the class and the heap memory also
GC overhead.

Do you have any idea how many classes are created by the simplest win
app?, believe me one more will have no impact what so ever :)
In this case the maintenability and logic has more importance that
creating one class.
Not only that, but as the class probably is static you will not create
an instance of it in the first place :)
 
Do you have any idea how many classes are created by the simplest win
app?, believe me one more will have no impact what so ever :)
In this case the maintenability and logic has more importance that
creating one class.
Not only that, but as the class probably is static you will not create
an instance of it in the first place :)

Thanks, that make me feel better.
 
Back
Top