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


    TextWindow.Write("spaghetti ")

    Goto Line6


    TextWindow.Write("an ")

    Goto Line5


    TextWindow.Write("of ")

    Goto Line1


    TextWindow.Write("This is ")

    Goto Line2


    TextWindow.Write("example ")

    Goto Line3





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:   

And go to to download Small Basic and learn all about it!


Small and Basically yours,

   - Ninja Ed & Majed Marji



See Also:

Comments (4)

  1. Like said an old friend: Spaghetti are good only in plates, never in code 🙂

    Good article.

  2. Ha! I just read this comment, Yan. Great point! I'm adding that to the blog post.

  3. I just added the See Also links.

  4. Computers Today (part 1 of 6)…/computers-today.aspx


    CS SPOTLIGHT: Girls in computer programming… why it matters!!!…/cs-spotlight-girls-in-computer-programming-why-it-matters.aspx

    Computational Thinking – Videos & Papers by Jeannette Wing…/computational-thinking-videos-amp-papers-by-jeannette-wing.aspx

Skip to main content