Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

What Causes Spaghetti Code? (Not the GOTO)

Hugh Pickens writes (1984118) writes | about 2 years ago

Programming 0

Hugh Pickens writes writes "Michael O'Church writes that spaghetti code is an especially virulent but specific kind of bad code related to the dreaded and mostly archaic goto statement, a simple and powerful control flow mechanism that makes it difficult to reason about code, because if control can bounce about a program, one cannot make guarantees about what state a program is in when it executes a specific piece of code. Goto statements were once the leading cause of spaghetti code, but goto has fallen so far out of favor that it’s a non-concern. "Now the culprit is something else entirely: the modern bastardization of object-oriented programming," writes O'Church adding that inheritance is an especially bad culprit, and so is premature abstraction: using a parameterized generic with only one use case in mind, or adding unnecessary parameters. Object-oriented programming, originally designed to prevent spaghetti code, has become one of the worst sources of it (through a “design pattern” ridden misunderstanding of it). An “object” can mix code and data freely and conform to any number of interfaces, while a class can be subclassed freely about the program. "There’s a lot of power in object-oriented programming, and when used with discipline, it can be very effective. But most programmers don’t handle it well, and it seems to turn to spaghetti over time," concludes O'Church. "I recognize that this claim – that OOP as practiced is spaghetti code – is not a viewpoint without controversy. Nor was it without controversy, at one time, that goto was considered harmful.""

cancel ×

0 comments

Sorry! There are no comments related to the filter you selected.

Check for New Comments
Slashdot Login

Need an Account?

Forgot your password?

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>