A Functional Approach to Java augmenting object-oriented Java code with functional principles
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 l...
Otros Autores: | |
---|---|
Formato: | Libro electrónico |
Idioma: | Inglés |
Publicado: |
Sebastopol, CA :
O'Reilly Media
2023.
|
Edición: | First edition |
Materias: | |
Ver en Biblioteca Universitat Ramon Llull: | https://discovery.url.edu/permalink/34CSUC_URL/1im36ta/alma991009742724106719 |
Tabla de Contenidos:
- 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