☢Nuke☢ Nov 12, 2024 @ 7:25am
Почему Соурс называют Спагетти кодом? \ Why is Source called Spaghetti Code?
Почему именно спагетти? С чем это связанно? \ Why spaghetti? What is the reason for this?

Something went wrong while displaying this content. Refresh

Error Reference: Community_9721151_
Loading CSS chunk 7561 failed.
(error: https://community.fastly.steamstatic.com/public/css/applications/community/communityawardsapp.css?contenthash=789dd1fbdb6c6b5c773d)
Showing 1-3 of 3 comments
cccrewmalt Nov 21, 2024 @ 5:53am 
Spaghetti code is a pejorative phrase for difficult-to-maintain and unstructured computer source code. Code being developed with poor structure can be due to any of several factors, such as volatile project requirements, lack of programming style rules, and software engineers with insufficient ability or experience. (from wikipedia)
cccrewmalt Nov 21, 2024 @ 5:55am 
Here follows what would be considered a trivial example of spaghetti code in BASIC. The program prints each of the numbers 1 to 100 to the screen along with its square. Indentation is not used to differentiate the various actions performed by the code, and the program's GOTO statements create a reliance on line numbers. The flow of execution from one area to another is harder to predict. Real-world occurrences of spaghetti code are more complex and can add greatly to a program's maintenance costs.

1 i=0
2 i=i+1
3 PRINT i;"squared=";i*i
4 IF i>=100 THEN GOTO 6
5 GOTO 2
6 PRINT "Program Completed."
7 END
Here is the same code written in a structured programming style:

1 FOR i=1 TO 100
2 PRINT i;"squared=";i*i
3 NEXT i
4 PRINT "Program Completed."
5 END
Ettanin Nov 21, 2024 @ 6:03am 
it's called like that because of how the code winds through each other, jumping from function to function with no apparent sign on where it starts and where it ends, like the noodles in spaghetti bolognese.
Last edited by Ettanin; Nov 21, 2024 @ 6:03am
Showing 1-3 of 3 comments
Per page: 1530 50

Date Posted: Nov 12, 2024 @ 7:25am
Posts: 3