Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

How to Port Goto Code to Java

Name: Anonymous 2014-02-09 16:44

Lets see how we can replace an ugly goto with an elegant structured programming constructs.

Given an unstructured loop

line1:
printf("Dijkstra sucks cocks in hell.\n");
goto line1;


Without sacrificing any expressiveness, we can refactor the above code into:

line = 0;
while (line++ > 0)
{
switch(line)
{
case 1: printf("Dijkstra sucks cocks in hell.\n") break;
case 2: line = 1; break;
}
}


Not only did we killed goto, but also gained a way to address lines of code dynamically. I.e. we can compute the next value of "line" variable.

Name: Anonymous 2014-02-09 17:19

It's funny because the dumbass stupid "refactoring" it actually as stupid as the original code.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List