Pattern 1Replacing Functional Interface

Intent

To encapsulate a bit of program logic so that it can be passed around, stored in data structures, and generally treated like any other first-class construct

Overview

Functional Interface is a basic object-oriented design pattern. It consists of an interface with a single method with a name like run, execute, perform, apply, or some other generic verb. Implementations of Functional Interface perform a single well-defined action, as any method should.

Functional Interface lets us call an object as if it were a function, which lets us pass verbs around our program rather than nouns. This turns the traditional object-oriented view of the world on its head a bit. In the strict object-oriented view, ...

Get Functional Programming Patterns in Scala and Clojure now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.