REASONING: One of the biggest factors to spaghetti code are global variables. For example, look at this code:
This code is a prime example of how spaghetti code is formed. doSomething() now affects other classes and variables, so that can cause confusion to anyone using doSomething() as to why the global constant has changed it's value!
The better way to do the above code that isn't a delicious italian product is like this:
This new technique produces completely identical code, adds more versality as now doSomething() can be used anywhere, and reduces confusion. All because you got rid of global constants!
Magic Constants
A magic constant is a literal in your code that doesn't have any meaning or explanation.
Instead of embedding literals into code, create a constant at the top of the file to reduce spatghetti code and allow for more configurability.