Functional Programming

One of the main reasons why Spring 5.0's framework was created is to fully integrate functional programming when implementing the asynchronous web framework. The so-called functional web framework has a reactive core that has its own annotation, interfaces, and classes for handling requests. Thus, to fully understand reactive programming in Spring is to know the core platform of Java functional programming.

The main idea of functional programming is to build a set of definitions to evaluate computer instructions. Each definition is a concise, single, and atomic expression that calls another occurrence of expressions which, collectively, can give a simplified result. Although functional programming is an old programming methodology based on mathematical principles, it is now being integrated in Java for the purposes of creating a transition from an imperative way of programming to a more reduced, clear, agile and robust style of coding. But aside from the tangible improvements it can give to Spring, functional programming can help developers focus on the problems instead of spending so much time on implementing complex and cluttered low-level implementations.

This chapter will introduce a new face of Java that can be used to solve synchronous and asynchronous Spring web projects.

In this chapter, you will learn the following:

  • Implementing lambda expressions using anonymous inner classes
  • Creating lambda expressions using @FunctionalInterface
  • Building the built-in functional interfaces
  • Applying method and constructor references
  • Using the Stream API
  • Applying streams to collections
  • Applying streams to NIO 2.0
  • Using parallel streams
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.11.227