Ask HN: Is "Stop Writing Classes” still good advice in modern Python?
https://news.ycombinator.com/item?id=35441152I've just saw Jack Diederich's "Stop Writing Classes" talk (2012) for the first time (https://www.youtube.com/watch?v=o9pEzgHorH0). This talk has shown up on HN a few times, but only elicited a big conversation in one thread back in 2012 (https://news.ycombinator.com/item?id=3717715).
One of the main takes is "Don't write classes that could just be a function" (stated in the video as "If a class has two methods and one of them is __init__, it doesn't need to be a class"). But given the addition of dataclasses and typing to python in the last 10 years, is this still good advice for code style?
For a more specific example, I'd prefer to defining a "useless" class for the purpose of typing like this:
@dataclass
class FooFuncParams:
bar: str
baz: int
...
def foofunc(params: FooFuncParams):
...
Rather than having to use overly-permissive typing like this: def foofunc(params: Dict[str, Any]):
...