Jump to content

Loop-switch sequence

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by LeeDoty (talk | contribs) at 19:13, 1 November 2006. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

Loop/Switch sequence

A specific derivative of the spaghetti code AntiPattern which achieves it's crapulence from the encoding of a clear process of steps in a byzantine switch within a loop.

Example of Antipattern

String key; String value; String extension;

for ( int i = 0; i < 3; ++i ) {

 switch( i )
 {
   case 0 :
     key = stream.parse();
     break;
   case 1 :
     value = stream.parse();
     break;
   case 0 :
     extension = stream.parse();
     break;
 }

}

Refactored Solution

String key = stream.parse(); String value = stream.parse(); String extension = stream.parse();