As Python continues to grow in popularity, projects are becoming larger and more complex. Many Python developers are now taking an interest in high-level software architecture patterns such as hexagonal/clean architecture, event-driven architecture, and strategic patterns prescribed by domain-driven design (DDD). But translating those patterns into Python isn't always straightforward. With this practical guide, Harry Percival and Bob Gregory from MADE.com introduce proven architectural design patterns to help Python developers manage application complexity. Each pattern is illustrated with concrete examples in idiomatic Python that explain how to avoid some of the unnecessary verbosity of Java and C# syntax. You'll learn how to implement each of these patterns in a Pythonic way. Architectural design patterns include: Dependency inversion, and its links to ports and adapters (hexagonal/clean architecture) Domain-driven design's distinction between entities, value objects, and aggregates Repository and Unit of Work patterns for persistent storage Events, commands, and the message bus Command Query Responsibility Segregation (CQRS) Event-driven architecture and reactive microservices
1. Test-Driven Development with Python
2. Architecture Patterns with Python
The 2nd one is the closest you're gonna get to a production-grade tutorial book.
Related to this topic, these resources by @dbeazley:
Barely an Interface
https://github.com/dabeaz/blog/blob/main/2021/barely-interfa...
Now You Have Three Problems
https://github.com/dabeaz/blog/blob/main/2023/three-problems...
A Different Refactoring
https://github.com/dabeaz/blog/blob/main/2023/different-refa...
His youtube channel:
The idea that I take advantage of good abstractions and I send those objects into my classes that need to perform actions via those abstractions made a lot of sense. Helps enable good polymorphism, as well as unit testing and other things.
I don't think I'm doing it justice, but the idea took a good while to understand there reasons behind it. Some books that helped me grok the idea were
- Patterns of Enterprise Application Architecture - Clean Architecture - Architecture Patterns with Python
along with running into problems that could be easily solved with a decent abstraction at work and learning to apply it directly.
Two more resources that I really like:
1. Pycon videos - they're posted free on youtube. It's a great way to explore interesting problems with interesting people.
2. Another book on python by Harry Percival (he does a lot of TDD stuff) - Architecture Patterns with Python. This book is relatively new. It targets an rather niche audience (web devs). But it's hard-won knowledge and really well written. It's a wonderful resource for python devs, and a book I wish more people knew about. https://www.oreilly.com/library/view/architecture-patterns-w...