Architecture Patterns with Python: Becoming a Software Developer

The complete guide to Software Engineering in Python: you will learn how to do Test Driven Development in python, what Domain-Driven Design is , and how to craft Event-Driven Micro-services: Build large and complex applications in this amazing programming language.

architecture patterns with python free pdf

The following is a review of the book Architecture Patterns with Python: Enabling Test-Driven Development, Domain-Driven Design, and Event-Driven Microservices by Harry J.W Percival and Bob Gregory.

Architecture Patterns with Python review: is it right for you?

This book suits Python developers who have built applications and now struggle with tangled business rules, persistence, and tests. It focuses on managing complexity through boundaries and abstractions. You do not need every pattern in every project.

Using Python for machine learning? Read the free Starter Kit excerpt on test sets before your first model. No email required; the full Starter Kit costs €19.

Review

From Machine Learning engineers, to Data Scientists, Analyst, Web Developers or App creators. All of them in the end dedicate a great deal of their time to writing code.

All of them fall under the umbrella of Software Engineers, and should always deliver optimal, well designed code that leads to awesome, robust applications or services.

The useful starting point is a concrete maintenance problem: business logic that is hard to test without a database, changes that ripple across modules, or unclear ownership of state. Architecture is easier to evaluate when it solves a problem you can describe.

With this previous experience you can and probably build easy and well contained applications with no problem, however, when things start getting a little bit more complex, you will quickly be overwhelmed, and lacking the knowledge to tackle a larger project.

Architecture Patterns with Python is the bridge between those easy, self-contained applications, and more complex and larger implementations.

The book develops domain modeling, dependency inversion, repositories, units of work, and message handling through an extended example. Treat these as design options with costs as well as benefits; additional layers can make a small script harder to understand.

Harry Percival and Bob Gregory illustrate these patterns in Python. Follow the example and its tests, then identify which dependency each new abstraction isolates. The main 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

To practise test-driven development, first express a business rule as a failing test, implement the smallest change that satisfies it, and refactor while the tests stay green. This is most useful when the test captures observable behavior rather than private implementation details.

Overall, it is a great book introduction to learn about proper professional software development. The authors provide great examples and have an excellent way of writing that makes the book like a little story, keeping it short and to the point. Lets learn a little bit more about it!

Illustration of the 90-day machine learning roadmap PDF

Stay on track. Get the Roadmap.

Download the 90-Day Roadmap PDF + get weekly tips and resources to help you succeed

Contents

The contents of Architecture Patterns with Python are the following:

I – Building an Architecture to Support Domain Modelling

II – Event Driven Architecture

To end the book we can find an epilogue, a Summary Diagram and Table, a templete project structure, and some Django Resources, and an explanation on Validation.

You can read Architecture Patterns with Python free on the official Cosmic Python website. Use its linked code alongside the text and follow the setup instructions for the chapter you are reading.

Also, you can find the official website of one of the authors (Harry Percival) here: Obey The Testing Goat Website.

About the book

Authors: Harry J.W. Percival, Bob Gregory
Publisher: O’Reilly
Publication Date: 3/5/2020

Pages: 304

Who is this book for?


In the preface of the book, the authors claim that readers of Architecture Patterns with Python should be developers with previous experience building applications of medium complexity, and that have experience in first person the pain that comes from trying to build large apps without the proper knowledge.

While this is true (if you have experience these problems you will probably be more aware of the need of proper design and architecture of software applications), we would expand this to the larger audencie of those that have worked with Python and want to know the guts of software development, how to create awesome projects, and how to scale up the complexity of the apps you can create, or the knowledge you have obtained from previous Python Programming Courses.

If you are looking to start with Python, this is definitely no the book for you. Take a look at our list of reviewed Python books or Python Courses to find something more appropriate.

This book is a great introduction to software engineering book, that gives you a hands-on experience, so long as you follow the code. Also, it discusses patterns that are left outside many software engineering courses and it gives a good introduction to microservices, which are very common and widely used right now.

Summary

For a machine-learning application, try separating prediction logic from file loading and the web endpoint. Test the logic with small fixtures, then add integration tests for the surrounding system. Our guide to deploying machine-learning models provides a related production perspective.

It will teach you many important keys of Software Development without crushing your head or over-complicating, while touching some topics that are most times left outside a normal software engineering track.

The material is very accessible with tests and code samples throughout and all code available online to download and run as you work through it. By reading it you will develop an understanding of how to design software applications, which architecture pattern fits your application the best, and how to properly implement it.

It’s a thoroughly worthwhile read for team that needs to build complex applications with many components, and handle scalability, efficiency, and elegancy. You can find it on Amazon here.

Other resources to consider before, while, or after reading Architecture Patterns With Python:

Thank you so much for reading How to Learn Machine Learning.

Subscribe to our awesome newsletter to get the best content on your journey to learn Machine Learning, including some exclusive free goodies!

HOW IS MACHINE LEARNING