2 Comments

I like your examples using design patterns in general but I'm looking for your opinion on something.

Considering we are working with a dynamic language like Python, should we embrace duck typing or try to structure code/classes more akin to statically typed languages?

For instance, in your example I've noticed you don't define a common interface (defined as an abstract class in python, as interface classes don't exist) that the concrete algorithms must implement.

I've noticed that examples in python on websites such as https://refactoring.guru/ generally include abstract interfaces and the likes.

What is your take on this? Just keep it simple and take advantage of duck typing?

Thank you Laszlo!

Expand full comment
author

I keep these examples to the absolute minimum, anything that is not absolutely necessary to communicate the main point is left out. So I usually don't do typing and defining abstract interfaces because the concept works without them.

My personal experience is that for at least ML projects these have marginal value (and this is a very narrow and specific experience). But of course by all means define your own internal policy and reason why you do or don't typing/ABCs. And most importantly define the workflows to maintain consistency.

Expand full comment