Book Image

Mastering JavaScript Functional Programming

By : Federico Kereki
Book Image

Mastering JavaScript Functional Programming

By: Federico Kereki

Overview of this book

Functional programming is a programming paradigm for developing software using functions. Learning to use functional programming is a good way to write more concise code, with greater concurrency and performance. The JavaScript language is particularly suited to functional programming. This book provides comprehensive coverage of the major topics in functional programming with JavaScript to produce shorter, clearer, and testable programs. You’ll delve into functional programming; including writing and testing pure functions, reducing side-effects, and other features to make your applications functional in nature. Specifically, we’ll explore techniques to simplify coding, apply recursion for loopless coding, learn ways to achieve immutability, implement design patterns, and work with data types. By the end of this book, you’ll have developed the JavaScript skills you need to program functional applications with confidence.
Table of Contents (22 chapters)
Title Page
About the Author
About the Reviewer
Customer Feedback
Connecting Functions - Pipelining and Composition
Answers to Questions

Chapter 11. Implementing Design Patterns - The Functional Way

In Chapter 10, Ensuring Purity - Immutability, we saw several functional techniques to solve different problems. However, programmers who are used to employing OOP may find that we have missed some well-known formulae and solutions, which are often used in imperative coding. Since design patterns are well known, and programmers will be likely already be aware of how they are applied in other languages, it's important to take a look at how a functional implementation would be done.

In this chapter, we shall consider the solutions implied by design patterns, which are common in OOP to see their equivalences in FP. In particular, we will study the following topics:

  • The concept of design patternsand to what they apply
  • A few OOP standard patterns and what alternative we have in FP, if we need one
  • A discussion about FP design patterns, not related to the OOP ones