3 ms·
To read code is to understand it. It has little to do with style but more to do with program structure and abstraction layers. I've maintained a PHP codebase wi
by yulapshun 9y ago
To read code is to understand it. It has little to do with style but more to do with program structure and abstraction layers. I've maintained a PHP codebase with some of the worst code I've ever seen. For Example:
1. A function with a few thousand lines of code, accepting dozens of parameter. The body is made up of some nested switch-case and if-else.
2. Instead of using constructors, every class has a static method that does nothing but initialize itself.
3. A class which queries DB and generate HTML, with nearly a hundred public variable. A few levels of sub classes with functions to update those variables.
When a piece of code is not obvious in what it's doing, I'll call it unreadable. In some cases this is acceptable, for example in some clever algorithm (https://en.wikipedia.org/wiki/Fast_inverse_square_root https://en.wikipedia.org/wiki/Fast_inverse_square_root), but it is still what it is, unreadable.