News for hackers. Stuff that matters.
Re:The use of `class` for things that should be simple free ... by disgruntledphd2 on Thursday May 28, 2020 @04:29AM (#23334877)
Traditionally, I don't really like classes, as I started with a mostly functional language (R).

However, when writing Python (for a poker simulator), I came to the conclusion that objects can actually be really useful for the following reasons: 1) managing state: this is the big one, if you need data with your functions, a class is an obvious way of doing it.

2) documentation: a class with methods is a higher-level structure than a bunch of functions and you are more likely not to forget the existence of a method on a class relative to a function somewhere in your code base (this second idea shamelessly stolen from Martin Fowler).

There are no comments on this comment yet.