Όλες οι συζητήσεις > Φόρουμ Steam > Help and Tips > Λεπτομέρειες θέματος
Почему Соурс называют Спагетти кодом? \ Why is Source called Spaghetti Code?
Почему именно спагетти? С чем это связанно? \ Why spaghetti? What is the reason for this?
< >
Εμφάνιση 1-3 από 3 σχόλια
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)
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
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.
Τελευταία επεξεργασία από Ettanin; 20 Νοε 2024, 23:03
< >
Εμφάνιση 1-3 από 3 σχόλια
Ανά σελίδα: 1530 50

Όλες οι συζητήσεις > Φόρουμ Steam > Help and Tips > Λεπτομέρειες θέματος
Ημ/νία ανάρτησης: 12 Νοε 2024, 0:25
Αναρτήσεις: 3