4 ms·
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
by disgruntledphd2 6y ago
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).