News for hackers. Stuff that matters.
Re:Do We Worship Complexity? by TeMPOraL on Wednesday October 17, 2018 @11:11AM (#18239815)
> and why you would need it at all.

Because in the functional model, you're not abusing the filesystem or inheritance hierarchy to do your bookkeeping.

Also, I said functions, not necessarily anonymous ones. There are ways to solve this use case. You can stash your actions as named public static functions in a "Commands" class. Or you can create one dummy class with @Functional on its only method, that essentially forwards the call. So in your UI handlers, you do button.setOnAction(new Command(someFunctionSomewhere));, instead of having a separate class for every possible action. You can now find all actions by looking up calls to Command c-tor(s), and you can build subtypes of Command as you need some special functionality. Note that this way, you don't commit yourself early to a huge type hierarchy.

In my experience, even in large projects, Command objects tend to sit in the filesystem, wasting space and people's time. But if you're absolutely sure you'll need this pattern, then go ahead and use it. It just shouldn't be the default, go-to way of solving this problem.

There are no comments on this comment yet.