Oop stackexchange

Example of not understanding category mistake
https://cseducators.stackexchange.com/questions/146/what-is-a-good-analogy-for-the-object-oriented-paradigm The classic "cats are felines, felines are mammals, mammals are animals" hierarchy only gets you so far and provides a very poor and rigid understanding of Object Oriented Programming that causes new programmers to tend towards Do-Everything Objects (where do float planes fit in the "boat extend vehicle, plane extends vehicle" hierarchy? Clearly the only solution is to make all vehicles drive, fly, and float and just disable the ones we don't need!) rather than through a composition of interfaces (say, FloatPlane extends BaseAircraft implements IWaterCraft).

I know that sort of thinking messed me up for a number of years. Heck, I'm still recovering from it: I still can't read inline lambda expressions natively, I have to decompose them, and it often takes me several minutes. Same thing goes for creating interfaces, I often have to go the "cats are felines" road until I hit a spot where I realize "I want to use this code on both cats AND cars" because they both share some property that doesn't exist in the common class (and shouldn't) and I have to refactor.


 * Your third-and-second-to-last paragraphs are really important. The "zoo" type introductions to OO are, in my opinion, extremely destructive. They can mess up how people think about OO design in a subtle way for a really long time. Switches, lights, and anything where there's a natural input, output and desired behavior are so much better than "a cat is an animal, so Cat.MakeNoise should return 'meow'".

Cats don't exist inside of computers.

complex real numbers
https://softwareengineering.stackexchange.com/questions/316507/what-is-the-correct-oop-relation-between-complex-and-real-numbers


 * @KevinMills math is very different from programming here in the sense that math objects are immutable. In the context of programming, establishing relation between real and complex numbers would be rather "a category error or category mistake" as was pointed in this answer to similar (possibly diplicate) question – gnat Apr 22 '16 at 12:16

https://softwareengineering.stackexchange.com/questions/199331/is-there-a-specific-name-for-the-square-inherits-from-rectangle-paradox/238420#238420


 * Unfortunately, it is difficult to model the relationships between numeric types using the typical feature set of an object oriented language. You can get close by modelling both real and complex as instances of an interface" number", but OO semantics will trip you up because in many cases functions of real values will want to return real and the same functions will want to return complex for complex arguments. You'll have to compromise and just return numbers without specifying which, but that ends up with a loss of type information (at least for static languages), which may be undesirable. A better answer is the use of polymorphic functions, rather than classes, along with some kindof constraint system to ensure your type arguments are proper numeric types. This is the way many functional languages handle the problem, and if c++ ever gets the template concept constraint system the c++ committee have been working on for years, you'd be able to achieve a similar result in c++. Otherwise, ad-hoc overloading is probably the best that can be achieved.

comp.lang.c++
https://groups.google.com/forum/#!topic/comp.lang.c++/KeiMQ8YecLM%5B1-25%5D google groups post by Robert Martin

links
Category mistake

https://en.cppreference.com/w/cpp/language/constraints