Design Patterns Explained - The Strategy Pattern

preview_player
Показать описание
The strategy design pattern can help make code more readable, maintainable when you need to be able to select an algorithm during the run time of a program.
This is done through the use of polymorphism.

Firstly I show how code can be bad when not using it, and then show the same code, but written using the pattern in mind.

=========

=========
RESOURCES:

More info on strategy pattern:

=========
MUSIC USED:

=========================================
LINKS:

GitHub:

Discord Server:

Support me on Patreon:

Follow me on Twitter:

Follow me on Twitch:

Subscribe to the subreddit:

Community Channel:
Рекомендации по теме
Комментарии
Автор

Hi all! It has been a while and I spent a very time making this video so I hope you enjoy the first episode of this new series :)

Unfortunately, there were many issues I didn't realise until too late. The main one is the video itself is full of "glitches". This was caused by me using a random mix of 60FPS and 30FPS clips, and also using an external HDD to store the clips.

It turns out the editing software I used (Camtasia) does not play well with this kind of thing. (and it makes sense, streaming video via USB external HDD into editing software is bound to cause issues, this would have been an issue for other software as well probably).


I tried to sort as many of these glitches as I could but more popping up :(


I have learned from these mistakes, so hopefully future videos in this series will be more up to standard.

Hope you understand and enjoy the video regardless! :)

Hopsonn
Автор

The explanation of the problem was excellent, but the explanation of the solution felt a bit rushed and made a lot of assumptions about pre-existing knowledge and experience. I think aiming for the 10-minute mark is a sane goal to have for explanation videos, and would give you a bit more time to take a breath and explain things at a speed viewers can more easily comprehend. Personally, I prefer C-style lookup table of function pointers, but it's more or less the same thing as a virtual table in C++. Great idea though, and I'm looking forward to seeing how you iterate on it in future videos.

Aside: Don't get caught up on micro optimizations like "video glitches". Nobody cares. If you fix them in the background we'll all get the benefits, but there's really no need to publicly apologize or point out these minor errors. It just undermines your work. Focus on big-picture feedback like speed of explanation, quality of content, readability of code snippets, etc.

dandymcgee
Автор

Very useful! Thank you so much, I’d love to see this turn into a series where you go over all the main or important design patterns.

TehBrian
Автор

That was interesting. Can you make more videos on design patterns?

h.hristov
Автор

Awesome video, well explained. Would love for you to do similar stuff with other patterns. Its very easy to understand when you write code without the pattern first, and then change it to use the pattern!

AntoNosu
Автор

Good refactoring tip that I'll fall back to when I get a chance to pay off some tech debt. Just as an aside though I can't figure out why you're using c++ for any of this.

Markd
Автор

I was searching for around an hour for a good explanation I can understand, THANK YOU

khaledmkhawad
Автор

Totally unrelated but your voice changed a lot

And a video related comment this is how many games manages multiple classes

dirtyblasion
Автор

selecting an algorithm at run time can be as simple as having a list of function pointers

phrydo
Автор

i made paint in windows batch when i was 13, that was the definition of unmaintainable code, but it worked and it was pretty cool for something made in windows batch

MrTurbo_
Автор

Ouf, nice! I really liked how you first showed how and why stuff is not ideal, and then demonstrated how the pattern solves the problem.

If you just go straight to the solution and skip the justification for why the solution was invented in the first place, it will never stick in memory, at least not for me. Subbed and hope for more content like this!

dawid_dahl
Автор

Yay new video.
Fun & educational !!

shorakie
Автор

for some reason I thought you'd talk about game design in video games. I'm happy to see that I was wrong, because this is way more useful .

Pinocchio
Автор

Great video! I would recommend the gameprogrammingpatterns book by Robert Nystorm, it's full of these awesome patterns and a great resource. Keep it up Hopson :)

WiLDDesigns
Автор

Learned that pattern a week ago and only now I found that video?
I call Bs.
Thanks for the explanation, it was clear, simple and quick.
Hope you'll cover some other patterns

NosAltarion
Автор

Really good video! Its very interesting how similar the strategy design pattern is to a state machine! Could you make a video exploring the observer design pattern? Or possibly the command pattern? That would work well too if you continue with the paint program because of its use for undo and redo functions!

monkeymm
Автор

Basically it's a video showing what c++ permitted over C

arnaud
Автор

Very happy to see a new video in this channel

tinycloud
Автор

Seems like you could have acceived something of similar organizational quality without oop.

foodice
Автор

I really like using DavinciResolve for video editing. A little bit of a learning curve, but might be worth a try.

braydenstorms