Comments by "MrAbrazildo" (@MrAbrazildo) on "Prime Reacts: The Flaws of Inheritance" video.
-
15:22, since class is about protecting data, I design them towards this. So there's no "obscure contract": the base class holds some data, and maybe some f()s, if they are pretty tied to it, technically. It's not a contract, it's an independent, ready to work class. A derived class should expand its data, or else should be reduced to just independent f()s, in most cases. This also brings the advantage to send just the base class, to f()s that only needs it, allowing a possible performance gain by coping it (if small), instead of referencing it.
16:30, the best way to do this in C++ is to avoid the abstract base class: put its methods on a macro, using composition on the derived ones. So the compiler will build the classes as concrete ones, not interfaces, gaining lots of performance.
26:10, this is pretty awkward. It should be just 1 class, and not an interface by default. And if many f()s should not be allowed to change users, almost everything here should be made nonpublic, allowing just a few f()s to change it.
1
-
3:15, I can't, there's C++.
7:25, it's better to separate resource/muiltimidia from the logic the commands them. Because resources can be large, staying on the RAM/heap memory, while the logic goes to CPU caches, becoming much faster. I use to let a class hold images, for instance. Whenever wants to draw, it's send a number/code, meaning a request for some specific image. This also avoids unnecessary duplicating resources, since they will stay in a single instance class. I also avoid making unnecessary classes. I only create them to defend critic data, since this is already built in the C++ core.
8:30, the same thing is applied to situations where an object is about to be unnecessarily duplicated: keep things in 1 object, which should receive request to access/modify its content.
15:00, these are not good examples for classes, they could be just f()s. Drawing and saving are actions, classes are mostly for data. Class is recommended for when data must travel safely along the battlefield. Safely means only changeble by authorized f()s.
1