4 ms·
I'm not sure that it is so bad. But I still don't understand why it's good! Why is it so good? It is said to be better than (non-OOP) alternatives. Where's the
by throwawaylinux 5y ago
I'm not sure that it is so bad.
But I still don't understand why it's good! Why is it so good? It is said to be better than (non-OOP) alternatives. Where's the evidence for that?
- chadcmulligan 5y agoI always think the best argument for OOP is avoiding name space collisions - with procedural programs you have a bunch of functions that could be named the same - how do you separate them? OOP gives you the ability to wrap things together - their variables along with the methods that make sense for the objects - little collections of things that go together. Then once you have an object, sometimes you'll want to make a method work a bit different in different circumstances - inheritance solves this. Sometimes you'll want a bunch of objects that aren't really in an inheritance hierarchy to have some features the same - so interfaces (protocols) are born.
- _dain_ 5y agoIsn't that just polymorphism? There are lots of ways to get that.
- chadcmulligan 5y agodon't think so - https://stackify.com/oop-concept-polymorphism/ https://stackify.com/oop-concept-polymorphism/
- rawoke083600 5y agoI would argue (my opinion) - OOP smashes together state + behavior. The original reason for this was good: I.e the user of the class(object) should not need to know ALL the internal details etc. Something like ECS (data-orientated). Very explicit separates DATA(state) and BEHAVIOR (System, Functions, Methods etc). For me at least it makes it easier and more reliable to "reason" and have a "mental model" about the big-complex system. If I know that for example in a game project ANYTHING with "gravity" is about the ONE Gravity-System(which runs 1x60 seconds in possible sep.thread) and that it Operates(change state) for ALL entities with the "Mass + Pos Components."