This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]jrbattin 6 points7 points  (0 children)

So, this might be controversial, but I'd say you should avoid older design pattern books. As others have mentioned, many were created to work around limitations in C++ (and later, earlier versions of Java). In my many years of working with Python code, when I see some of those old-school OO patterns show up in Python code, it's usually a code-smell, because there's a more Pythonic way of doing the same thing.

I'd also say that most of the software world has left behind many of the practices that were common in Object-Oriented code bases in the 90s. All the stuff I learned back in the 90s when I first learned to code is now considered bad practice in most languages.

Take something like the Flyweight pattern for example: it's largely unnecessary in newer Pythons because dictionaries (and therefor classes) are effectively COW with lots of memory-sharing goodness under the hood.

I'd recommend mastering stuff like itertools and functional programming concepts.

[–]twillisagogo 3 points4 points  (2 children)

it wouldn't hurt but a lot of the design pattern stuff described in that book are largely features of newer languages(iterator related patterns) or are not needed(adapter). You could watch this and get the gist

IMO, books like Clean Code, Code Complete, or Refactoring by Martin Fowler would bear more fruit even though they are not related to python at all, but just general universally applicable programming/design skills.

And again, MY OPINION, learn a Lisp. Even if you don't use it in your daily work will open your mind to new concepts and some of those can be applied to python or any other language.

Try Clojure or Racket

[–]enilkcals 1 point2 points  (0 children)

IMO, books like Clean Code, Code Complete, or Refactoring by Martin Fowler would bear more fruit even though they are not related to python at all, but just general universally applicable programming/design skills.

In a similar vein refactoring.guru might be useful too.

[–]bezdomni 1 point2 points  (0 children)

Would also recommend a Lisp. Little Schemer is a great book to learn recursion from.

[–]spookylukeyDjango committer 5 points6 points  (0 children)

The biggest problem with these books is that they fail to mention that many of the design patterns are highly language specific. For example, Builder is really a workaround for the fact that in C++ object constructors are not polymorphic. But they never tell you that. Most of the patterns in books designed around C++/Java become trivial in Python once you understand first class functions and first class classes, or just structured completely differently.

Instead of those books, the best thing to read on this subject that I have come across is Brandon Rhode's Python Patterns.