Click here to Skip to main content
15,886,873 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: Security - You're doing it wrong! Pin
Brisingr Aerowing8-Aug-12 15:15
professionalBrisingr Aerowing8-Aug-12 15:15 
JokeRe: Security - You're doing it wrong! Pin
Bernhard Hiller8-Aug-12 21:42
Bernhard Hiller8-Aug-12 21:42 
JokeRe: Security - You're doing it wrong! Pin
Andrei Straut8-Aug-12 23:05
Andrei Straut8-Aug-12 23:05 
GeneralRe: Security - You're doing it wrong! Pin
Bernhard Hiller9-Aug-12 0:49
Bernhard Hiller9-Aug-12 0:49 
GeneralRe: Security - You're doing it wrong! Pin
Andrei Straut9-Aug-12 1:15
Andrei Straut9-Aug-12 1:15 
GeneralRe: Security - You're doing it wrong! Pin
ekolis30-Aug-12 13:09
ekolis30-Aug-12 13:09 
GeneralRe: Security - You're doing it wrong! Pin
Brisingr Aerowing10-Aug-12 15:01
professionalBrisingr Aerowing10-Aug-12 15:01 
GeneralMicrosoft.Sharepoint.dll Pin
leppie7-Aug-12 3:22
leppie7-Aug-12 3:22 
I swear there was not a single code review done on any part of that 'thing'. If there was, the code reviewer is a complete idiot.

Long story short, was trying to figure how to provide my own 'complex' custom properties in a web part. Easy you say? I thought so too.

My first attempt at it was using a TypeConverter applied on the property (yes a plain ol' C# one), but no, that went no where.
Then I discovered, a TypeConverter will only be instantiated if applied to the type and not the property.
The property being a string, caused me to dish out some silly 'computational object' aka class Category { string Value; }.
But alas, that was fruitless as Sharepoint does not bother calling GetStandardValuesSupported even.
All I want is bloody dropdownlist with a few values!

Then I decided to look at what they invent inside the above-mentioned assembly.

WARNING: Do NOT attempt to do the following without your shrink present and/or a fire truck nearby. People have been known to commit suicide and/or spontaneously combust attempting the following. I take no responsibility after this point.

I opened up Reflector, and yes, they indeed re-invented the wheel and poorly as hell. All the extensibility stuff is marked internal. And hardcoded mostly. So unless I work for Microsoft, tough cookies. (BTW I did the same thing as an exercise many many years back, why this is above their skill level is beyond me. See xacc.propertygrid[^].)

While trying to see what could be done, I came across some bad code, but this one stabbed me in the eye. I will only regain vision in a few weeks the doctor says.
C#
string name;
if ((name = obj.Info) != null && name == "Zone") { ... }

Why on earth could they not just use this:
C#
if (obj.Info == "Zone") { ... }

What self-respecting developer would allow such rubbish to pass a code review or even allowed to be written? Did they think they were optimizing the code? Did they even read the manual?

GeneralRe: Microsoft.Sharepoint.dll Pin
PIEBALDconsult7-Aug-12 3:44
mvePIEBALDconsult7-Aug-12 3:44 
GeneralRe: Microsoft.Sharepoint.dll Pin
Kevin Drzycimski7-Aug-12 19:03
Kevin Drzycimski7-Aug-12 19:03 
GeneralRe: Microsoft.Sharepoint.dll Pin
leppie7-Aug-12 19:46
leppie7-Aug-12 19:46 
GeneralRe: Microsoft.Sharepoint.dll Pin
Eddy Vluggen9-Aug-12 1:09
professionalEddy Vluggen9-Aug-12 1:09 
GeneralRe: Microsoft.Sharepoint.dll Pin
leppie9-Aug-12 3:29
leppie9-Aug-12 3:29 
GeneralThe worst way to name a variable PinPopular
DaintyB3-Aug-12 21:03
DaintyB3-Aug-12 21:03 
GeneralRe: The worst way to name a variable Pin
PIEBALDconsult4-Aug-12 8:29
mvePIEBALDconsult4-Aug-12 8:29 
GeneralRe: The worst way to name a variable Pin
AspDotNetDev4-Aug-12 21:03
protectorAspDotNetDev4-Aug-12 21:03 
GeneralRe: The worst way to name a variable Pin
Andrei Straut6-Aug-12 2:37
Andrei Straut6-Aug-12 2:37 
GeneralRe: The worst way to name a variable Pin
DaintyB4-Aug-12 22:34
DaintyB4-Aug-12 22:34 
GeneralRe: The worst way to name a variable Pin
Andrei Straut6-Aug-12 2:41
Andrei Straut6-Aug-12 2:41 
GeneralRe: The worst way to name a variable Pin
BillW337-Aug-12 8:39
professionalBillW337-Aug-12 8:39 
GeneralRe: The worst way to name a variable Pin
Brisingr Aerowing15-Aug-12 15:14
professionalBrisingr Aerowing15-Aug-12 15:14 
GeneralWhat's the f()?! PinPopular
David MacDermot2-Aug-12 12:57
David MacDermot2-Aug-12 12:57 
GeneralRe: What's the f()?! Pin
OriginalGriff2-Aug-12 21:23
mveOriginalGriff2-Aug-12 21:23 
GeneralRe: What's the f()?! Pin
Christian Brüggemann2-Aug-12 22:24
Christian Brüggemann2-Aug-12 22:24 
GeneralRe: What's the f()?! Pin
Bernhard Hiller3-Aug-12 0:29
Bernhard Hiller3-Aug-12 0:29 

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.