This isn't to say his underlying message is wrong (I 100% agree with Jack's message, too much classes create unnecessary complexity in your library/app), but I don't want people destroying their classes without fully understanding the consequences.
This isn't to say his underlying message is wrong (I 100% agree with Jack's message, too much classes create unnecessary complexity in your library/app), but I don't want people destroying their classes without fully understanding the consequences.
try:
import simplejson as json
except ImportError:
import json
I'm pretty sure I've seen those exact four lines of code in the internals of Tornado and Flask, among others.He should explicitly catch the ImportError
In plain C, your main "method" can be a simple external function, and the "helpers" can be static functions. Python offers similar functionality.
Making a class is a step backward because the internal helpers have to exposed to users, even if they're intended not to be used.
(The reality is simple. Classes are Python's state-capture abstraction. Using a bunch of lambdas to do the same thing means you are writing Haskell in Python, which is a dumb thing to do, because while the computer knows what you want, other programmers don't. If you want to use Haskell, use Haskell.)