Click here to Skip to main content
15,887,454 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: Multithreading done "right" Pin
Florin Jurcovici10-Jul-12 4:28
Florin Jurcovici10-Jul-12 4:28 
GeneralAJAX calender Pin
Arul R Ece17-May-12 18:31
Arul R Ece17-May-12 18:31 
GeneralRe: Quote Pin
Rahul Rajat Singh17-May-12 21:44
professionalRahul Rajat Singh17-May-12 21:44 
GeneralRe: Quote PinPopular
Sander Rossel19-May-12 0:35
professionalSander Rossel19-May-12 0:35 
GeneralRe: Quote Pin
BillW3319-May-12 6:58
professionalBillW3319-May-12 6:58 
GeneralRe: Quote Pin
Dalek Dave21-May-12 22:25
professionalDalek Dave21-May-12 22:25 
GeneralRe: Quote Pin
KP Lee24-May-12 21:41
KP Lee24-May-12 21:41 
GeneralReflection Optimization Pin
Mike Marynowski17-May-12 13:46
professionalMike Marynowski17-May-12 13:46 
Just found this gem in my own code D'Oh! | :doh: Worst part is that this runs quite often in tight loops in production code, haha.

public class SomeClass()
{
    private PropertyInfo _propertyInfo;

    public SomeClass(PropertyInfo propertyInfo)
    {
        _propertyInfo = propertyInfo;
    }

    public void ProcessStuff(object obj, object value)
    {
        // [Lots of stuff omitted]

        obj.GetType().GetProperty(_propertyInfo.Name).SetValue(obj, value, null);
    }
}


Who can spot the blunder?
GeneralRe: Reflection Optimization Pin
Ankush Bansal17-May-12 18:11
Ankush Bansal17-May-12 18:11 
GeneralRe: Reflection Optimization Pin
Mike Marynowski17-May-12 18:36
professionalMike Marynowski17-May-12 18:36 
GeneralRe: Reflection Optimization Pin
CDP180219-May-12 4:29
CDP180219-May-12 4:29 
GeneralRe: Reflection Optimization Pin
Mike Marynowski19-May-12 4:59
professionalMike Marynowski19-May-12 4:59 
GeneralRe: Reflection Optimization Pin
CDP180219-May-12 23:04
CDP180219-May-12 23:04 
GeneralRe: Reflection Optimization Pin
Brisingr Aerowing23-May-12 13:02
professionalBrisingr Aerowing23-May-12 13:02 
GeneralRe: Reflection Optimization Pin
CDP180223-May-12 21:31
CDP180223-May-12 21:31 
GeneralRe: Reflection Optimization Pin
Mike Marynowski19-May-12 5:03
professionalMike Marynowski19-May-12 5:03 
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 
GeneralRe: return value optimization PinPopular
Ankush Bansal16-May-12 19:47
Ankush Bansal16-May-12 19:47 

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.