Click here to Skip to main content
15,891,597 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
JokeRe: Code Optimize Pin
cpkilekofp27-Jan-12 8:54
cpkilekofp27-Jan-12 8:54 
GeneralRe: Code Optimize Pin
Snorri Kristjansson18-Jan-12 22:28
professionalSnorri Kristjansson18-Jan-12 22:28 
GeneralRe: Code Optimize Pin
Donkey Master17-Jan-12 0:56
Donkey Master17-Jan-12 0:56 
GeneralRe: Code Optimize Pin
Rajesh Anuhya17-Jan-12 1:17
professionalRajesh Anuhya17-Jan-12 1:17 
GeneralRe: Code Optimize PinPopular
Rob Grainger17-Jan-12 3:31
Rob Grainger17-Jan-12 3:31 
GeneralRe: Code Optimize Pin
mrchief_200017-Jan-12 11:49
mrchief_200017-Jan-12 11:49 
GeneralRe: Code Optimize Pin
KP Lee17-Jan-12 21:25
KP Lee17-Jan-12 21:25 
GeneralRe: Code Optimize Pin
jschell17-Jan-12 11:50
jschell17-Jan-12 11:50 
Rajesh Anuhya wrote:
However this is a Small code, which is called by many classes.
 
my
point is why should i declare a extra variable "resultflag", where this method
called 5000+ times in every 10 seconds


I can only suppose that that is a general statement that has nothing to do with the code presented.

First the code presented suggests it is doing a database call. You will not be able to even measure the performance gain that you are claiming because of that. The impact of the database call will completely overwhelm the the measurement of what you are claiming. I would suspect that even the variability of network traffic itself would reduce your measurement to the noise level.

Second if your goal is to improve the performance of the that code then you must reduce the number of calls to the database. For example by using a memory cache. That would have a significant impact.

Finally the code is using a return value that is going to end up on the stack regardless of whether it is explicitly stated or implicitly stated. I wouldn't be suprised if the emitted code is almost basically the same between the two versions.
GeneralRe: Code Optimize Pin
johannesnestler18-Jan-12 5:22
johannesnestler18-Jan-12 5:22 
GeneralRe: Code Optimize Pin
BobJanova17-Jan-12 1:25
BobJanova17-Jan-12 1:25 
GeneralRe: Code Optimize Pin
Rajesh Anuhya17-Jan-12 1:52
professionalRajesh Anuhya17-Jan-12 1:52 
GeneralRe: Code Optimize Pin
KP Lee17-Jan-12 21:11
KP Lee17-Jan-12 21:11 
GeneralRe: Code Optimize Pin
RobCroll18-Jan-12 15:57
RobCroll18-Jan-12 15:57 
GeneralRe: Code Optimize Pin
wg_self27-Jan-12 4:44
wg_self27-Jan-12 4:44 
GeneralCongratulations, you have overtaxed the .NET garbage collector! Pin
ekolis14-Jan-12 9:15
ekolis14-Jan-12 9:15 
GeneralWhy is dates so difficult? Pin
Jan Steyn12-Jan-12 23:26
Jan Steyn12-Jan-12 23:26 
GeneralRe: Why is dates so difficult? Pin
AspDotNetDev13-Jan-12 7:23
protectorAspDotNetDev13-Jan-12 7:23 
GeneralRe: Why is dates so difficult? PinPopular
John Hunley16-Jan-12 6:51
John Hunley16-Jan-12 6:51 
GeneralRe: Why is dates so difficult? Pin
Florin Jurcovici16-Jan-12 22:13
Florin Jurcovici16-Jan-12 22:13 
GeneralWhat one Should do if Program warns you about one's uninitialized variable? Pin
Mohibur Rashid11-Jan-12 21:29
professionalMohibur Rashid11-Jan-12 21:29 
GeneralRe: What one Should do if Program warns you about one's uninitialized variable? Pin
Nagy Vilmos12-Jan-12 1:00
professionalNagy Vilmos12-Jan-12 1:00 
QuestionRe: What one Should do if Program warns you about one's uninitialized variable? Pin
Julien Villers12-Jan-12 4:32
professionalJulien Villers12-Jan-12 4:32 
AnswerRe: What one Should do if Program warns you about one's uninitialized variable? Pin
Nagy Vilmos12-Jan-12 4:47
professionalNagy Vilmos12-Jan-12 4:47 
GeneralRe: What one Should do if Program warns you about one's uninitialized variable? Pin
Julien Villers12-Jan-12 4:54
professionalJulien Villers12-Jan-12 4:54 
GeneralThe result was that people learnt to check for warnings before they checked in their code. Pin
jsc4216-Jan-12 23:01
professionaljsc4216-Jan-12 23:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.