@cod1ng_together: This Python Trick Makes Range Checks WAY Cleaner #python #coding #programming In this video we learn about the Strategy Pattern in Python, a clean way to swap out behavior at runtime instead of relying on long if-elif chains. This video shows how to turn each conditional branch into its own interchangeable class with a shared method, making it effortless to extend your logic without ever touching the core function again.
adding more lines and making things overly object oriented for no reason
2026-09-04 03:45:50
22
karlobi :
this isnt really that scalable i would just put the multipliers in a dictionary and return amount * dict[strategy]
2026-09-03 17:38:24
10
𝐁𝐫𝐢𝐠𝐡𝐭 𝐒𝐤𝐲 :
This still doesn't change the fact that there are 42 million kangaroos in Australia and only 3 million people in Jamaica. Which means if the kangaroos were to invade Jamaica, each person would have to fight 14 kangaroos.
2026-09-04 11:10:41
0
Yingy88 :
How did you make it better? You need to change that example and use something that align properly with that use case. What you presented is great but it didnt offer much.
2026-09-16 00:57:13
1
Bharatchadani :
what if its YAGNI??
2026-09-04 13:27:48
1
@zo8953 :
Sorry but this is premature abstraction for this example.
2026-09-04 07:33:48
3
Ollie :
Incidentally, your notification example you used for the Registry pattern video is a much better Strategy example than this pricing one! Email / SMS / Push behind a shared Protocol, with the registry only doing the channel -> strategy lookup.
Then each strategy can have its own clients and setup internally, while the caller just sees the same send() contract.
2026-09-03 18:36:42
1
Patataz30 :
"hope you dont break anything" 😭
2026-09-24 13:16:45
1
scout :
Oop has a bad reputation because people keep over abstracting everything that doesn't need to be a class.
2026-09-07 06:59:39
1
Robbie31415 :
2026-09-04 06:45:39
1
Mpenda Chapo Moto :
Registry pattern would have been better IMO
2026-09-29 10:54:40
1
bloopee7 :
😳😳😳
2026-09-03 23:47:37
1
To see more videos from user @cod1ng_together, please go to the Tikwm
homepage.