Ask HN: Why would I use a class over a module for stateless computation?
On the one hand, I don’t want to blindly imitate programmers who are dealing with problems of a different type (or scale) than those I’m dealing with and end up making my own code unnecessarily complex. I sometimes have an imaginary conversation with a composite “seasoned Python programmer” in which I proudly show him code that I’ve written as a collection of classes, and he looks at me quizzically and says, “Why did you write all these classes to solve this problem? I would have just used modules.”
On the other hand, as I’ve matured as a programmer I’ve noticed that my code has started to look more like the code I read, not due to conscious imitation, but because I’ve improved and those improvements have naturally made my code look more like the code of more experienced programmers. If I’m inevitably going to rediscover the reason for using objects when state isn’t an issue, I might as well just be told what I’m missing and save myself some time (and spare my employer the inferior code that I’ll be writing in the interim).