Step1: Learn "Hot to work with strings?"
If you are c++ programmer and start with modern languages while Delphi, c# or Java, there have thausands of lines writen for working with strings.
Never not use:
string result = ""; //instead result = string.Empty.
For this method of initialization of string variable Microsoft are make couple of optimization.
If you want to format same string, don't write:
result = var1 + " this is " + var2 + " the best " var3 + " ."; //where var 1-3 are string variable
Just use:
result = String.Format("{0} this is {1} the best {2} ."
If you must concatenated more that four string, in language exist StringBuilder. I'm make test with 1000 concatanations of strin. For "result += result" this take about twenty
seconds, instead for StringBuilder is three seconds.
If you campare strings, don't use equals operator (this is stupid least). Use String.Compar() or string result = "test", result.Equals("tests")
Step2: Use "Using" block for working with database and file system.
if you open file or database connection just write:
using(SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open()
} //after programs pass this line, connection is closed
What deliver this functionallity for you?
- if you forgot to close connection, it's closed.
- couple of lines code, that you have to write.
Step4: Use generics List instead ArrayList.
ArrayList object make boxing and unboxing in every operation with it, for this reason Microsoft ® release List<T> (generic lists) with .net 2.0. When they are make optimization , we just have to use it.
Never don't write:
ArrayList customers = new ArrayList();
// List<Customer> customer = new List<Customer>();
customers.add(new Customer()); // it's same
Customer temp = customers[i] as Customer; //
Customer temp = customers[i];//without unboxing;
Step5: Don't use ssl on every pages
I'm look person that write e-commerce application and they put ssl on every web pages. This isn't right decision, you must implement you chec-out process with ASP.NET wizard
and put user iteration only on couple of pages. When user browse web site , there no reason to have SSL on every page. If you open sites while amazon i yahoo shopping you will
see, that use ssl when you buy product and must enter same sensitive information.
For you stay problem to define which pages exatly have need to be put on SSL line, this one will be perfect fix the problem with your ASP.NET perfomance.
Conclusion:
-
Working with string is imporatnt for web development.
-
Minimazing using of ArrayList, instead use Custom Obgects with Generic List.
-
Minimazing using of SSL, this will put down your web server.