I don’t know about you, but I write Terrible Code™, a lot.
I’m always banging on about how classes are mainly a namespace because they give me a very neat way of containing that terror whilst I’m working out the details of my code.
I’ve done plenty of functional programming in my time, and I like it, I’m a fan. But my experience is that functional composition gets messier, more quickly, and is harder to both contain, and comprehend, than breaking things up in a class.
I’m not so confident of my own ability to re-grok my nasty code later. Not to mention my juniors.
I can give my nasty class to someone else and say, Just use it so without feeling too bad. My mess of functions, not so much.
I can put my functions in their own module, again a namespace, trading the
self parameter for a separate file, but I’m not convinced that’s a gain.
I can tidy up my code once it’s written. Once I understand the problem domain that is. I might prefer the aesthetics of functions in this case. I can count on my digits the number of times I got there in my career. (Is that an exaggeration?)
Over use of inheritance deserves all the grief it gets. Limited inheritance customising behaviours, though, is awesome. It’s a perfectly good hammer. I'm not just going to throw it away.