Book Review: Learning Python Design Patterns

Review

Learning Python Design Patterns book cover

Title: Learning Python Design Patterns

Author(s): Gennadiy Zlobin

Python is both a scripted language, and at times a quite peculiar specimen compared with other scripted languages, but I really like using it. I wanted to see how people implement the classic Gang of Four design patterns, so I grabbed this book... not looking in detail the publication date. After reading a few chapters, I was thinking "what an obsolete and at times weird Python code..." and then I noticed that the book was written in 2013 😅.

For context, I began working with Python directly in Python 3, having only dealt with Python 2 in migrations to 3. So, "the old ways" might have been darker and/or more limited, but as of 2024, beware of what you will find inside the book's pages: here be dragons.

It is a quick read: 10 patterns explained both theory and an example alongside just over 100 pages. The explanations are very concise and overall good. The patterns covered are:

  • MVC
  • Singleton
  • Factory
  • Factory Method
  • Abstract Factory
  • Facade
  • Proxy
  • Observer
  • Command
  • Template

And for each one, you get one implementation example, and a few also some tiny chunks of code while explaining the pattern. But to me, the main issue is that half of the examples either have no object orientation, or weird and hacky ways of implementing them. There are at least two typos, and an example or two are too finely "crafted" to work exactly and only given the proposed scenario (e.g. Singletons break if you try to instantiate them with non-empty set arguments). And in general, I felt that half of the chosen examples were a bit too convoluted to showcase the design pattern; there are way simpler things to demonstrate how to use any of them.

In summary, I think that while full of good intentions, the book could be better, and its code has aged badly, so you'll be better off on your own doing searches like "how do I implement the XXXXX design pattern in Python?".

Tags: Books Development Patterns & Practices Python Reviews

Book Review: Learning Python Design Patterns article, written by Kartones. Published @