MENU

Fun & Interesting

How to Implement the Strategy Design Pattern in Python

ArjanCodes 54,602 4 years ago
Video Not Working? Fix It Now

💡 Learn how to design great software in 7 steps: https://arjan.codes/designguide. This video covers the Strategy pattern, but also looks at a few varieties of the pattern using Python features such as Protocol classes, dataclasses, the __call__ dunder method, and closures. The code I worked on in this video is available here: https://github.com/ArjanCodes/2021-pythonic-strategy. 🎓 ArjanCodes Courses: https://www.arjancodes.com/courses/ 🔖 Chapters: 0:00 Intro 1:23 Explaining the example 3:54 About the Strategy pattern 4:40 #1: Classic OO version 11:58 #2: Using protocols 14:20 #2: Using the __call__ dunder method 16:21 #4: Using functions 22:45 #5: Using closures 26:01 Final thoughts #arjancodes #softwaredesign #python

Comment