This is the fifth in a series of posts introducing co.unruly.control, a functional control library for Java. You can find the introductory post here, a critique of different ways to represent failure here, an an overview of carpet-oriented programming - abstracting control flow with Optionals - here, and an argument for implementing rich behaviour on datatypes using standalone functions instead of methods here.
So. You’re on board with using functions instead of methods, and you start applying that approach. Most likely, you’ll find that your code is bitty and clunky - it just doesn’t flow like it did when you were happily chaining methods.
Let’s explore that.
Functions? More like clunk-tions!
Using functions instead of methods looks fine in isolation, but the moment you want to do something more complex - like building a carpet-oriented programming pipe - the functional approach starts to get much harder to read.