by cheschire · 3y ago · 0 comments
There were a lot of assertions in this article that rubbed me wrong, but this one was particularly egregious. Handlers are behavior. They handle something.
This feels like the kind of article I would've written early in my career when I was getting really clever with stuff and starting to be able to question the way I understood the world of programming.
So, Handlers are functions that "handle something", but they are also part of the app object's state, not its behavior.
An alternate view might be:
Handlers are functions that are part of the app object's state, which alters the app's behavior.
In the majority (possibly overwhelming majority) of the cases this is true. The purpose of Handlers and similar Publisher/Subscriber patterns is effectively to change application behavior when they are configured.
I find that phrasing very fair.
class App {
public IHandlerFoo Foo; // routed as /app/Foo
public IHandlerBar Bar; // routed as /app/Bar
...
}
...
App.Foo = new HandlerFooInstance(...);
...
Foo, Bar, etc. can evolve under an app's state changes, so the handlers to invoke are states of the app. They implement behaviour too, yes, but the original wording isn't wrong either.