Small Basic - Spaghetti Code
What is Spaghetti Code?
As Yan mentioned, an old friend once said, "Spaghetti is best served on your plate, not in your code."
Take a look at this program:
' Shows you how Goto statements can create spaghetti code
Goto Line4
Line1:
TextWindow.Write("spaghetti ")
Goto Line6
Line2:
TextWindow.Write("an ")
Goto Line5
Line3:
TextWindow.Write("of ")
Goto Line1
Line4:
TextWindow.Write("This is ")
Goto Line2
Line5:
TextWindow.Write("example ")
Goto Line3
Line6:
TextWindow.WriteLine("code.")
Output:
This is an example of spaghetti code.
As you can see, it’s hard to track the flow of this program. Like spaghetti, this program’s a tangled mess! Try to trace through the program to see how it works!
Do you have any questions? Ask us! We're full of answers and other fine things!
Head to the Small Basic forum to get the most answers to your questions:
https://social.msdn.microsoft.com/Forums/en-US/smallbasic/threads/
And go to https://blogs.msdn.com/SmallBasic to download Small Basic and learn all about it!
Small and Basically yours,
- Ninja Ed & Majed Marji
================
See Also:
Comments
Anonymous
April 04, 2015
Like said an old friend: Spaghetti are good only in plates, never in code :) Good article.Anonymous
July 21, 2015
Ha! I just read this comment, Yan. Great point! I'm adding that to the blog post.Anonymous
August 18, 2015
I just added the See Also links.Anonymous
January 31, 2016
Computers Today (part 1 of 6) blogs.msdn.com/.../computers-today.aspx ..... CS SPOTLIGHT: Girls in computer programming... why it matters!!! blogs.msdn.com/.../cs-spotlight-girls-in-computer-programming-why-it-matters.aspx ... Computational Thinking - Videos & Papers by Jeannette Wing blogs.msdn.com/.../computational-thinking-videos-amp-papers-by-jeannette-wing.aspx