CSharp/C# >> Novice question on Performance

by CSharper » Wed, 03 Sep 2008 23:39:30 GMT

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,

CSharp/C# >> Novice question on Performance

by Ignacio Machin ( .NET/ C# MVP ) » Wed, 03 Sep 2008 23:47:11 GMT



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 :)

CSharp/C# >> Novice question on Performance

by CSharper » Wed, 03 Sep 2008 23:56:15 GMT

On Sep 3, 10:47燼m, "Ignacio Machin ( .NET/ C# MVP )"



Thanks, that make me feel better.

Similar Threads

1. Syntax Question - Novice Question

Hi,

I am filling a datagrid and I was wondering how I can test for "end of file"
and then make decisions based on that. I am still making the transition from
asp to asp.net.

Could someone help me with the syntax please?

Thanks in advance for youe answer

Sean



Dim Conn As OleDbConnection

Dim Rdr As OleDbDataReader

Try

Dim strConn As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="

strConn &= Server.MapPath("clicks.mdb") & ";"

Dim strSQL As String

strSQL = "select FirstName from newsletter where FirstName='sean'"

Conn = New OleDbConnection(strConn)

Dim Cmd As New OleDbCommand(strSQL, Conn)

Conn.Open()

Rdr = Cmd.ExecuteReader()

MyDataGrid.DataSource = Rdr

MyDataGrid.DataBind()

Catch exc1 As Exception

Label1.Text = exc1.ToString()

Finally

If Not (Rdr Is Nothing) Then

If Rdr.IsClosed = False Then Rdr.Close()

End If

If Not (Conn Is Nothing) Then

If Conn.State = System.Data.ConnectionState.Open Then Conn.Close()

End If

End Try



2. question from C# novice - Microsoft .NET Framework

3. Novice question about overridable subs

If I have the following in a master user control...

Protected Overridable Sub CaptureFields()
    DoThis...
End Sub

And then this in an inherited user control...

Protected Overrides Sub CaptureFields()
    DoThat...
End Sub

What happens?

Will "DoThis" execute and then "DoThat"?  Will "DoThis" never execute?  How 
does it work (i.e. how do they work together if they do?)

Thanks for any response. 

4. Another novice question - CSharp/C#

5. Simple novice question!

I have a program which I am going to install it in a server with short
cut to bunch of users to that applicaion. Now, how does the program
execute when a user starts the program? Will the program run in server
or in client? (it has to be in server but want to confirm). How is the
running application differ from when another user executes the same
program?

6. novice question - CSharp/C#

7. Novice question about inherited constructors

I am moving from Delphi to C# and hve encountered the problem:

I have the following classes and form Load event handler:

public class class1
{
  public string S;
  public class1( string aS )
  {
  S = aS;
  }
}

public class class2 : class1
{
}

private void Form1_Load(object sender, System.EventArgs e)
{
  class2 C2 = new class2( "string" );
  label1.Text = C2.S;
}

When I try to compile I get the following errors:

No overload for method 'class1' takes '0' arguments
No overload for method 'class2' takes '1' arguments

What does it mean ?
Why inherited constructors are not used (as in Delphi) ?

Oleg Subachev


8. Novice C#.NET question - CSharp/C#