Click here to Skip to main content
15,899,026 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: Another loop bites the dust Pin
PIEBALDconsult26-Jun-08 5:21
mvePIEBALDconsult26-Jun-08 5:21 
GeneralRe: Another loop bites the dust Pin
_Maxxx_26-Jun-08 11:27
professional_Maxxx_26-Jun-08 11:27 
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 
While a select-case statement would probably be better than the cascaded if/else-if, the illustrated construct may not be unreasonable in certain cases where it is expected that the inside of the loop will be pulled out into a separate routine for use as a state machine. Having the code within a for-next loop may be handy during development while the code is being perfected, even if the final construct will be something else.

To be sure, when running on a PC it's often easier to use threads rather than state machines, but state machines can often have a much lower 'footprint'. If an application will require hundreds or thousands of objects each with a multi-way state machine, and all have to be operable concurrently, a select-case state machine may be a reasonable approach. Delegates should be considered as well, since they have some advantages (but also some disadvantages), but state machines are reasonable in simple cases.
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 
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 Pin
_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 

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.