Introduction

Object-oriented patterns are a staple of modern software engineering. In this chapter, we’ll take a look at some of the most common ones and the problems they solve. Then we’ll introduce more functional solutions that solve the same sorts of problems that the object-oriented patterns solve.

For each pattern that we introduce, we’ll first look at it in Java. Then we’ll look at a Scala approach that solves the same problems, and finally we’ll wrap up with a look at a Clojure version that does as well.

Sometimes the Scala and Clojure replacements will be quite similar. For instance, the Scala and Clojure solutions in both Pattern 1, Replacing Functional Interface, and Pattern 7, Replacing Strategy, are largely the same. Other times the solutions we explore in these two languages will be quite different but still embody the same functional concept.

The solutions we look at in Pattern 4, Replacing Builder for Immutable Object, for instance, are very different in Scala and Clojure. However, in both cases they show straightforward ways of working with immutable data.

By exploring both the similarities and the differences between Scala and Clojure, you should get a good feel for how each language approaches functional programming and how it differs from the traditional imperative style you may be used to.

Let’s get started with our first pattern, Functional Interface!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.76.204