Functional Design: Principles, Patterns, and Practices

Book description

A Practical Guide to Better, Cleaner Code with Functional Programming

In Functional Design, renowned software engineer Robert C. Martin ("Uncle Bob") explains how and why to use functional programming to build better systems for real customers. Martin compares conventional object-oriented coding structures in Java to those enabled by functional languages, identifies the best roles for each, and shows how to build better systems by judiciously using them in context.

Martin's approach is pragmatic, minimizing theory in favor of "in the-trenches" problem-solving. Through accessible examples, working developers will discover how the easy-to-learn, semantically rich Clojure language can help them improve code cleanliness, design, discipline, and outcomes. Martin examines well-known SOLID principles and Gang of Four Design Patterns from a functional perspective, revealing why patterns remain extremely valuable to functional programmers, and how to use them to achieve superior results.

  • Understand functional basics: immutability, persistent data, recursion, iteration, laziness, and statefulness

  • Contrast functional and object approaches through expertly crafted case studies

  • Explore functional design techniques for data flow

  • Use classic SOLID principles to write better Clojure code

  • Master pragmatic approaches to functional testing, GUIs, and concurrency

  • Make the most of design patterns in functional environments

  • Walk through building an enterprise-class Clojure application

"Functional Design exudes 'classic-on-arrival'. Bob pulls back the curtain to reveal how functional programming elements make software design simple yet pragmatic. He does so without alienating experienced object-oriented programmers coming from languages like C#, C++, or Java."

--Janet A. Carr, Independent Clojure Consultant

Register your book for convenient access to downloads, updates, and/or corrections as they become available. See inside book for details.

Table of contents

  1. Cover Page
  2. About This eBook
  3. Halftitle Page
  4. Title Page
  5. Copyright Page
  6. Dedication
  7. Contents
  8. Foreword
  9. Preface
    1. A Brief History of Functional and Procedural Programming
    2. On Clojure
    3. On Architecture and Design
    4. On Object Orientation
    5. On “Functional”
  10. Acknowledgments
  11. About the Author
  12. I: Functional Basics
    1. 1. Immutability
      1. What Is Functional Programming?
      2. The Problem with Assignment
      3. So Why Is It Called Functional?
      4. No Change of State?
      5. Immutability
    2. 2. Persistent Data
      1. On Cheating
      2. Making Copies
      3. Structural Sharing
    3. 3. Recursion and Iteration
      1. Iteration
      2. Recursion
    4. 4. Laziness
      1. Lazy Accumulation
      2. OK, but Why?
      3. Coda
    5. 5. Statefulness
      1. When We MUST Mutate
      2. Software Transactional Memory (STM)
      3. Life Is Hard, Software Is Harder
  13. II: Comparative Analysis
    1. 6. Prime Factors
      1. Java Version
      2. Clojure Version
      3. Conclusion
    2. 7. Bowling Game
      1. Java Version
      2. Clojure Version
      3. Conclusion
    3. 8. Gossiping Bus Drivers
      1. Java Solution
      2. Clojure
      3. Conclusion
    4. 9. Object-Oriented Programming
      1. Functional Payroll
      2. Namespaces and Source Files
      3. Conclusion
    5. 10. Types
      1. Conclusion
  14. III: Functional Design
    1. 11. Data Flow
    2. 12. Solid
      1. The Single Responsibility Principle (SRP)
      2. The Open-Closed Principle (OCP)
      3. The Liskov Substitution Principle (LSP)
      4. The Interface Segregation Principle (ISP)
      5. The Dependency Inversion Principle (DIP)
  15. IV: Functional Pragmatics
    1. 13. Tests
      1. But What about the REPL?
      2. What about Mocks?
      3. Property-Based Testing
      4. A Diagnostic Technique
      5. Functional
    2. 14. GUI
      1. Turtle-Graphics in Quil
    3. 15. Concurrency
      1. Conclusion
  16. V: Design Patterns
    1. 16. Design Patterns Review
      1. Patterns in Functional Programming
      2. Abstract Server
      3. Adapter
      4. Command
      5. Composite
      6. Decorator
      7. Visitor
      8. Abstract Factory
      9. Conclusion
      10. Postscript: OO Poison?
  17. VI: Case Study
    1. 17. Wa-Tor
      1. Scratch That Itch
      2. Showers Solve Problems
      3. It’s Time to Wildly Reproduce
      4. What about the Sharks?
      5. Conclusion
  18. Afterword
  19. Index
  20. Code Snippets

Product information

  • Title: Functional Design: Principles, Patterns, and Practices
  • Author(s): Robert C. Martin
  • Release date: October 2023
  • Publisher(s): Addison-Wesley Professional
  • ISBN: 9780138176518