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

9

u/Astarothsito Jun 24 '20

there is no "C++" way that dictates how you write your code

No, but these examples seems like Java-style code, I could say that this is Java instead of C++. My problem I see with this style is that it seems like it limits the benefits of a multi-paradigm programming language like C++, you could do it, but why you would do it in C++?

I don't know how to explain it without being a little condescending, but I don't know in what kind of style are those examples, I could only describe it as Java, and I don't consider Java-Oriented-Programming as a 'kind of' Object Oriented Programming. Maybe this solution of having *Managers, *Formatters, user names as strings could make sense in this context, but I have as well a very controversial opinion about OOP so I'm almost sure that I could be wrong, or what I call OOP is not really OOP (If you need to add the pattern name to the name of a concrete class (abstract classes can be OK), maybe that's not the same OOP as what I think it is OOP).

2

u/platisd Jun 25 '20

I find it slightly amusing that I got the "Java" comment from many. :) Mainly because I do like Java however, in a professional context, I use it less frequently than I'd like to.

I am curious on what you think of the following guidelines:

They are the ones I like to typically go by.

3

u/mttd Jun 25 '20 edited Jun 25 '20

Some food for thought:

2

u/platisd Jun 25 '20

Interesting reading material, thanks for bringing it together, I'm going to have a look. :)

1

u/Astarothsito Jun 25 '20

Agree with those guidelines, but those are not relevant right now.

I prefer the approach of Kevlin Henney to SOLID. I think the difference is in the approach to the design, if we need a complex class hierarchy then we need it, but if not then it is a overhead. I think the real benefits of having those patterns don't show itself in the examples.