picostitch
crafting (and) JavaScript

Don't make objects that end with 'er'

I was about to write a "Handler" class. But I remembered that the "er" classes are not so good.

And I mean, think about it. Even if it is a RequestHandler it still can do lots of things and can have many reasons to change, which breaks the Single Responsibility Principle. So I searched for it and found this article.

the jst of OOP is that we bind behavior to data

noted

in nearly every "er" object case, there was a better name for it. And that giving it a better name would tend to make the design more encapsulated, less spaghetti code, in short more object oriented

now we are getting to the meat :)

Take some sort of "Loader" for example. The focus here is on the unit of work it does. [...] Now instead replace that with a LoadRecord and a LoadStream. I'm reasonably confident you'll end up with something that is more akin to what the original Founding Fathers of OOP had in mind.

A simple example: Loader => LoadRecord

Until you apply the mindset for a while though, you'll never really know.

That is so true for a lot of things, and also a good reason why I do believe that katas have a value.
Just read the article, it's quite short and compact but has some nice examples in it.