Click here to Skip to main content
15,887,214 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.

 
GeneralRe: Reflection Optimization Pin
BillW3319-May-12 6:57
professionalBillW3319-May-12 6:57 
GeneralRe: Reflection Optimization Pin
CDP180219-May-12 23:39
CDP180219-May-12 23:39 
GeneralRe: Reflection Optimization Pin
Mike Marynowski22-May-12 4:39
professionalMike Marynowski22-May-12 4:39 
GeneralRe: Reflection Optimization Pin
englebart22-May-12 3:00
professionalenglebart22-May-12 3:00 
GeneralRe: Reflection Optimization Pin
Mike Marynowski22-May-12 4:30
professionalMike Marynowski22-May-12 4:30 
GeneralRe: Reflection Optimization Pin
BrianPayne22-May-12 9:47
BrianPayne22-May-12 9:47 
GeneralRe: Reflection Optimization Pin
MiddleTommy22-May-12 3:44
MiddleTommy22-May-12 3:44 
Rantreturn value optimization PinPopular
Rahul Rajat Singh16-May-12 19:32
professionalRahul Rajat Singh16-May-12 19:32 
I was reading some of the legacy code that is being used by one of our applications. there are some .js files which are meant to be used by new developments so that we dont have to "reinvent the wheel" (thats what we have been told)

I opened the first file and first function and i saw

JavaScript
function somefucntion()
{
  .
  .
  .
    if (!flag)
    {
        retVal = false;
        return false;
    }

    retVal = true;
    return true;
}


What the heck? Is this some kind of javascript return value optimization that I am unaware of because i think i can simply replace these lines with return flag;

P.S. even after pointing in out I am not allowed to change is as we are not allowed to change this code as "it might break something" (WT Elephant?)
GeneralRe: return value optimization Pin
Ankush Bansal16-May-12 19:47
Ankush Bansal16-May-12 19:47 
GeneralRe: return value optimization Pin
Jochen Arndt16-May-12 21:09
professionalJochen Arndt16-May-12 21:09 
GeneralRe: return value optimization Pin
Ankush Bansal16-May-12 22:03
Ankush Bansal16-May-12 22:03 
GeneralRe: return value optimization Pin
BobJanova17-May-12 2:04
BobJanova17-May-12 2:04 
GeneralRe: return value optimization Pin
Vasily Tserekh21-May-12 8:01
Vasily Tserekh21-May-12 8:01 
GeneralRe: return value optimization Pin
BobJanova16-May-12 22:59
BobJanova16-May-12 22:59 
GeneralRe: return value optimization Pin
Mohibur Rashid17-May-12 0:12
professionalMohibur Rashid17-May-12 0:12 
GeneralRe: return value optimization Pin
BobJanova17-May-12 0:55
BobJanova17-May-12 0:55 
GeneralRe: return value optimization Pin
jsc4221-May-12 22:13
professionaljsc4221-May-12 22:13 
GeneralRe: return value optimization Pin
BobJanova21-May-12 23:51
BobJanova21-May-12 23:51 
GeneralRe: return value optimization Pin
jsc4222-May-12 0:11
professionaljsc4222-May-12 0:11 
GeneralRe: return value optimization Pin
Rahul Rajat Singh17-May-12 1:03
professionalRahul Rajat Singh17-May-12 1:03 
GeneralRe: return value optimization Pin
Mohibur Rashid17-May-12 1:52
professionalMohibur Rashid17-May-12 1:52 
GeneralRe: return value optimization Pin
Rahul Rajat Singh17-May-12 2:01
professionalRahul Rajat Singh17-May-12 2:01 
GeneralRe: return value optimization Pin
BillW3317-May-12 3:10
professionalBillW3317-May-12 3:10 
Generalcome on give me a break !! Pin
Ankush Bansal12-May-12 2:03
Ankush Bansal12-May-12 2:03 
GeneralRe: come on give me a break !! Pin
StM0n13-May-12 23:43
StM0n13-May-12 23:43 

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.