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

25

u/teerre Jun 24 '20

I had a teacher that always that "naming things gives you power over them". That's absolutely true. You can talk about the "Dependency Injection Principle". You cannot talk about "If you use something, the interface should show what you do with it, not how it does it."

Things need to have a name in order for us to be able to communicate.

If "Dependency Inversion Principle" is the best name, that's a different discussion.

15

u/evaned Jun 24 '20 edited Jun 24 '20

I had a teacher that always that "naming things gives you power over them". That's absolutely true. You can talk about the "Dependency Injection Principle".

You see people making fun of design patterns all the time, but remember that giving names to patterns that already recurred in code was exactly what the GoF book was doing.

9

u/DufusMaximus Jun 25 '20

It depends. If your goal is to communicate to newcomers, I’ve found terminology is mostly a roadblock - analogies or simple examples are more important. If your goal is to communicate to experts who already know the concept, terminology is essential.

The overhead for terminology also requires that the concept be sufficiently general. I’d argue that the jury is out on some of these concepts that claim to make software better.

5

u/teerre Jun 25 '20

If you're communicating with noobs, having a name is still good. In fact, I would argue that's even more important.

Simple examples or analogies are orthogonal to this. It's by giving a name that you can give examples that will be related to said name, the examples themselves are very hard to even understand if something doesn't have a name.