Oberon_Command said:
C++ may have objects and we may spend a lot of time talking about things that we call objects, but I don't really consider C++ an OO language when you factor in its dominant idioms, especially the more modern ones. C++ may have started out as “C with classes,
Wanted to quote the whole paragraph, but that's a nice definition i can befriend with, being so critical about OOP. : )
Oberon_Command said:
ensure that a design contract is upheld
introduce a seam beyond which change of some sort can occur without the user needing to modify their own code to preserve correctness, possibly without even requiring a recompile
Yes, but my claim is those are high goals which can't be enforced to work just by following OO paradigms, SOLID, or whatever.
There always are failures, and if so, the enforcement becomes an obstacle.
So i'd like to break the private constraint, in cases i am willing to accepting the consequences, which include making my hacks hard to maintain and them being eventually just temporary solutions.
I mean, C was meant to do anything. We can cast one type to another, even if surely incompatible. We can shoot our own foot if we desire.
Why the hell should private / public be an exception from this tradition? This is like saying, suddenly modern programmers must be protected from themselves, because they tend to do everything wrong and are just stupid.
Well, i could add ‘#define private public’ to my preprocessor defintions. But there should be a better way for such criminals, hackers, and fools to do their thing. Just declare it bad practice, and i'm fine with that.
Oberon_Command said:
but I would prefer to refactor rather than break a type's design contract.
Exactly, but you can not always convince the author to do so.
So there should be a non recommended option you do it on your own, without a need to change the original code somebody else is responsible for.
I respect the decision of the author, and also his designs. But sometimes a need a backdoor to apply little hacks. And the evil language tells me i can't.
Oberon_Command said:
In what way?
I have a list of small changes i need to apply to the authors code each time i do an update. They pile up. It's annoying.
Well, maybe i'm currently too focused on a special case.
I'll try to make my OOP critique more general…
Imagine a node based shader editor GUI. We make this, and proudly present this to our users. We claim it's flexible and spurs creativity.
And the users like it. They drag nodes around, try to connect them with spaghetti noodles, and they get what they want. Plus some interesting, unexpected results.
Everybody is happy.
So that's good. Why? Although we use spaghetti to glue things together in arbitrary ways, it's fine. So it is sort of spaghetti code in programming terms, but it works.
Why does it work? Because the whole system represents a graph, which is what we want.
But OOP does not give us that. We get no flexible graphs - we get restrictive and cumbersome hierarchies and trees.
That's not what we want at all imo. And it will never work to hold its promise.
OOP fans will now argue i do not understand OOP. Of course it can form graphs. Our shader editor was even coded with OOP!
And you may be right. I may fail to understand it. But i just don't buy it.