News for hackers. Stuff that matters.
Re:Write More Classes by fab13n on Tuesday February 12, 2013 @03:20AM (#5205765)
There's a fairly effective rule of thumb: classes--or more accurately objects--are a way to cleanly encapsulate state. If you rely on a mutating state, you probably want an object/class. If not, a function is often better.

Now you can bundle related functions together in a structure, but this structure is morally a module, not an object, let alone a class. Some languages will force you to encode those modules as classes / prototypes / singletons, but that's just a design pattern to circumvent a limitation of the language.

There are no comments on this comment yet.