3 ms·
The only objective rule in SOLID is L: "Objects of a superclass should be replaceable with objects of its subclasses without breaking the application." And wh
by BulgarianIdiot 4y ago
The only objective rule in SOLID is L:
"Objects of a superclass should be replaceable with objects of its subclasses without breaking the application."
And when you decipher it, it literally means "all X should act like X", which is already obvious. I.e. if "Y extends X" then Y is also X, so Y should act like X.
The other rules are so vague and subjective, that you can spin them any way around to prove someone's code sucks if you choose so. Which is ideal for selling people books & consultation services. And for Internet arguments.
- mejutoco 4y agoWhen possible, I prefer to do away with objects and have functions with types. X in, Y out.
- diarrhea 4y agoA style I like as well, but methods are exactly that as well, only that `X` is implied, and there's a danger of abusing state (`f(X) -> Y` can and often is pure, whereas the entire point of methods is to be impure (modifying instance state)).
- mejutoco 4y ago> methods are exactly that as well, only that Exactly, except for implicit types and modifying state, indeed. Those are the reasons why I prefer the above.