Hacker News new | ask | show | jobs
by partisan 5021 days ago
Just my take but when I think of spaghetti code, I think of code that has side effects. An accessor that also performs some update. A global variable that is updated by many different points in the code. Code that needs to be run in a certain order and only a set number of times OR ELSE. You pull a noodle out and you really just have to wait to see where the effect is felt.

Code that jumps around via gotos and functions in various modules can be mapped out and you can gain an understanding of what the code does, but it is less than ideal. Code that changes its behavior depending on the time and order in which it is run is way more dangerous.

1 comments

No that's mikado code, touch one little part and everything moves.

Spaghetti code is simply very long functions without structure stuffed with long nested branching. I have seen 3000 lines functions, in PHP, and that's even worse, maybe like those "crossing bridge noodle" you can eat in China.