Comments by "MrAbrazildo" (@MrAbrazildo) on "Object Oriented Programming vs Functional Programming" video.
-
@plan.b2 Let's say you want to hide data in C, kind of a class in C++. You will have to put that data aside, in other file, to be seen only in that file, with some f()s to talk to public. And how could you inherit this code? You could repeat it with macros, but it would be awful, because of too many code. I love macros, but not for an entire class.
And let's say you want several objects of that "class" in C. There's no way, unless you transform all from that file into arrays, but the resulting code would be prone to errors, compared to a C++ array of objects.
2
-
2
-
2
-
2
-
@plan.b2 The DRY principle (Do not Repeat Yourself) protects the coder from errors. Inheritance works with it. Let's say you must compute objects and people. Both have locations, and you want compress locations coordinates to save memory, leading to not intuitive code. It's nice to have that in a class, with f()s to unpack info behind the scenes and keep a higher level dialogue. Both classes inheriting that is DRY.
Even if you use hash table, trying to say that won't inherit, because it will be an unique array/list/container, you can reach a situation in which you realize it's better to have 2 hash tables, because let's say, people is the "hot data" (more accessed), and the whole app will be faster if accessed separately. In this case, the locations class could hold an array itself, being inherited by both hash tables, keeping the DRY principle.
2
-
1
-
1
-
@plan.b2 If all you are dealing with is a database, which asks to the user what action to take, does that, and asks again, it's fine to use FP. But if you are handling a highly interactive project, such as a game, operating system or multimedia at all, things can get really dangerous in FP. Let's suppose the user starts frantically kidding with window resizing. This will try to access many data, before concluding some tasks, testing the stability of the system. OO has much more chances to catch any error, due to its restrictions. For instance, you have control of who is trying to reach the hidden data.
Here's an example of that: https://www.youtube.com/watch?v=0Yh80SvW9mo
1
-
1
-
1