3 ms·
Objects are a useful pattern. Hiding data behind a suite of methods is great if you need to polymorphically treat a set of disparate data types in the same way,
by bccdee 6y ago
Objects are a useful pattern. Hiding data behind a suite of methods is great if you need to polymorphically treat a set of disparate data types in the same way, or if you want to expose an API to consumers and then change the implementation behind the scenes.
The problem with object-oriented programming IMO is that it demands we use this pattern even when it doesn't make sense. Sometimes you should just use a struct or a function. And when you abstract things that didn't need to be abstracted, your code becomes bloated and hard to understand.
OOP also encourages an outlook where objects are things with agency which do things and have responsibilities. Data should, more often than not, just be data; when you think of data as being the thing that has the agency, you risk winding up with classes like `ThingDoer` that have methods like `ThingDoer.doThing()`.