← Home ← Back to /g/

Thread 105712732

25 posts 8 images /g/
Anonymous No.105712732 [Report] >>105712767 >>105712769 >>105712777 >>105712793 >>105712794 >>105712803 >>105712805 >>105712919 >>105713144 >>105714871 >>105714983 >>105715036 >>105715396 >>105717149 >>105720217
What is "spaghetti code"?
Most people don't seem to have a clear definition.
Anonymous No.105712767 [Report]
>>105712732 (OP)
If i ask you "please remove this feature" and you spend more than 30 seconds looking for its implementation then its spaghetti code
Anonymous No.105712769 [Report]
>>105712732 (OP)
For me, it's code that is strung out (hence the spaghetti metaphor) across a bunch random files with poor structure. For instance, File A calls a method in File B and File B calls a method in File C that updates a state in File A.
Anonymous No.105712777 [Report]
>>105712732 (OP)
unorganized code, messy code that's hard to track.
It's a simple definition.
Anonymous No.105712781 [Report]
nigger = "spaghetti"
print(nigger)
Anonymous No.105712793 [Report]
>>105712732 (OP)
It means it's tangled and complicated like spaghetti, it usually means separation of concerns doesn't exist and you have fuckhuge functions changing state in other smaller functions without any good reason, you can't make small changes without breaking shit easily, a tangled, fragile mess.
Anonymous No.105712794 [Report]
>>105712732 (OP)
Almost every Python project.
Anonymous No.105712803 [Report]
>>105712732 (OP)
I just wish "spaghetti" wasn't synonymous with bad code, because I love spaghetti.
Anonymous No.105712805 [Report] >>105712829 >>105712848
>>105712732 (OP)
Code that's above your IQ level.
Anonymous No.105712829 [Report]
>>105712805
>Code that's below fridge IQ level.
So basically every Python project.
Anonymous No.105712848 [Report]
>>105712805
>Code that's above your IQ level.
this
Anonymous No.105712919 [Report]
>>105712732 (OP)
>Identify how structure [X] feature integrates with structure [Y]
>have to go through structures [W] [V] [T] and [R} to explain it
Anonymous No.105713144 [Report] >>105714882 >>105715473
>>105712732 (OP)
The term spaghetti code was coined before structured programming when all you had was GOTOs. Instead of having well-defined functions or procedures you'd just have code randomly jumping around labels so if you wanted to find out what was going on you had to follow around jumps like following a string of spaghetti.
This type of code in the strictest sense is mostly outdated at this point.
Anonymous No.105713163 [Report]
code that is hard to scale
Anonymous No.105714871 [Report]
>>105712732 (OP)
no overarching structure. following the control flow will lead you in a circle around the whole project
Anonymous No.105714882 [Report]
>>105713144
the modern gotos are cross file references
Anonymous No.105714983 [Report]
>>105712732 (OP)
Italians have an undeserved reputation.
Curry code on the other hand...
Anonymous No.105715036 [Report]
>>105712732 (OP)
You can't understand what it does, you can't properly extend it or fix something without breaking some other, potentially unrelated functionality, you can't reuse any code because it's part of a 2000 line function and does tons of side effects you don't want or need...
And optionally it's just bugged as hell.
Anonymous No.105715396 [Report]
>>105712732 (OP)
Code that someone else wrote
Anonymous No.105715473 [Report]
>>105713144
the term is still somewhat relevant
goto being the "nigger" of programming has only made it very slightly more difficult for retards to make incomprehensible codebases
Anonymous No.105717149 [Report]
>>105712732 (OP)
If you print out the code and draw lines in the margin next to it tracing out the jumps, the lines end up looking all tangled up like spaghetti.
Anonymous No.105717472 [Report]
Pointers
Branch prediction
Flow control
Anonymous No.105718735 [Report]
yours
Anonymous No.105718783 [Report]
Clean code is well structured. You read it and you understand what it does, but spaghetti code is mostly made up of nested functions that abstract each other into oblivion. You read the subroutines and you wont understand them unless you read the other subroutines they are nested into, and to untangle this mess you would rewrite it. This is literally spaghetti
Anonymous No.105720217 [Report]
>>105712732 (OP)
long strings with little to no structure.