Click here to Skip to main content
15,923,226 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: Another loop bites the dust Pin
Spacix One28-Jun-08 5:20
Spacix One28-Jun-08 5:20 
GeneralClever For-loop Pin
Oyvind Bratland24-Jun-08 3:04
Oyvind Bratland24-Jun-08 3:04 
GeneralRe: Clever For-loop Pin
James Simpson24-Jun-08 3:37
James Simpson24-Jun-08 3:37 
GeneralRe: Clever For-loop Pin
Oyvind Bratland24-Jun-08 3:51
Oyvind Bratland24-Jun-08 3:51 
JokeRe: Clever For-loop Pin
leppie24-Jun-08 6:06
leppie24-Jun-08 6:06 
GeneralRe: Clever For-loop Pin
supercat924-Jun-08 6:30
supercat924-Jun-08 6:30 
GeneralRe: Clever For-loop Pin
Tristan Rhodes24-Jun-08 23:05
Tristan Rhodes24-Jun-08 23:05 
GeneralRe: Clever For-loop Pin
supercat925-Jun-08 6:26
supercat925-Jun-08 6:26 
Tristan Rhodes wrote:
Where in the original WTF did it mention a problem that would require State Machines or Threads to solve?


My point was that there are circumstances where code like that illustrated may be useful. While it is true that there was nothing to indicate that such circumstances applied here, I would not wish to condemn code without knowing that such circumstances did not apply.

BTW, another circumstance where such code may be useful is in cases where the loop will evolve into something like:
for i=1 to 5
  .. do some stuff in every case
  if i=1 then
    .. handle first case
  else if i=2 then
    .. handle second case
  ... etc
  end if
  .. do some more stuff in every case

In many circumstances, that style of code could be handled better by putting the different parts into subroutines and just calling them:
everycase_prep()
.. handle first case
everycase_cleanup()
everycase_prep()
.. handle second case
everycase_cleanup()

In some cases, however, the prep and cleanup would need to share many local variables, thus requiring either long parameter lists or awkward class constructs.
GeneralRe: Clever For-loop Pin
John R. Shaw24-Jun-08 9:20
John R. Shaw24-Jun-08 9:20 
JokeRe: Clever For-loop Pin
Ariel Kazeed26-Jun-08 23:38
Ariel Kazeed26-Jun-08 23:38 
GeneralRe: Clever For-loop Pin
Paul Conrad1-Jul-08 19:31
professionalPaul Conrad1-Jul-08 19:31 
GeneralCobol Horror PinPopular
_Maxxx_23-Jun-08 17:23
professional_Maxxx_23-Jun-08 17:23 
JokeRe: Cobol Horror Pin
Nelek23-Jun-08 21:55
protectorNelek23-Jun-08 21:55 
JokeRe: Cobol Horror Pin
CPallini23-Jun-08 22:15
mveCPallini23-Jun-08 22:15 
GeneralRe: Cobol Horror Pin
VentsyV24-Jun-08 5:22
VentsyV24-Jun-08 5:22 
GeneralRe: Cobol Horror Pin
_Maxxx_24-Jun-08 11:31
professional_Maxxx_24-Jun-08 11:31 
GeneralRe: Cobol Horror Pin
RichardM126-Jun-08 15:01
RichardM126-Jun-08 15:01 
GeneralRe: Cobol Horror Pin
_Maxxx_26-Jun-08 15:04
professional_Maxxx_26-Jun-08 15:04 
GeneralRe: Cobol Horror Pin
BillW3329-Aug-08 9:02
professionalBillW3329-Aug-08 9:02 
GeneralRe: Cobol Horror Pin
leppie24-Jun-08 6:11
leppie24-Jun-08 6:11 
GeneralRe: Cobol Horror Pin
_Maxxx_24-Jun-08 12:28
professional_Maxxx_24-Jun-08 12:28 
GeneralRe: Cobol Horror Pin
leppie24-Jun-08 22:55
leppie24-Jun-08 22:55 
GeneralRe: Cobol Horror Pin
_Maxxx_25-Jun-08 12:18
professional_Maxxx_25-Jun-08 12:18 
GeneralRe: Cobol Horror Pin
Pete O'Hanlon27-Jun-08 11:56
mvePete O'Hanlon27-Jun-08 11:56 
GeneralRe: Cobol Horror Pin
Paul Conrad1-Jul-08 19:31
professionalPaul Conrad1-Jul-08 19:31 

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.