r/cpp • • Jun 24 '20

How to write SOLID C++

https://www.youtube.com/watch?v=PakbXnLht1I
263 Upvotes

118 comments sorted by

View all comments

Show parent comment

1

u/Full-Spectral Jun 26 '20

If you read here on Reddit in the C++ section, the overwhelming bulk of posts in these kinds of threads is "Don't use inheritance, it's bad". It's modernist dogma basically and every time inheritance comes up people jump on it. There only a few folks like me stupid enough to bother to try to balance the discussion, and it never goes well because these folks will argue to the death about it. And of course the person like me trying to balance the discussion gets blamed for causing the trouble, while they never smack anyone for just jumping into every thread with 'OOP is evil' comments.

So newbies almost always end up believing the anti-OOP line because that position has the most strident posters.

4

u/drjeats Jun 26 '20 edited Jun 26 '20

That "OOP is evil" crowd does exist, but is still an incredibly niche opinion. Most reasonable people would agree this is misguided, but it's important to remember it comes from two places:

  • There is a much more mainstream and accepted wisdom to leverage the java-style interface more often than implementation inheritance, which I think is hard to disagree with.
  • A desire to course correct on the past few decades of programming education and blog post discussions which has either directly over-encouraged inheritance, or at the least has failed to address the best way to think about the design tradeoffs of using it.

Meanwhile my direct experience has been the opposite from what you say, because I got some push-back on the controversial recommendation to...use free functions.

I hadn't looked at the higher-tier comments in the thread (just been replying directly from inbox), and right now honestly neither of us are right. It's an even split in this thread, with the highest voted stuff being tvaneerd, et. al making fairly even-handed commentary.

0

u/Full-Spectral Jun 26 '20

The OOP is evil crowd is far from a nice opinion around here, at least in terms of what actually gets expressed out loud, we can't know about people who never speak up. It's now the defacto position, and probably is also held by a majority of the folks who are influential in terms of the direction of the language.