473,397 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Dot net optimization tips

Hi All

Some tips for optimizing your .Net Code.
You can add more by leaving comments

http://dotnetforum.blogspot.com
or

http://www.dotnetforum.blogspot.com
Regards
Akash

Aug 11 '06 #1
4 4316
Akash,

I think that you need to revise a good number of these optimizations. A
good number of them are either incomplete, are targeted for very specific
situations, or are outright wrong. A good number of them can also be
considered "premature" optimizations.

For example:

Instead of For.Each construct within the iteration you must use Normal For
Loop Construct as For . Each creates an overhead.

Yes, it does, but have you measured how much of an overhead it creates?
It's minimal, at best, and provides a MUCH better way of iterating through
resources, as well as establishes a well-known interface which is now used
everywhere. It's an optimization that I could never recommend in good
conscience.

I would do a lot of work revising these.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"softwareakash" <so***********@gmail.comwrote in message
news:11**********************@75g2000cwc.googlegro ups.com...
Hi All

Some tips for optimizing your .Net Code.
You can add more by leaving comments

http://dotnetforum.blogspot.com
or

http://www.dotnetforum.blogspot.com
Regards
Akash

Aug 11 '06 #2
Well, you're just setting yourself up now... and note that your article
contains almost nothing that would actually optimise code... nor tell the
user what code would be usefully optimised (leaving them open to wasting
time on premature optimisation).

Just my opinion...

1: and if I want to do parallel database access, perhaps on different
threads? in fact, I would suggest let the connection pool worry about this,
and create / dispose connections as you need them; this doesn't remove them
from the pool (urban myth)

2: erm... not very useful without a "by..."; on the occasion you need to do
different things under different circumstances, you need *some* kind of
branching construct

3: not always true; on an array, maybe "for" with indexer access is
quicker - but without knowing what the underlying item is this is just
wrong. On a linked list, for instance, you could be changing the performance
from O(n) to O(n^2) by virtue of a telescoping series [actually, n(n+1)/2 or
something similar IIRC, which is O(n^2)]. Also, you can't use "for" on an
IEnumerable - only "foreach". Your assumption should be that the iterator is
well designed and knows the best way to enumerate that structure.

4: doesn't mean much to me I must admit

5: "towards XML so that Application can be made lightweight"... ahh, what
thedailywtf would say about this... xml, although versatile, is *not* a
lightweight data structure. DOMs are worse, but even raw xml is vastly more
costly than proper objects. Not sure what the choice of XML has to do with
the number of roundtrips - these are disparate concerns.

6: And you expect DataSets to improve performance?

7: When used correctly, agreed

8: whatever

9: UDF vs SP is odd. you can't call UDF directly, so... and you have less
access to certain features. I'm not saying they are bad, just that they do
different things to SPs, so it doesn't necessarily make sense to compare
them directly like this

10: Not sure what this means, but not sure I agree

11: How the heck does making the "Code More Generic" help with the need to
loop or branch? It doesn't. It also doesn't make the code shorter or
improved.

Marc
Aug 11 '06 #3
Limit the number of variables? Not a chance. Reusing "non-temp" variables
leads to confusing code. Also, local variable allocation always takes space
on the stack. Stack allocation when entering a stack frame is a constant
time operation with the actual space being reserved for local variables
allocated with a single machine language instruction, which on the x86
architecture is "SUB ESP, <bytes needed>. <bytes neededis determined by
the compiler at compile time and not by the runtime at runtime. Not
initializing objects with the "new" keyword may improve performance because
the runtime won't allocate memory until the object is initialized.

If the number of variables is causing performance problems, the only real
solution is to add memory to the system.

Mike Ober.

"softwareakash" <so***********@gmail.comwrote in message
news:11**********************@75g2000cwc.googlegro ups.com...
Hi All

Some tips for optimizing your .Net Code.
You can add more by leaving comments

http://dotnetforum.blogspot.com
or

http://www.dotnetforum.blogspot.com
Regards
Akash

Aug 11 '06 #4
Hi All

Thanks for your replies. I agree that the tips were very immature.
I am temporarily removing the tips and will again post them after
carefull reworking.

Regards
Akash

Aug 16 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Alex Glass | last post by:
I am building a query to select contacts and filter by category. I was wondering if anyone could explain why the first select statement takes 950 times as long to execute compared to the second....
2
by: Ruggiero | last post by:
Sorry for my bad english What is the optimization technique used by Access dbms? Thanks
21
by: mjbackues at yahoo | last post by:
Hello. I'm having a problem with the Visual Studio .net (2003) C++ speed optimization, and hope someone can suggest a workaround. My project includes many C++ files, most of which work fine...
5
by: Marty | last post by:
Hi, I've read that the if/else statement, or get/set accessor, can be compiled inline by the C# compiler if they are small enough. Have you seen any documentation that 'summarized' all thoses...
1
by: Tim | last post by:
Here is a list of a few very simple tips for optimizing your php/mysql applications. Keep these in mind while developing to survive the digg-effect. ...
0
by: qonhfmwfyrqx | last post by:
Discover how to quickly and easily create search engine optimized affiliate web sites that can make you money, even without any HTML knowledge or search engine optimization skills. Create...
0
by: softwareakash | last post by:
Hi All Some tips for optimizing your .Net Code. You can add more by leaving comments http://dotnetforum.blogspot.com or http://www.dotnetforum.blogspot.com
9
by: Amod | last post by:
hi all, Kindly suggest some tips to optimize the C++ code for higher speed. regards, Amod
3
by: mr_doles | last post by:
Let me preface this by saying I am not a programmer, I write code to make my like easier. So at the end of the day when I press the button as long as 1 + 1 = 2, I don't care how ugly the code is. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.