Click here to Skip to main content
15,913,587 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: Sometimes I wonder about code comments Pin
wout de zeeuw6-Mar-13 14:31
wout de zeeuw6-Mar-13 14:31 
GeneralThis is the kind of productivity you get when you pay by lines of code PinPopular
Rob Grainger18-Feb-13 1:18
Rob Grainger18-Feb-13 1:18 
JokeRe: This is the kind of productivity you get when you pay by lines of code PinPopular
AspDotNetDev18-Feb-13 9:32
protectorAspDotNetDev18-Feb-13 9:32 
GeneralRe: This is the kind of productivity you get when you pay by lines of code Pin
Sander Rossel18-Feb-13 20:45
professionalSander Rossel18-Feb-13 20:45 
GeneralRe: This is the kind of productivity you get when you pay by lines of code Pin
OriginalGriff19-Feb-13 4:59
mveOriginalGriff19-Feb-13 4:59 
GeneralRe: This is the kind of productivity you get when you pay by lines of code Pin
Bernhard Hiller19-Feb-13 5:05
Bernhard Hiller19-Feb-13 5:05 
GeneralRe: This is the kind of productivity you get when you pay by lines of code Pin
fjdiewornncalwe20-Feb-13 3:13
professionalfjdiewornncalwe20-Feb-13 3:13 
GeneralRe: This is the kind of productivity you get when you pay by lines of code Pin
wout de zeeuw6-Mar-13 14:31
wout de zeeuw6-Mar-13 14:31 
GeneralIF-free codes Pin
SarK0Y15-Feb-13 12:34
SarK0Y15-Feb-13 12:34 
GeneralRe: IF-free codes PinPopular
Paul Conrad15-Feb-13 12:54
professionalPaul Conrad15-Feb-13 12:54 
GeneralRe: IF-free codes Pin
SarK0Y15-Feb-13 13:06
SarK0Y15-Feb-13 13:06 
GeneralRe: IF-free codes Pin
Gary Wheeler19-Feb-13 0:17
Gary Wheeler19-Feb-13 0:17 
GeneralRe: IF-free codes Pin
Chad3F20-Feb-13 19:03
Chad3F20-Feb-13 19:03 
GeneralRe: IF-free codes Pin
dusty_dex19-Feb-13 5:54
dusty_dex19-Feb-13 5:54 
GeneralRe: IF-free codes Pin
DarthDana19-Mar-13 10:09
professionalDarthDana19-Mar-13 10:09 
GeneralRe: IF-free codes Pin
RonDsz19-Feb-13 9:36
RonDsz19-Feb-13 9:36 
JokeRe: IF-free codes Pin
Brisingr Aerowing25-Feb-13 14:58
professionalBrisingr Aerowing25-Feb-13 14:58 
GeneralRe: IF-free codes Pin
PIEBALDconsult15-Feb-13 19:27
mvePIEBALDconsult15-Feb-13 19:27 
JokeRe: IF-free codes PinPopular
Brisingr Aerowing15-Feb-13 19:47
professionalBrisingr Aerowing15-Feb-13 19:47 
GeneralRe: IF-free codes Pin
Monaco.Bavarian18-Feb-13 19:50
Monaco.Bavarian18-Feb-13 19:50 
GeneralRe: IF-free codes Pin
KP Lee19-Feb-13 11:36
KP Lee19-Feb-13 11:36 
AnswerRe: IF-free codes Pin
Monaco.Bavarian19-Feb-13 19:07
Monaco.Bavarian19-Feb-13 19:07 
GeneralRe: IF-free codes Pin
KP Lee19-Feb-13 21:51
KP Lee19-Feb-13 21:51 
I've never encountered a business case that needed that many branches for a single set of conditions. I have encountered "cute" programmers who thought that unnecessary complexity made sense and did things that didn't make sense to me. (Throwing unrelated logic together in one big if-else if- cluster.) I'm also wondering if branching might help both the readability and maintainability of the logic and if that supercedes efficiency if it meets the business logic?
IE
C#
if ( expression1) Condition1();
else NotCondition1();
...
void Condition1()
{
  if ( expression2) Condition2();
  else NotCondition2();
}
void NotCondition1()
{
  if ( expression5) Condition3();
  else NotCondition3();
}

void Condition2()
{
    if ( expression3) {
      ...
    } else {
      ...
    }
}
etc.
I'm not all that convinced that branching to routines won't be performant as well as more readable.

I just recently read about a bubble sort routine. OK, old news + inexperienced developer = time to move on. One of the respondents liked how easy it was to read and how efficient it was. Man, I can't let that misinformation go. I explained how it rated as N^2 efficiency. (IE double the number of fields will quadruple the time to compute.) 200K records sorted in over 2 minutes. (The posted program sorted 11 hardcoded values in an int[] array. Of course that would be fast.) I calculated a million numbers would sort in about 56 minutes. I ran 50 million numbers through a binary sort process in just over 14 seconds. The time consistently increased by a second for just under 3 million numbers being added.
A LOT of if tests being done in recursive routine calls. Slightly slower than List<int>'s built-in Sort routine, List blows up faster with memory problems as the numbers increase. (Can't do 20 million int[] and 20 million List<int>)
GeneralRe: IF-free codes Pin
Stefan_Lang19-Feb-13 0:30
Stefan_Lang19-Feb-13 0:30 
GeneralRe: IF-free codes Pin
JHubSharp19-Feb-13 4:14
JHubSharp19-Feb-13 4:14 

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.