Architecture Patterns with Python: Enabling Test-Driven Development, Domain-Driven Design, and Event-Driven Microservices Paperback – Illustrated, 20 March 2020
|New from||Used from|
Frequently bought together
Customers who viewed this item also viewed
About the Author
From the Preface
Who Should Read This Book
Here are a few things we assume about you, dear reader:
- You’ve been close to some reasonably complex Python applications.
- You’ve seen some of the pain that comes with trying to manage that complexity.
- You don’t necessarily know anything about DDD or any of the classic application architecture patterns.
We structure our explorations of architectural patterns around an example app, building it up chapter by chapter. We use TDD at work, so we tend to show listings of tests first, followed by implementation. If you’re not used to working test-first, it may feel a little strange at the beginning, but we hope you’ll soon get used to seeing code “being used” (i.e., from the outside) before you see how it’s built on the inside.
We use some specific Python frameworks and technologies, including Flask, SQLAlchemy, and pytest, as well as Docker and Redis. If you’re already familiar with them, that won’t hurt, but we don’t think it’s required. One of our main aims with this book is to build an architecture for which specific technology choices become minor implementation details.
Origins of this book:
At the end of Harry’s last book, Test-Driven Development with Python (O’Reilly), he found himself asking a bunch of questions about architecture, such as, What’s the best way of structuring your application so that it’s easy to test? More specifically, so that your core business logic is covered by unit tests, and so that you minimize the number of integration and end-to-end tests you need? He made vague references to “Hexagonal Architecture” and “Ports and Adapters” and “Functional Core, Imperative Shell,” but if he was honest, he’d have to admit that these weren’t things he really understood or had done in practice.
And then he was lucky enough to run into Bob, who has the answers to all these questions. Bob ended up a software architect because nobody else on his team was doing it. He turned out to be pretty bad at it, but he was lucky enough to run into Ian Cooper, who taught him new ways of writing and thinking about code.
Our aim with this book is to introduce several classic architectural patterns and show how they support TDD, DDD, and event-driven services. We hope it will serve as a reference for implementing them in a Pythonic way, and that people can use it as a first step toward further research in this field.
Customers who bought this item also bought
No customer reviews
|5 star (0%)||0%|
|4 star (0%)||0%|
|3 star (0%)||0%|
|2 star (0%)||0%|
|1 star (0%)||0%|
Review this product
Most helpful customer reviews on Amazon.com
Publication Date: 3/5/2020
Disclaimer: I am reviewing my own copy of this book because I want to. The publisher did not provide me with a copy. I promise to be 100% honest in how I feel about this book, both the good and the less so.
About the Book
This is an introductory software engineering book that gives you more hand-on experience than your typical software engineering course. The authors discuss domain-driven design, test-driven development, the basic concepts of object-oriented programming, and general software architecture. It's broken up into two parts: Building an Architecture to Support Domain Modeling and Event-Driven Architecture, with a bit extra thrown in at the end to fill in some gaps. This is an unofficial follow up to one author's previous book, Test-Driven Design in Python.
The first half, on building the architecture, gives you a high level view of your software and about setting it up for success. It starts with an introduction to domain modelling, discusses basic architecture patterns, and gives examples of the Flask API. It finishes with setting up your tests and being ready to add the meat to the bones. The second half, on event-driven architecture, looks at event handling and the message bus that serves of the backbone of your application.
Who is This For and Why Was it Written?
In the preface, the authors claim that you are an experienced Python developer who has developed applications with at least a moderate amount of complexity, You have realized how difficult this can be, but you don't know much if anything about Domain Driven Design or basic architecture patterns.
I would expand this to a slightly wider audience. If you're an advanced undergraduate who has spent their university career working in Python and were not satisfied with your Software Engineering course, this book is for you. If you are about to create your own open source project with even the slightest bit of complexity, this book is for you. If you want to work on or take over an abandoned open source project, this book is for you. There are other people this is for, but I'll end the list here.
I would argue that this book fills a gap left by a LOT of software engineering books. First, it gives you a hands-on experience, so long as you follow the code. Second, is discusses patterns that I never learned in my software engineering course. Third, it gives a good introduction to microservices, which are common right now.
The first part of the book begins as soon as the introduction ends. Half way through the book, they leave the architecture and look at the code running within that architecture. Then it finishes with a series of appendices that fill in missing bits, expand on important topics, or give alternatives to how the main parts of the book handled this topic. One example is how to use Django rather than Flask to achieve the same results.
Within a chapter, there are a page or two that gives you a high level view of the upcoming text. Each chapter comes in at 15-25 pages of clear written prose. Then they finish up with a Wrap-Up (Summary) section where they review what you just read while also giving you a taste of what is to come.
Did This Book Succeed?
I think that this book does very well. As someone who wants to write their own large program without knowing where to start (like so many of us), I picked up this book at just the right time. It's not going to teach you all of software engineering (which they did not claim to do), nor is it going to teach you Python. This is an intermediate level book who want to expand their developer's toolbox. t was well organized, well written, and very much needed, as one of the few books of its kind.
Rating and Final Thoughts
This is a great book, which earns a 5 out of 5. It's the book I need the most right now, as it will let me step up with my Python development. I very much hope that the authors consider collaborating again for a design pattern book for Python. I would expect it to be as well organized and written.
This book covers topics that aren't touched by most python books, and is an excellent resource to help you develop any python program, especially one that needs to get or save data from a database, interact with HTTP requests, or abstract business procedures.
The reason I gave this book so many stars is not only for the topics that needed covering, but also the way they talk about them. The authors discuss the trade offs of the approaches they bring up, which is not done enough in the programming world.
The book is easy to read, they have great exercises you can do on your own to pick up the concepts, and you will become a better programmer after absorbing the ideas in this book.
## This teaches theory in a highly practical way
My experience is completely the OPPOSITE here compared with most theoretical books.
This book is highly practical. In fact, it's so practical, I am highly motivated to re-read certain chapters of this book several times. I have made plenty of notes as well. See the images. Many highly theoretical books, I read once, cannot implement, then put them aside. This includes many 5-star rated books. My experience is entirely different for this book.
## Gradual evolution of architecture across chapters using diagrams
Another good thing about this book is that it shows you the gradual evolution of the architectural patterns across multiple chapters using diagrams of the overall structure. This is very useful as I am a visual person. It makes me feel that I can grok their suggestions but also the reasons behind their suggestions.
## No BS. They emphasize tradeoffs
Many architectural / highly theoretical books either don't talk abt tradeoffs or they simply note that tradeoffs happen and then handwave it to move onto stuff the authors like to talk about.
No such thing here. They go deep into the weeds.
Almost every chapter that covers a new pattern, they will have at least one pros and cons table summarizing the various options. Some chapters have more than one pros and cons because there are multiple key decision points. And the authors go in to explore the full range of options. And then weigh them for you.
It feels like they are right there besides you coaching you step by small step.
## Is this suitable for Django people?
I'm currently using Django professionally for a project that accounts to 50% of my revenue. I expect to be 100% by end of the year. I have been using Django since early 2018 (~2 years). And then I come across this book.
So I say this as an actual Django developer with real stakes: this book is one of the most important software design books in my career. I'm already trying to implement one of the suggestions inside (CQRS). I fully expect to revisit the book several times.
However, do note that the authors (Harry and Bob) are more familiar with Flask. So they write this with Flask in mind. They did seek out experienced Django people to review their book and they wrote up an appendix D to show how you can implement some of their main patterns using Django and why.
So yes, you may need some effort to make this work for you in Django, but it's possible.
Remember this book teaches you new ways to architect. So it's not a copy-paste teaching in the first place. You have to adapt it to your context even if you use Flask.
Nevertheless, this book is so useful because they really go deep into the whys and hows. Which excites me enough to put in extra effort to make some of the patterns work for my Django projects. That doesn't happen for most software books I read.
I recommend go slow, take small steps, and pick the low hanging fruit in your python (Flask or Django) project to adopt some of the patterns.
For me, initially there were a few 2 steps forward 1 step back in terms of adapting. But I see that as part of the learning process. I spoke earlier that I am now adopting some aspects of CQRS in my Django app. The next move for me is likely the adoption of Domain Entity while keeping the Django ActiveRecord ORM pattern. I'll see how it goes.
But I am excited and looking forward to that experiment. Thanks to this book!
This is my second review because my first one got rejected.
I don't have verified purchase because I needed a hardcopy and I got mine from some other online seller due to shipping costs reasons.
If you still are hesitant despite being a Python web developer, I recommend searching for sample chapters that are available by the authors. In fact, it was those sample chapters that tipped the balance for me to buy the hardcopy.
Easily the best purchase for me this 2020.