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.""
DEAL: For $25 - Add A Second Phone Number To Your Smartphone for life! Use promo code SLASHDOT25. Also, Slashdot's Facebook page has a chat bot now. Message it for stories and more. Check out the new SourceForge HTML5 internet speed test! ×