You are previewing Functional Thinking.
O'Reilly logo
Functional Thinking

Book Description

If you’re familiar with functional programming basics and want to gain a much deeper understanding, this in-depth guide takes you beyond syntax and demonstrates how you need to think in a new way. Software architect Neal Ford shows intermediate to advanced developers how functional coding allows you to step back a level of abstraction so you can see your programming problem with greater clarity.

Table of Contents

  1. Preface
    1. Chapter Overview
    2. Conventions Used in This Book
    3. Using Code Examples
    4. Safari® Books Online
    5. How to Contact Us
    6. Acknowledgments
  2. 1. Why
    1. Shifting Paradigms
    2. Aligning with Language Trends
    3. Ceding Control to the Language/Runtime
    4. Concision
  3. 2. Shift
    1. A Common Example
      1. Imperative Processing
      2. Functional Processing
    2. Case Study: Number Classification
      1. Imperative Number Classification
      2. Slightly More Functional Number Classification
      3. Java 8 Number Classifier
      4. Functional Java Number Classifier
    3. Common Building Blocks
      1. Filter
      2. Map
      3. Fold/Reduce
    4. Synonym Suffering
      1. Filter
        1. Scala
        2. Groovy
        3. Clojure
      2. Map
        1. Scala
        2. Groovy
        3. Clojure
      3. Fold/Reduce
        1. Scala
        2. Groovy
        3. Clojure
  4. 3. Cede
    1. Iteration to Higher-Order Functions
    2. Closures
    3. Currying and Partial Application
      1. Definitions and Distinctions
      2. In Groovy
      3. In Clojure
      4. Scala
        1. Currying
        2. Partially applied functions
        3. Partial (constrained) functions
      5. Common Uses
        1. Function factories
        2. Template Method design pattern
        3. Implicit values
    4. Recursion
      1. Seeing Lists Differently
    5. Streams and Work Reordering
  5. 4. Smarter, Not Harder
    1. Memoization
      1. Caching
        1. Method-level caching
        2. Caching sum
        3. Caching everything
      2. Adding Memoization
    2. Laziness
      1. Lazy Iterator in Java
      2. Totally Lazy Number Classifier
      3. Lazy Lists in Groovy
        1. Lazy list of perfect numbers
      4. Building a Lazy List
      5. Benefits of Laziness
      6. Lazy Field Initialization
  6. 5. Evolve
    1. Few Data Structures, Many Operations
    2. Bending the Language Toward the Problem
    3. Rethinking Dispatch
      1. Improving Dispatch with Groovy
      2. Clojure’s “Bendable” Language
      3. Clojure Multimethods and a la carte Polymorphism
    4. Operator Overloading
      1. Groovy
      2. Scala
    5. Functional Data Structures
      1. Functional Error Handling
      2. The Either Class
        1. Parsing Roman numerals
        2. Lazy parsing and Functional Java
        3. Providing defaults
        4. Wrapping exceptions
      3. The Option Class
      4. Either Trees and Pattern Matching
        1. Scala pattern matching
        2. Either trees
        3. Pattern matching for tree traversal
  7. 6. Advance
    1. Design Patterns in Functional Languages
    2. Function-Level Reuse
      1. Template Method
      2. Strategy
      3. The Flyweight Design Pattern and Memoization
      4. Factory and Currying
    3. Structural Versus Functional Reuse
      1. Code Reuse Via Structure
        1. Refactoring to eliminate duplication
        2. Code reuse via composition
  8. 7. Practical Thinking
    1. Java 8
      1. Functional Interfaces
      2. Optional
      3. Java 8 Streams
    2. Functional Infrastructure
      1. Architecture
        1. CQRS
      2. Web Frameworks
      3. Databases
  9. 8. Polyglot and Polyparadigm
    1. Combining Functional with Metaprogramming
    2. Mapping Data Types with Metaprogramming
      1. Infinite Streams with Functional Java and Groovy
    3. Consequences of Multiparadigm Languages
    4. Context Versus Composition
    5. Functional Pyramid
  10. Index
  11. Colophon
  12. Copyright