6

I get it. Functional code is still kind of considered the "new hotness" in languages like Java, but THAT DOESN'T MEAN YOU NEED TO CRAM IT IN EVERYWHERE FOR THE SAKE OF IT. If in doubt, *please* go for the simpler, classic option...

Just inherited a code base that's full of things like this:

Optional.of(getResult()).filter(s -> s.equals(true)).ifPresent(s -> callService());
Optional.of(getResult()).filter(s -> s.equals(false)).ifPresent(s -> logError());

Comments
  • 6
    If you think that is functional code then you don't know what functional means
  • 2
    @host127001 Absolutely. I'm just not really sure of a good name for "code using functional libraries in a way that's definitely not functional"...
  • 0
    That little fuckery is called "fluent" code writing.
    Google apply it in a lot if Android code, mostly the "Builder pattern".
  • 1
    @AlmondSauce i'd call it "not understanding what optional is and jerking all over labdas"
Add Comment