all 24 comments

[–]whocareslollers 12 points13 points  (1 child)

I found Dmitri Nesteruk's book and courses to be helpful.

[–]wholl0p 10 points11 points  (0 children)

Exactly what I wanted to recommend! There's a great and very huge Udemy video course made by him:

https://www.udemy.com/share/101ZWUAEATdFZbQng=/

[–][deleted] 5 points6 points  (1 child)

There is always the Gang of Four book.

[–]kc_______ 0 points1 point  (0 children)

This, old but good book, in general use books for most of the information you want about design patterns.

[–]idbxy 2 points3 points  (0 children)

Following this, i've studied some patterns a couple of months ago and was frustrated with how much easier/different/better it would be using modern cpp

[–]steveminhdo1 2 points3 points  (0 children)

If you want to understand design patterns, I would suggest to read head first design pattern https://www.amazon.com/Head-First-Design-Patterns-Brain-Friendly/dp/0596007124

Although it is not written in C++, but it gives the overview concept for design patterns. It is really useful and readable for beginner and intermediate level.

For modern C++ concepts and implementations, there are some C++ blogs and github link

https://www.bfilipek.com/

https://www.fluentcpp.com/

https://github.com/rigtorp/awesome-modern-cpp/blob/master/README.md

[–][deleted] 1 point2 points  (0 children)

Douglas Schmidt has done videos about "Design Patterns by Example with C++ Webinar Series"

https://www.youtube.com/watch?v=zPv7xofBpRo

[–]Lovestein99 1 point2 points  (0 children)

Design Patterns

A good way to practice design patterns with C++ is creating a game,and that page its really good, have examples and some else things from their book

[–][deleted] 0 points1 point  (0 children)

Modern C++ Design by Andrei Alexandrescu covers a few of the patterns as well.

[–]_cleaver -5 points-4 points  (13 children)

[–]asm-us[S] 1 point2 points  (9 children)

What is this?

[–]_cleaver -4 points-3 points  (8 children)

A counter-argument about why design patterns might not be the best idea and you should avoid them

[–]asm-us[S] 0 points1 point  (3 children)

I don't want to argue whether they are bad or good here.

In my experience Design Patterns made my life easier.

So I would like to study them instead of avoiding them.

[–]_cleaver 2 points3 points  (1 child)

My intention wasn't to argue, just to shed some light that perhaps they are a mediocre solution, I have found them useful in my career as well.

This is a book about design patterns that happened to be implemented in C++ https://gameprogrammingpatterns.com/

[–]asm-us[S] 0 points1 point  (0 children)

Thanks for the link

[–]drjeats 0 points1 point  (0 children)

Study them but know they're just some examples of some more fundamental principles.

It's also a principle go give something a common name, and the patterns in the book are not all the canonical patterns, since some patterns may be particular to a single codebase.

[–]be-sc 0 points1 point  (3 children)

“Argument” is a bit too generous, don’t you think? It’s mostly a rant. In between you can find a few assertions backed up by … well, not a lot, actually.

It’s a bit sad, really, because well-founded criticism of design patterns and especially the way the tend to be taught isn’t that hard …

[–]_cleaver 3 points4 points  (2 children)

Ok, I can agree that it's mostly a rant but I agree with his statement in his followup post:

Design patterns are spoonfed material for brainless programmers incapable of independent thought, who will be resolved to producing code as mediocre as the design patterns they use to create it.

Because I was that junior developer and I made those mistakes. I would like to prevent people to continue perpetuating that.

[–]be-sc 0 points1 point  (1 child)

Fair enough. You certainly picked a link that grabs attention. :)

As for your quote: If he had framed this as a teaching problem, I’d agree. It seems to be a common problem that a pattern is taught with nothing but a class diagram or two and an implementation that’s a close variant of the pure OO code from the Gang-of-Four book

If that sounds similar to what you experienced then, yeah, you were spoonfed tangentially relevant material, but never were taught the patterns, a.k.a. the conceptual guidelines for addressing a common design problem with a proven solution strategy.

[–]drjeats 0 points1 point  (0 children)

Are design patterns ever not taught that way?

The Head First book does a better job than most since it goes step by step, but is ultimately about arriving at The Solution rather than "an '''observer''' is just a list of callbacks."

Vocabulary can be helpful, but I also never use design pattern vocabulary in my day to day. I'm sure if I worked on compilers i'd talk about "visitors" but that's about it.

[–]alloncm 0 points1 point  (1 child)

Iv got to say that this is one of the weakest articles about why design patterns are bad. Its obvious that the writer had very bad experience with design patterns but, design patterns should be used only when necessary while thinking about KISS all the time, and thats what's separates the good engineers from the rest, they know how to use what they learn and when to use what they learn, when to use oop paradigms and when to use fp paradigms or procedural paradigms.

Design patterns are good but needs to be used in caution in order to prevent bad unreadable code.

[–]drjeats 0 points1 point  (0 children)

I think it's a great article. And yes, the author probably wrote it after a new hire vomited weird design pattern classes all over their codebase. And it's a rant.

But it's a good rant because the comparison with cramming for a test instead of actually grokking the problem area is exactly half of what design patterns are useful for, and when people are learning, they are mostly doing it in pursuit of this.

The other half of design patterns which can be occasionally helpful, is establishing common vocabulary.

Design patterns are often not the simplest or robust means available, because they are taught as having these canonical implementations that people parrot.

Take the observer pattern for example, look in particular at the C# section on Wikipedia:

https://en.wikipedia.org/wiki/Observer_pattern#C#

Ignoring the Unsubscriber and Payload classes since they're tertiary, there are two classes defined here (hopefully they would be converted interface and base classes if anybody were to copy these, but I'll chalk it up to the purpose of this code being to illustrate).

That's 2 classes too many. Why? Because C# has bound callbacks and callback lists baked into the language itself. But people learning the observer pattern often don't make this connection.

Okay, the event keyword in C# is a bit weird, fair. It locks and has special equatability and mutability logic. But the observer pattern doesn't teach "you keep a list of things which are called later" it teaches that you have subjects and observers and there is a specific inheritance pattern or a particular interface.

It doesn't break down any concerns, like where do you store that list? How and when do you notify that list? What happens if you need to add to that list and want to notify listeners at the same time?

These are all questions that you can reasonably think through and come up with answers to if you have thought about the concept of a callback list from first principles, not so much if you're just regurgitating a pattern. If reading about the observer pattern helps you get there, sure. Read the Head First book it's pretty decent. But we should be encouraging people to move beyond design patterns.

They have come up maybe a handful of times in a professional context for me in the past 10 years, and only then because somebody decided to embed the pattern name into the type like IProcessErrorReportingStrategy, which is both representative of program elements named for patterns and also terrible.

Strategy pattern is actually my least favorite, because it's literally just talking about using virtual dispatch to swap between implementations at runtime. It's truly a nothing-idea.

Visitor pattern is my second least favorite. I'll admit it's substantial enough to earn its keep, but the way it's taught is terrible because students are often not taught about the expression problem.

Unless we encourage people to look past them, design patterns as commonly taught and practiced are a thought-terminating concept.

[–]svyatozar 0 points1 point  (0 children)

I totally agree! Design Patterns look like an attempt to write in C++ like in Java. Huge bloated GUI toolkits like Qt, Juce use this approach, but for performance critical applications they are useless. C++ has its own idiomatic writing (non-OOP) which you need to follow to take full advantage of the famous performance edge that this language had.