Knowledge

Spaghetti code

Source 📝

893: 879: 196:
If, in fixing up an error, you wanted to insert some omitted instructions then you took the immediately preceding instruction and replaced it by a transfer to some empty space. There you put in the instruction you just wrote over, added the instructions you wanted to insert, and then followed by a
197:
transfer back to the main program. Thus the program soon became a sequence of jumps of the control to strange places. When, as almost always happens, there were errors in the corrections you then used the same trick again, using some other available space. As a result
1177:
Guy Lewis Steele. 1977. Macaroni is better than spaghetti. In Proceedings of the 1977 symposium on Artificial intelligence and programming languages. Association for Computing Machinery, New York, NY, USA, 60–66.
201:
Why not simply insert them in the run of instructions? Because then you would have to go over the entire program and change all the addresses which referred to any of the moved instructions! Anything but
481:
statement encourages arbitrary flow control. Though this example is small, real world programs are composed of many lines of code and are difficult to maintain when written in a spaghetti code fashion.
1501: 260:. 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 946: 270:. 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. 1127:
Abbes, M.; Khomh, F.; Gueheneuc, Y. G.; Antoniol, G. (2011). "An Empirical Study of the Impact of Two Antipatterns, Blob and Spaghetti Code, on Program Comprehension".
1343: 1535: 1347: 84: 175:
was described as forcing the programmer to "produce understandable, instead of spaghetti code", because of its restrictive exception propagation mechanism.
1492: 1074:
Moha, N.; Gueheneuc, Y. G.; Duchien, L.; Meur, A. F. Le (January 2010). "DECOR: A Method for the Specification and Detection of Code and Design Smells".
983: 1540: 248:
code refers to code whose layers are so complicated and intertwined that making a change in one layer would necessitate changes in all other layers.
1498: 912: 104:
is written in a procedural style, such as by creating classes whose methods are overly long and messy, or forsaking object-oriented concepts like
1530: 1395:. Advanced Information Systems Engineering. Notes on Numerical Fluid Mechanics and Multidisciplinary Design. Vol. 498. pp. 561–578. 1408: 1308: 1225: 1200: 1154: 1036: 957: 72:
constructs, resulting in convoluted and unmaintainable programs, is often called spaghetti code. Such code has a complex and tangled
924: 1295:. Ada – Europe '93 (Proceedings). Lecture Notes in Computer Science. Vol. 688. Springer Berlin Heidelberg. pp. 142–152. 48:. Code being developed with poor structure can be due to any of several factors, such as volatile project requirements, lack of 105: 116:
It is not clear when the phrase spaghetti code came into common usage; however, several references appeared in 1977 including
1370: 240: 132:
described programs that "have the same clean logical structure as a plate of spaghetti", a phrase repeated in the 1979 book
1477: 224: 884: 220: 101: 257: 172: 998: 465:
The program jumps from one area to another, but this jumping is formal and more easily predictable, because
1525: 1132: 1083: 383: 108:. The presence of this form of spaghetti code can significantly reduce the comprehensibility of a system. 69: 192:
described in his lectures the etymology of the term in the context of early programming in binary codes:
1337: 1291:
Schwille, Jürgen (1993). "Use and abuse of exceptions — 12 guidelines for proper exception handling".
38: 1137: 1088: 236: 199:
the control path of the program through storage soon took on the appearance of a can of spaghetti.
1414: 1258: 1160: 1109: 898: 1404: 1366: 1304: 1221: 1196: 1150: 1101: 1032: 129: 121: 73: 53: 49: 1396: 1296: 1250: 1142: 1093: 1510: 1505: 1481: 1466: 906: 189: 149: 1386:
De Troyer, O. (13 May 1991). Andersen, Rudolf; Bubenko, Janis A.; Sølvberg, Arne (eds.).
984:"Pronouns and procedural meaning: The relevance of spaghetti code and paranoid delusion" 1278:
Structured programming for the COBOL programmer: design, documentation, coding, testing
918: 1462: 1387: 1241:
Boehm, Barry W. (May 1988). "A spiral model of software development and enhancement".
892: 1519: 1433: 17: 1418: 1164: 1113: 1262: 474: 97: 227:
that are easy to understand in isolation, but difficult to understand as a whole.
1486: 1471: 1389:
The OO-binary relationship model : A truly object oriented conceptual model
878: 267: 137: 45: 1400: 874: 470: 34: 1300: 1105: 256:
Here follows what would be considered a trivial example of spaghetti code in
93:
was used to describe older programs having "fragmented and scattered files".
77: 1031:(5th ed. . ed.). Hoboken, NJ: J. Wiley & Sons. pp. 235–236. 1146: 485:
Here is another example of Spaghetti code with embedded GOTO statements.
466: 42: 1179: 1097: 991:
Oxford University Working Papers in Linguistics, Philology and Phonetics
1129:
2011 15th European Conference on Software Maintenance and Reengineering
245: 216: 183: 1024: 148:, which lacked planning and eventually led to the development of the 1489:
separating out a bowl full of code from one class into seven classes
1434:"Teaching Good Practices In Software Engineering by Counterexamples" 182:
titled "BASICally speaking...FORTRAN bytes!!", the author described
1473:
We don't know where to GOTO if we don't know where we've COME FROM
1324:
MTSBS (March–April 1981). "BASICally speaking...FORTRAN bytes!!".
1499:
Programming Pasta - Spaghetti, Lasagna, Ravioli and Macaroni Code
1254: 1193:
A primer on disciplined programming using PL/I, PL/CS, and PL/CT
262: 126:
A primer on disciplined programming using PL/I, PL/CS, and PL/CT
65: 76:, resulting in a program flow that is conceptually like a 144:, the term is used to describe the older practice of the 186:
stating that "it consists entirely of spaghetti code".
164:
as synonyms to describe poorly structured source code.
909:, a piece of software with no perceivable architecture 142:
A spiral model of software development and enhancement
1432:
Tomov, Latchezar; Ivanova, Valentina (October 2014).
1487:
Refactoring Java spaghetti code into Java bento code
1475:
by R. Lawrence Clark from DATAMATION, December, 1973
915:, a competition to produce pleasingly obscure C code 1059:United States National Bureau of Standards (1980). 223:. It describes code that comprises well-structured 1438:Computer Science and Education in Computer Science 947:"Straightening spaghetti-code with refactoring?" 1465:. The classic repudiation of spaghetti code by 493:"How many numbers should be sorted? " 194: 154:Structured programming for the COBOL programmer 8: 1342:: CS1 maint: multiple names: authors list ( 1493:Objects and Frameworks – Taking a Step Back 1063:. United States Government Printing Office. 1346:) CS1 maint: numeric names: authors list ( 954:Software Engineering Research and Practice 85:United States National Bureau of Standards 1136: 1087: 1076:IEEE Transactions on Software Engineering 56:with insufficient ability or experience. 1363:The Art of Doing Science and Engineering 27:Software source code with poor structure 937: 913:International Obfuscated C Code Contest 1536:Pejorative terms related to technology 1335: 1216:Conway, Richard; Gries, David (1979). 178:In a 1981 computer languages spoof in 1180:https://doi.org/10.1145/800228.806933 1029:Java Concepts for AP Computer Science 7: 156:, author Paul Noll uses the phrases 96:Spaghetti code can also describe an 382:Here is the same code written in a 1463:Go To Statement Considered Harmful 1061:ASTM special technical publication 982:Cram, David; Hedley, Paul (2005). 25: 1293:Lecture Notes in Computer Science 925:The Elements of Programming Style 118:Macaroni is Better Than Spaghetti 1541:Metaphors referring to spaghetti 891: 877: 266:statements create a reliance on 1220:(3rd ed.). Little, Brown. 1218:An Introduction to Programming 826:"The sorted list is" 454:"Program Completed." 371:"Program Completed." 241:Layer (object-oriented design) 134:An Introduction to Programming 1: 1531:Software engineering folklore 1280:. M. Murach & Associates. 83:In a 1980 publication by the 1511:Pasta Theory of Programming 885:Computer programming portal 221:object-oriented programming 219:code is a term specific to 1557: 234: 1401:10.1007/3-540-54059-8_104 1361:Hamming, Richard (1996). 997:: 187–210. Archived from 956:: 846–852. Archived from 1365:. Taylor & Francis. 1301:10.1007/3-540-56802-6_12 1191:Conway, Richard (1978). 487: 388: 272: 37:phrase for difficult-to- 1195:. Winthrop Publishers. 1025:"Chapter 6 - Iteration" 1023:Horstmann, Cay (2008). 80:, twisted and tangled. 68:statements rather than 945:Markus, Pizka (2004). 384:structured programming 204: 70:structured programming 18:Spaghetti programming 1326:The Michigan Technic 1147:10.1109/CSMR.2011.24 1131:. pp. 181–190. 424:"squared=" 317:"squared=" 180:The Michigan Technic 140:. In the 1988 paper 136:he co-authored with 102:object-oriented code 1276:Noll, Paul (1977). 1098:10.1109/TSE.2009.50 538:"NUMBER:" 237:Architectural layer 152:. In the 1979 book 124:. In the 1978 book 64:Code that overuses 1504:2023-01-21 at the 1480:2018-07-16 at the 899:Engineering portal 568:'Calculations: 146:code and fix model 54:software engineers 1410:978-3-319-98176-5 1310:978-3-540-56802-5 1227:978-0-316-15414-7 1202:978-0-87626-712-7 1156:978-1-61284-259-2 1038:978-0-470-18160-7 90:spaghetti program 78:bowl of spaghetti 74:control structure 50:programming style 41:and unstructured 16:(Redirected from 1548: 1495:by Brian Rinaldi 1450: 1449: 1447: 1445: 1429: 1423: 1422: 1394: 1383: 1377: 1376: 1358: 1352: 1351: 1341: 1333: 1321: 1315: 1314: 1288: 1282: 1281: 1273: 1267: 1266: 1238: 1232: 1231: 1213: 1207: 1206: 1188: 1182: 1175: 1169: 1168: 1140: 1124: 1118: 1117: 1091: 1071: 1065: 1064: 1056: 1050: 1049: 1047: 1045: 1020: 1014: 1013: 1011: 1009: 1003: 988: 979: 973: 972: 970: 968: 962: 951: 942: 901: 896: 895: 887: 882: 881: 866: 863: 860: 857: 854: 851: 848: 845: 842: 839: 836: 833: 830: 827: 824: 821: 818: 815: 812: 809: 806: 803: 800: 797: 794: 791: 788: 785: 782: 779: 776: 773: 770: 767: 764: 761: 758: 755: 752: 749: 746: 743: 740: 737: 734: 731: 728: 725: 722: 719: 716: 713: 710: 707: 704: 701: 698: 695: 692: 689: 686: 683: 680: 677: 674: 671: 668: 665: 662: 659: 656: 653: 650: 647: 644: 641: 638: 635: 632: 629: 626: 623: 620: 617: 614: 611: 608: 605: 602: 599: 596: 593: 590: 587: 584: 581: 578: 575: 572: 569: 566: 563: 560: 557: 554: 551: 548: 545: 542: 539: 536: 533: 530: 527: 524: 521: 518: 515: 512: 509: 506: 503: 500: 497: 494: 491: 461: 458: 455: 452: 449: 446: 443: 440: 437: 434: 431: 428: 425: 422: 419: 416: 413: 410: 407: 404: 401: 398: 395: 392: 378: 375: 372: 369: 366: 363: 360: 357: 354: 351: 348: 345: 342: 339: 336: 333: 330: 327: 324: 321: 318: 315: 312: 309: 306: 303: 300: 297: 294: 291: 288: 285: 282: 279: 276: 265: 169:Ada – Europe '93 21: 1556: 1555: 1551: 1550: 1549: 1547: 1546: 1545: 1516: 1515: 1506:Wayback Machine 1482:Wayback Machine 1467:Edsger Dijkstra 1459: 1454: 1453: 1443: 1441: 1431: 1430: 1426: 1411: 1392: 1385: 1384: 1380: 1373: 1360: 1359: 1355: 1334: 1323: 1322: 1318: 1311: 1290: 1289: 1285: 1275: 1274: 1270: 1240: 1239: 1235: 1228: 1215: 1214: 1210: 1203: 1190: 1189: 1185: 1176: 1172: 1157: 1138:10.1.1.294.1685 1126: 1125: 1121: 1089:10.1.1.156.1524 1073: 1072: 1068: 1058: 1057: 1053: 1043: 1041: 1039: 1022: 1021: 1017: 1007: 1005: 1004:on 6 March 2018 1001: 986: 981: 980: 976: 966: 964: 963:on 5 March 2018 960: 949: 944: 943: 939: 934: 907:Big ball of mud 897: 890: 883: 876: 873: 868: 867: 864: 861: 858: 855: 852: 849: 846: 843: 840: 837: 834: 831: 828: 825: 822: 819: 816: 813: 810: 807: 804: 801: 798: 795: 792: 789: 786: 783: 780: 777: 774: 771: 768: 765: 762: 759: 756: 753: 750: 747: 744: 741: 738: 735: 732: 729: 726: 723: 720: 717: 714: 711: 708: 705: 702: 699: 696: 693: 690: 687: 684: 681: 678: 675: 672: 669: 666: 663: 660: 657: 654: 651: 648: 645: 642: 639: 636: 633: 630: 627: 624: 621: 618: 615: 612: 609: 606: 603: 600: 597: 594: 591: 588: 585: 582: 579: 576: 573: 570: 567: 564: 561: 558: 555: 552: 549: 546: 543: 540: 537: 534: 531: 528: 525: 522: 519: 516: 513: 510: 507: 504: 501: 498: 495: 492: 489: 463: 462: 459: 456: 453: 450: 447: 444: 441: 438: 435: 432: 429: 426: 423: 420: 417: 414: 411: 408: 405: 402: 399: 396: 393: 390: 380: 379: 376: 373: 370: 367: 364: 361: 358: 355: 352: 349: 346: 343: 340: 337: 334: 331: 328: 325: 322: 319: 316: 313: 310: 307: 304: 301: 298: 295: 292: 289: 286: 283: 280: 277: 274: 261: 254: 243: 233: 214: 209: 207:Related phrases 190:Richard Hamming 150:waterfall model 114: 62: 28: 23: 22: 15: 12: 11: 5: 1554: 1552: 1544: 1543: 1538: 1533: 1528: 1518: 1517: 1514: 1513: 1508: 1496: 1490: 1484: 1469: 1458: 1457:External links 1455: 1452: 1451: 1424: 1409: 1378: 1371: 1353: 1316: 1309: 1283: 1268: 1233: 1226: 1208: 1201: 1183: 1170: 1155: 1119: 1066: 1051: 1037: 1015: 974: 936: 935: 933: 930: 929: 928: 921: 919:Technical debt 916: 910: 903: 902: 888: 872: 869: 488: 389: 273: 253: 250: 232: 229: 213: 210: 208: 205: 158:spaghetti code 130:Richard Conway 113: 110: 61: 58: 31:Spaghetti code 26: 24: 14: 13: 10: 9: 6: 4: 3: 2: 1553: 1542: 1539: 1537: 1534: 1532: 1529: 1527: 1526:Anti-patterns 1524: 1523: 1521: 1512: 1509: 1507: 1503: 1500: 1497: 1494: 1491: 1488: 1485: 1483: 1479: 1476: 1474: 1470: 1468: 1464: 1461: 1460: 1456: 1439: 1435: 1428: 1425: 1420: 1416: 1412: 1406: 1402: 1398: 1391: 1390: 1382: 1379: 1374: 1368: 1364: 1357: 1354: 1349: 1345: 1339: 1331: 1327: 1320: 1317: 1312: 1306: 1302: 1298: 1294: 1287: 1284: 1279: 1272: 1269: 1264: 1260: 1256: 1252: 1248: 1244: 1243:IEEE Computer 1237: 1234: 1229: 1223: 1219: 1212: 1209: 1204: 1198: 1194: 1187: 1184: 1181: 1174: 1171: 1166: 1162: 1158: 1152: 1148: 1144: 1139: 1134: 1130: 1123: 1120: 1115: 1111: 1107: 1103: 1099: 1095: 1090: 1085: 1081: 1077: 1070: 1067: 1062: 1055: 1052: 1040: 1034: 1030: 1026: 1019: 1016: 1000: 996: 992: 985: 978: 975: 959: 955: 948: 941: 938: 931: 927: 926: 922: 920: 917: 914: 911: 908: 905: 904: 900: 894: 889: 886: 880: 875: 870: 486: 483: 480: 476: 472: 468: 387: 385: 271: 269: 264: 259: 251: 249: 247: 242: 238: 230: 228: 226: 222: 218: 211: 206: 203: 200: 193: 191: 187: 185: 181: 176: 174: 170: 165: 163: 159: 155: 151: 147: 143: 139: 135: 131: 127: 123: 119: 111: 109: 107: 103: 99: 94: 92: 91: 87:, the phrase 86: 81: 79: 75: 71: 67: 59: 57: 55: 51: 47: 44: 40: 36: 32: 19: 1472: 1442:. Retrieved 1440:(1): 397–405 1437: 1427: 1388: 1381: 1362: 1356: 1338:cite journal 1329: 1325: 1319: 1292: 1286: 1277: 1271: 1255:10.1109/2.59 1249:(2): 61–72. 1246: 1242: 1236: 1217: 1211: 1192: 1186: 1173: 1128: 1122: 1082:(1): 20–36. 1079: 1075: 1069: 1060: 1054: 1042:. Retrieved 1028: 1018: 1006:. Retrieved 999:the original 994: 990: 977: 965:. Retrieved 958:the original 953: 940: 923: 484: 478: 477:whereas the 475:flow control 464: 381: 268:line numbers 255: 244: 231:Lasagna code 215: 212:Ravioli code 198: 195: 188: 179: 177: 171:conference, 168: 166: 161: 157: 153: 145: 141: 133: 125: 117: 115: 106:polymorphism 98:anti-pattern 95: 89: 88: 82: 63: 30: 29: 138:David Gries 52:rules, and 46:source code 1520:Categories 1372:9056995006 932:References 235:See also: 162:rat's nest 122:Guy Steele 35:pejorative 1133:CiteSeerX 1106:0098-5589 1084:CiteSeerX 1044:2 January 471:functions 467:for loops 100:in which 1502:Archived 1478:Archived 1419:10894568 1165:14152638 1114:14767901 871:See also 473:provide 252:Examples 43:computer 39:maintain 1444:5 March 1263:1781829 1008:5 March 967:5 March 386:style: 246:Lasagna 225:classes 217:Ravioli 184:FORTRAN 167:In the 112:History 60:Meaning 1417:  1407:  1369:  1307:  1261:  1224:  1199:  1163:  1153:  1135:  1112:  1104:  1086:  1035:  1415:S2CID 1393:(PDF) 1259:S2CID 1161:S2CID 1110:S2CID 1002:(PDF) 987:(PDF) 961:(PDF) 950:(PDF) 847:PRINT 823:PRINT 820:C330: 664:F230: 652:I220: 580:E180: 547:INPUT 535:PRINT 490:INPUT 451:PRINT 415:PRINT 368:PRINT 341:>= 308:PRINT 258:BASIC 202:that! 33:is a 1446:2018 1405:ISBN 1367:ISBN 1348:link 1344:link 1332:(4). 1305:ISBN 1222:ISBN 1197:ISBN 1178:DOI: 1151:ISBN 1102:ISSN 1046:2017 1033:ISBN 1010:2018 969:2018 862:NEXT 817:I220 814:GOTO 811:E180 808:GOTO 805:THEN 799:> 775:F230 772:GOTO 769:THEN 763:> 715:SWAP 712:THEN 697:> 625:C330 622:GOTO 619:THEN 562:NEXT 479:goto 469:and 442:NEXT 359:GOTO 350:GOTO 347:THEN 263:GOTO 239:and 160:and 66:GOTO 1397:doi 1297:doi 1251:doi 1143:doi 1094:doi 829:FOR 589:INT 517:FOR 502:DIM 460:END 409:100 394:FOR 377:END 344:100 173:Ada 120:by 1522:: 1436:. 1413:. 1403:. 1340:}} 1336:{{ 1330:99 1328:. 1303:. 1257:. 1247:21 1245:. 1159:. 1149:. 1141:. 1108:. 1100:. 1092:. 1080:36 1078:. 1027:. 995:10 993:. 989:. 952:. 841:TO 793:IF 757:IF 727:), 682:IF 607:IF 529:TO 406:TO 335:IF 128:, 1448:. 1421:. 1399:: 1375:. 1350:) 1313:. 1299:: 1265:. 1253:: 1230:. 1205:. 1167:. 1145:: 1116:. 1096:: 1048:. 1012:. 971:. 865:i 859:) 856:i 853:( 850:n 844:T 838:1 835:= 832:i 802:D 796:E 790:1 787:+ 784:E 781:= 778:E 766:0 760:f 754:C 751:- 748:f 745:= 742:f 739:) 736:g 733:( 730:n 724:f 721:( 718:n 709:) 706:g 703:( 700:n 694:) 691:f 688:( 685:n 679:C 676:+ 673:f 670:= 667:g 661:E 658:= 655:f 649:1 646:= 643:E 640:C 637:- 634:T 631:= 628:D 616:0 613:= 610:C 604:) 601:2 598:/ 595:C 592:( 586:= 583:C 577:T 574:= 571:C 565:i 559:) 556:i 553:( 550:n 544:i 541:; 532:T 526:1 523:= 520:i 514:) 511:T 508:( 505:n 499:T 496:; 457:5 448:4 445:i 439:3 436:i 433:* 430:i 427:; 421:; 418:i 412:2 403:1 400:= 397:i 391:1 374:7 365:6 362:2 356:5 353:6 338:i 332:4 329:i 326:* 323:i 320:; 314:; 311:i 305:3 302:1 299:+ 296:i 293:= 290:i 287:2 284:0 281:= 278:i 275:1 20:)

Index

Spaghetti programming
pejorative
maintain
computer
source code
programming style
software engineers
GOTO
structured programming
control structure
bowl of spaghetti
United States National Bureau of Standards
anti-pattern
object-oriented code
polymorphism
Guy Steele
Richard Conway
David Gries
waterfall model
Ada
FORTRAN
Richard Hamming
Ravioli
object-oriented programming
classes
Architectural layer
Layer (object-oriented design)
Lasagna
BASIC
GOTO

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.