Classes, Complexity, and Functional Programming
Kent C. Dodds
2.3K34

Excellent article Kent. I agree life can be simpler with objects and functions.

Classes have a benefit I don’t think you discussed of declaring all the attributes “in one place” and constructors ensure all attributes exist and are initialized. Which could also be resolved by writing a factory function in place of a class constructor.

Passing the object as an argument is how millions of lines of C code were and are written :)

The pattern of passing the object as the first argument is also the syntax Python uses for class methods. Python also does “what you expect” wrt binding when passing an instance method around to callbacks and other functions.

IMO JS’s the binding issue really makes this's behavior unexpected.

Like what you read? Give Steve Schwarz a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.