The Strategy Pattern: Write BETTER PYTHON CODE Part 3

preview_player
Показать описание
The strategy pattern is a widely used design pattern that help you write better Python code. I'll show you how to apply the strategy using a practical example written in Python. I'll cover both the classic object-oriented version of the pattern, and I'll also show you a functional version that's a bit shorter to write and works equally well. At the end of the video, there's a more advanced bit where you'll see how to add type hints for functions as parameters.

All parts in this series:

Relevant books:

🎓 Courses:

Chapters:
0:00 Intro
1:30 Code example
3:21 Main problem with the code
4:01 Switching to a strategy pattern
5:23 Creating concrete strategies
6:56 Updating the process_tickets method
10:09 Adding a new strategy
11:03 A functional version of the strategy
13:18 Adding a function type hint
14:49 Outro

If you enjoyed this content, give this video a like. If you want to watch more of my upcoming videos, consider subscribing to my channel!

DISCLAIMER - The links in this description might be affiliate links. If you purchase a product or service through one of those links, I may receive a small commission. There is no additional charge to you. Thanks for supporting my channel so I can continue to provide you with free content each week!
Рекомендации по теме
Комментарии
Автор

Cannot begin to express how much I am loving this series. I just feel like no one ever addresses these concepts as much. It's always algorithms and system design in regards to nailing the interview. I'm trying to craft software! Please keep this series going. I just found you today and expect to finish all of this by tonight. <3

murghay
Автор

”The perfect way to deal with customer support.”

Amen! 😂

dawid_dahl
Автор

Super underrated channel. You provide some of the most helpful python content on youtube. It seems like nobody else is addressing the concepts that you are, or with the same depth.

ares
Автор

Hey Arjan, I never leave comments. But I just wanted to say you have some QUALITY content. I have no doubt in my mind that your channel will blow up. Keep it up!

sandmasterful
Автор

Thank you so much for not ignoring functional programming in your videos. My eye was twitching the entire first half because of the classes each having only a single method. Was so relieved when you switched them all to functions! :D

imadetheuniversefun
Автор

I really enjoy how you present and demonstrate those pattern! Thank you!
Best Part: 10:40 ;)

felixsponholz
Автор

Wow. Now so many of the Python libraries I use are starting to make even more sense. These videos are sensational. Thank you again!

mrdbourke
Автор

Not a lot of people go into distinguishing this pattern between OO and functional paradigm. Most just harp on creating objects when most of the modern languages these days support first class function. Thank you for making that distinctions and showing us why latter is simpler.

yojansh
Автор

I don't even use python but these are the most effective lectures on design patterns I've watched. I think it's in part because you include just enough code to give the necessary context but not so much as to distract from the actual topic. I wouldn't change anything about your teaching style I think you pretty much nailed it so cheers

chiefxtrc
Автор

I really appreciated seeing both the more formal solution and the streamlined Python solution, and finally the solution with type hints. Exploring the variations helped me see what was at the heart of the solution. Thank you, this is really leveling up my code.

mikec
Автор

The quality of these videos is phenomenal

hungryskelly
Автор

Man, this channel has spoiled me for the other Python channels. You've set a high bar, Arjun.

heyheyjc
Автор

Great series, lovin it so far. My only obvious code smell that triggered me, was that you named your argument `list` which is a builtin type in python

stalinthomas
Автор

Arjan, I am in a while True loop here.
I watch a video. Refactor my code. Watch another video before going to sleep. Wake up and refactor based on what I learned last night. Watch another video before going to sleep. Acknowledge new patterns and think " I should refactor my code tomorrow and implement this".
Much appreciate your precious content.

felipedeabreuprazeres
Автор

This is so cool even I don't really comprehend what you are talking about

KaruseTang
Автор

This series is so well done! This is the sort of stuff that I've constantly run into but was never explicitly taught. I really appreciate this your work!

beckaddison
Автор

Your content is 100% making me a better programmer, easy to follow and examples that mimic real systems. I have been able to implement these topics in my day to day work with ease!

macleayy
Автор

At first, I felt the use of abstract base class, while certainly elegant OOP style code, was too much. I thought, "this guy's writing Python with a Java mentality. Why doesn't he use functions instead?" And then, you finished it off by using functions instead. I'm sorry to have doubted you! This is very informative. Thank you

qwertyuiopsdfgh
Автор

Your free videos are way better than the paid courses I bought, thank you Arjan

TheMako
Автор

I am so grateful because I found this channel

Moody