You Don't Need That!
summary
Claim: many classic OO design patterns are unnecessary in Python because built-in features do the same job more simply. Shows a Java-like Singleton and then a Pythonic module-level instance that prevents multiple constructions. Replaces Dependency Injection with runtime overrides and unittest.mock.patch for tests. Reimplements Iterator + Visitor and then simplifies them with generators and the for loops construct. Demonstrations compile and the idiomatic alternatives work and read far clearer, so prefer language features like the module system over reimplementing external-language patterns.
AI-written summary · about
chapters (22)
- 0:00Start
- 1:35Development teams are increasingly polyglot.
- 2:07Object-Oriented
- 2:17Python?
- 4:06Let's implement 5 design patterns in Python
- 4:33Ideas on how to port software to Python
- 7:081. Namespacing
- 7:292. Functionality you can pass around
- 8:03A better solution: Modules
- 9:41Provide dependencies to classes as constructor arguments
- 11:53Unit Testing.
- 12:24Mocks
- 14:00Python doesn't need dependency injection because you can override
- 14:33Lets you use iterate over custom collections
- 17:39Python doesn't need explicit iterators because Generators are easier
- 17:49Perform a common operation on a collection
- 18:02Acceptor Visitor
- 19:11Separating the structure from the operation
- 21:03What did we learn?
- 21:20Python provides language features that replace common patterns
- 21:37"Everything is a variable" replaces binding restrictions
- 22:04Write code like you're writing Python.
related talks
01h 08mPython Design Patterns 1
25mDesign Patterns Unleashed: Building Elegant and Confident Solutions
50mThe Clean Architecture in Python
24mPython for Humans, Designing Python Code Like a User Interface
55mThe modern view on implementation of classic design patterns in Java
26mPatterns, patterns everywhere
30mPython for Humans - Designing Python Code Like a User Interface
52mThe modern view on implementation of design patterns (RU)
