4 ms·
I'm reminded of Mike Acton's 3 Lies of Object Oriented Programming. Lie 2: Code should be designed around a model of the world. He makes the point that object-o
by MaxBarraclough 6y ago
I'm reminded of Mike Acton's 3 Lies of Object Oriented Programming. Lie 2: Code should be designed around a model of the world. He makes the point that object-oriented models can never really model real-world objects, and shouldn't try to. A game engine may have several ways of representing a chair, for instance (a physics chair, a breakable chair, a static chair, a usable chair). These probably shouldn't share an interface, despite all relating to real-world chairs.
https://youtu.be/rX0ItVEVjHc?t=1154 https://youtu.be/rX0ItVEVjHc?t=1154
- watwut 6y agoOk, but that is argument against idea that died 20 years ago. I cant think of a code written in last years that would try to model real world or blog post that would promoted the idea of modeling real world in classes.
- jcelerier 6y agoA big problem is that university teachers are sometimes stuck 20+ years ago and teach that to students every year - one teacher can hurt a hundred+ students every year. And then we have to undo the damage when they join the workforce. e.g. take this example (sorry guys if you see that, I googled for PassagerStandard) : https://github.com/sbrouard/public-transport-manager/tree/master/TD6/FabriqueTec/src https://github.com/sbrouard/public-transport-manager/tree/ma... - during a whole semester you model a freakin bus with different "passengers" - "standardpassenger", "stressedpassenger", and the bus stops also have behaviour modeled by objects like "CarefulStop", "PoliteStop", etc... The whole thing is basically worst-case OOP where everything is modeled by an interconnected mess of objects and every exercise becomes just worse and worse than the previous. And students have to learn to do that every year and are judged on how "well" they did apply OOP techniques in order to graduate. (note to reader - the authors of this repos are students who had to implement this mess, not the authors of this exercice)
- MaxBarraclough 6y ago> "passengers" - "standardpassenger", "stressedpassenger" That sounds pretty terrible. I presume passengers are unable to change state? Or is the instance replaced with an instance of another class?