Software Architecture in Python

The online resources for software architecture in Python are few and far between, being self-taught means a lot of searching. so I wanted to take some time and share some of the stuff I’ve come across that may be useful to others interested in software architecture. Here are a few useful links I came across on my journeys:

The Architecture of Open Source Applications: Python Packaging

This is a goldmine. It takes us to a fairly comprehensive guide on packaging in Python. I’ve not read all of this in detail, but I have gleaned the important aspects. It highlights some of the difficulties for Python developers and shows how to set up a setup and distribute a python package. If you then visit the homepage, http://www.aosabook.org, you’ll find 4 books with links to a number of open source projects. The first book ‘500 Lines or Less’, is the perfect place to start. Not all of the examples are in Python, but many are. Open source developers discuss their ideas, designs and thought process as they tackle the project. It is invaluable resource and one definitely worth investing a few dollars in.

Structuring Your Project — The Hitchhiker’s Guide to Python

Another guide to structuring a Python project. I’ve found the Hitchhiker’s guide really useful as an overview of topics. You can delve more deeply into each area with provided links, but this is definitely one to bookmark.

The Clean Architecture in Python — Rhodes Mill

I have taken a look at Uncle Bob’s book ‘Clean Architecture’ and I like a lot of the ideas in their. It’s definitely not for everyone, It could be considered self righteous and preachy, but there are a lot of valid techniques which I’ve been trying to implement into my own code in Python. I would recommend watching the talk Rhodes Mill gave at PyOhio in 2014 as a supplement to the slideshows in this link.

Clean architectures in Python: a step-by-step example — The Digital Cat

It’s difficult to find good examples of software architecture specific to Python without delving into code (which is also a useful exercise) but finding the thought process behind an architecture is like finding gold. blog.thedigitalcatonline is collection of tutorials based on TTD (test driven development) and clean architecture. Definitely worth a read, if not for a few pointers.

Mike Bayer on sqlalchemy

Mike Bayer is the creator of many open source programming libraries for the Python Programming Language, including SQLAlchemy, Alembic Migrations, Mako Templates for Python, and Dogpile Caching. So I would say he knows a thing or two about Software Architecture. Check out Patterns Implemented by SQLAlchemy you can also read his contribution to the aosabook project sqlalchemy mentioned earlier.

Mike highlights a number of Architecture Patterns curated by Martin Fowler in his book Patterns of Enterprise Application Architecture. I was inspired to purchase a copy this week, however there are a number of excepts floating around on various sites. Martin mostly uses Java for readability but the concepts are not language specific.

Writing Documentation in Python

Readability is a primary focus for Python developers, in both project and code documentation. Following some simple best practices can save both you and others a lot of time.

Another Do-It-Yourself-Framework

This article written by Ian Bicking is what got me into Software Architecture in the first place. It was the first time I really thought about how code was organized. Before this, I just followed the conventions of a framework and did whatever the documentation said to do. But Ian unraveled the mystery of a framework and made it something to be explored rather than blindly followed. I started looking into the architecture of different frameworks, Django, Flask, Falcon, in particular webapp2, a lightweight web framework for Python.

Webapp2 used a lot of ideas from Ian Bicking combined with established design patterns, like the front controller pattern, adapter pattern and factory method pattern. The thing that makes webapp2 interesting is how simple the source code is. Reading from top to bottom you can understand what each piece does. The documentation is self explanatory but the source code is even m0re so.

Conclusion

These are just a handful of links I’ve found useful, they each link to other resources so there is a lot to read and learn. If you are self-taught developer like me, who struggles to find the right path there is inspiration to be found here.