Limit search to available items
Book Cover
E-book
Author Weidig, Ben, author

Title A Functional Approach to Java : augmenting object-oriented Java code with functional principles / Ben Weidig
Edition First edition
Published Sebastopol, CA : O'Reilly Media, 2023
©2023

Copies

Description 1 online resource
Contents Intro -- Copyright -- Table of Contents -- Preface -- New Hardware Needs a New Way of Thinking -- Java Can Be Functional, Too -- Why I Wrote This Book -- Who Should Read This Book -- What You Will Learn -- What about Android? -- A Functional Approach to Android -- Navigating This Book -- Conventions Used in This Book -- Using Code Examples -- O'Reilly Online Learning -- Acknowledgments -- Part I. Functional Basics -- Chapter 1. An Introduction to Functional Programming -- What Makes a Language Functional? -- Functional Programming Concepts -- Pure Functions and Referential Transparency
Immutability -- Recursion -- First-Class and Higher-Order Functions -- Functional Composition -- Currying -- Partial Function Application -- Lazy Evaluation -- Advantages of Functional Programming -- Disadvantages of Functional Programming -- Takeaways -- Chapter 2. Functional Java -- What Are Java Lambdas? -- Lambda Syntax -- Functional Interfaces -- Lambdas and Outside Variables -- What about Anonymous Classes? -- Lambdas in Action -- Creating Lambdas -- Calling Lambdas -- Method References -- Functional Programming Concepts in Java -- Pure Functions and Referential Transparency -- Immutability
First-Class Citizenship -- Functional Composition -- Lazy Evaluation -- Takeaways -- Chapter 3. Functional Interfaces of the JDK -- The Big Four Functional Interface Categories -- Functions -- Consumers -- Suppliers -- Predicates -- Why So Many Functional Interface Variants? -- Function Arity -- Primitive Types -- Bridging Functional Interfaces -- Functional Composition -- Extending Functional Support -- Adding Default Methods -- Implementing Functional Interfaces Explicitly -- Creating Static Helpers -- Takeaways -- Part II. A Functional Approach -- Chapter 4. Immutability
Mutability and Data Structures in OOP -- Immutability (Not Only) in FP -- The State of Java Immutability -- java.lang.String -- Immutable Collections -- Primitives and Primitive Wrappers -- Immutable Math -- Java Time API (JSR-310) -- Enums -- The final Keyword -- Records -- How to Achieve Immutability -- Common Practices -- Takeaways -- Chapter 5. Working with Records -- Data Aggregation Types -- Tuples -- A Simple POJO -- From POJO to Immutability -- From POJO to Record -- Records to the Rescue -- Behind the Scenes -- Record Features -- Missing Features -- Use Cases and Common Practices
Record Validation and Data Scrubbing -- Increasing Immutability -- Creating Modified Copies -- Records as Local Nominal Tuples -- Better Optional Data Handling -- Serializing Evolving Records -- Record Pattern Matching (Java 19+) -- Final Thoughts on Records -- Takeaways -- Chapter 6. Data Processing with Streams -- Data Processing with Iteration -- External Iteration -- Internal Iteration -- Streams as Functional Data Pipelines -- Stream Features -- Spliterator, the Backbone of Streams -- Building Stream Pipelines -- Creating a Stream -- Doing the Work -- Terminating the Stream
Summary Java developers usually tackle the complexity of software development through object-oriented programming (OOP). But not every problem is a good match for OOP. The functional programming (FP) paradigm offers you another approach to solving problems, and Java provides easy-to-grasp FP tools such as lambda expressions and Streams. If you're interested in applying FP concepts to your Java code, this book is for you. Author Ben Weidig highlights different aspects of functional programming and shows you how to incorporate them into your code without going "fully functional." You'll learn how, when, and why to use FP concepts such as immutability and pure functions to write more concise, reasonable, and future-proof code. Many developers seek to expand their horizons by using OOP and FP together. It's no longer either-or; it's both. In this book, you will: Get a high-level overview of functional programming, including the types already available to Java developers Explore different FP concepts and learn how to use them Learn how to augment your code and use Java's new functional features in your daily work without going fully functional Develop a functional mindset and improve your programming skills regardless of language or paradigm
Notes Includes index
Description based on online resource; title from digital title page (viewed on June 22, 2023)
Subject Functional programming (Computer science)
Java (Computer program language)
Object-oriented programs (Computer programs)
Functional programming (Computer science)
Java (Computer program language)
Object-oriented programs (Computer programs)
Form Electronic book
ISBN 9781098109899
1098109899