3 ms·
I would second ayhanfuat's comment[1] - if the programming beginner is at the level that we'd prefer to show them Python over Java or C#, then they probably are
by nicklecompte 3y ago
I would second ayhanfuat's comment[1] - if the programming beginner is at the level that we'd prefer to show them Python over Java or C#, then they probably aren't ready for understanding these design patterns.
The other thing is that Python doesn't actually seem like a good language to discuss these abstractions compared to Java or C#: it's dynamically/gradually typed and in general dependencies are handled in a more "UNIX"-y way. In particular Python doesn't have first-class interfaces (at least last I checked, maybe mypy has something?). But statically-checked first-class interfaces are critical for why e.g. the service locator pattern works "seamlessly"[2] in real-life Java/C# codebases with lots of people doing lots of different things.
My gut is that a lot of inversion-of-control design patterns don't actually work so well in practical Python compared to just throwing things in a dictionary/etc and using strings + careful unit testing. I do see there are some service locator Python packages so maybe I am being too closed-minded. But for teaching C#/Java is probably a better choice.
[1] https://news.ycombinator.com/item?id=39459732 https://news.ycombinator.com/item?id=39459732
[2] I have been mystified by too many null pointers to say this with a straight face. But when the bugs are squashed it really does manage a "magical" level of complexity.
- polotics 3y agoWow, are you really sure you've updated your priors? This notion that Python is for programming beginners as opposed to Java/C# has aged quite a bit has it not? In other news, ten years on the game's been up a while now, Fowler's profusion of wordage plastered onto simple functional concept, eg. in the present case: partial function application, doesn't really fly so well, even in the enterprise.