Somebody said that when your PHP code and application use global variables then it must be spaghetti code (I assume this). I use WordPress a lot. As far as I know, it's the best thing near great PHP software. And it uses many global variables to interact between its components.
But forget about that, because frankly, that's the only thing I know. So it's completely biased ;D
So, I am just curious, What is the characteristic of spaghetti code?
PS: the only thing I know is WordPress. So, hopefully, maybe this will help somebody give a great answer for somebody who has little experience in developing a full web application on PHP (for example, the Stack Overflow website).
- No modularity (everything in one file, class, module, namespace, package, or whatever your language uses to provide modularity),
- Plenty of
- Poor organization,
- No clear separation of functionality and purpose. (That is, all-encompassing classes or functions)
- Long functions.
- Poor naming.
- No consistent coding style throughout.
- No clear interface contract between implementation and clients of code. (That is, no specification of what the inputs, outputs, pre- and post-conditions of functions are)
- Over-reliance on internals of data structures with little abstraction.
- Functions randomly permute/modify global state without any mention of it in documentation.
- Lack of comments or documentation of non-trivial code.
- Code that is more complicated than it needs to be.
- Lack of reuse. (plenty of duplicated code, a.k.a. copypasta)
- No verification or unit testing (it works on faith).
- Magic numbers.
In essence, a lack of design and forethought, and just a mishmash of hacks slapped together. This applies to any language, not just PHP.
for somebody who has little experience in developing a full web application on PHP (for example, the Stack Overflow website)
Just FYI, but Stack Overflow was not developed with PHP.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki