In this Meetup Victor Perepelitsky - R&D Technical Leader at LivePerson leading the 'Real Time Event Processing Platform' team , will talk about Java 8', 'Stream API', 'Lambda', and 'Method reference'.
Victor will clarify what functional programming is and how can you use java 8 in order to create better software.
Victor will also cover some pain points that Java 8 did not solve regarding functionality and see how you can work around it.
This document contains the slides for a presentation on Java 8 Lambdas and Streams. The presentation will cover lambdas, including their concept, syntax, functional interfaces, variable capture, method references, and default methods. It will also cover streams. The slides provide some incomplete definitions that will be completed during the presentation. Questions from attendees are welcome. A quick survey asks about past experience with lambdas and streams.
Lambda expressions, default methods in interfaces, and the new date/time API are among the major new features in Java 8. Lambda expressions allow for functional-style programming by treating functionality as a method argument or anonymous implementation. Default methods add new capabilities to interfaces while maintaining backwards compatibility. The date/time API improves on the old Calendar and Date APIs by providing immutable and easier to use classes like LocalDate.
Introduction to functional programming with java 8JavaBrahman
Recently gave a presentation in a Java Meetup in Bangalore on basics of functional programming, new functional features in Java 8, and introduction to the basic concepts of functional interfaces and lambda expressions...
Functional programming in Java 8 allows for:
1) The use of lambda expressions and streams for a more declarative programming style without iteration.
2) Functional interfaces like Function, Predicate, and Consumer along with lambda expressions enable function composition and chaining.
3) Features like immutable collections help reduce mutability and side effects, important aspects of functional programming.
Introduction of Java 8 with emphasis on Lambda Expressions and StreamsEmiel Paasschens
Lambda expressions and streams are major new features in Java 8. Lambda expressions allow treating functionality as a method argument or variable. Streams provide a new way to process collections of objects in a declarative way using intermediate and terminal operations. The document provides examples of lambda expressions, method references, functional interfaces, default methods on interfaces, and stream operations like filter, map, and reduce.
Presentation provides introduction and detailed explanation of the Java 8 Lambda and Streams. Lambda covers with Method references, default methods and Streams covers with stream operations,types of streams, collectors. Also streams are elaborated with parallel streams and benchmarking comparison of sequential and parallel streams.
Additional slides are covered with Optional, Splitators, certain projects based on lambda and streams
In this Meetup Victor Perepelitsky - R&D Technical Leader at LivePerson leading the 'Real Time Event Processing Platform' team , will talk about Java 8', 'Stream API', 'Lambda', and 'Method reference'.
Victor will clarify what functional programming is and how can you use java 8 in order to create better software.
Victor will also cover some pain points that Java 8 did not solve regarding functionality and see how you can work around it.
This document contains the slides for a presentation on Java 8 Lambdas and Streams. The presentation will cover lambdas, including their concept, syntax, functional interfaces, variable capture, method references, and default methods. It will also cover streams. The slides provide some incomplete definitions that will be completed during the presentation. Questions from attendees are welcome. A quick survey asks about past experience with lambdas and streams.
Lambda expressions, default methods in interfaces, and the new date/time API are among the major new features in Java 8. Lambda expressions allow for functional-style programming by treating functionality as a method argument or anonymous implementation. Default methods add new capabilities to interfaces while maintaining backwards compatibility. The date/time API improves on the old Calendar and Date APIs by providing immutable and easier to use classes like LocalDate.
Introduction to functional programming with java 8JavaBrahman
Recently gave a presentation in a Java Meetup in Bangalore on basics of functional programming, new functional features in Java 8, and introduction to the basic concepts of functional interfaces and lambda expressions...
Functional programming in Java 8 allows for:
1) The use of lambda expressions and streams for a more declarative programming style without iteration.
2) Functional interfaces like Function, Predicate, and Consumer along with lambda expressions enable function composition and chaining.
3) Features like immutable collections help reduce mutability and side effects, important aspects of functional programming.
Introduction of Java 8 with emphasis on Lambda Expressions and StreamsEmiel Paasschens
Lambda expressions and streams are major new features in Java 8. Lambda expressions allow treating functionality as a method argument or variable. Streams provide a new way to process collections of objects in a declarative way using intermediate and terminal operations. The document provides examples of lambda expressions, method references, functional interfaces, default methods on interfaces, and stream operations like filter, map, and reduce.
Presentation provides introduction and detailed explanation of the Java 8 Lambda and Streams. Lambda covers with Method references, default methods and Streams covers with stream operations,types of streams, collectors. Also streams are elaborated with parallel streams and benchmarking comparison of sequential and parallel streams.
Additional slides are covered with Optional, Splitators, certain projects based on lambda and streams
Introduction to functional idioms in Java 8, language-extending functional libraries and short overview of reasons for adoption of such programming style.
Examples and snippets available here: https://github.com/lbialy/functionaljava8
Java is Object Oriented Programming. Java 8 is the latest version of the Java which is used by many companies for the development in many areas. Mobile, Web, Standalone applications.
Cover Basic concept for Functional Programming in Java. Define new functional interfaces, lambda expressions, how to translate lambda expression, JVM deal with new byte code etc. This is not the perfect slides for functional programming, but trying cover simple basic functional programming.
Java 8 Streams And Common Operations By Harmeet Singh(Taara)Harmeet Singh(Taara)
In this, we are discuss about Java 8 Streams. Common Operations . Java 8 Streams are huge topic, so i am not cover all the things, but try to cover the basics operations of Streams. Before this, please refer my previous presentation "Functional programming in java 8", because of clear some basic concept for functional programming. For the reference use Java 8 API docs.
Lambda expressions allow implementing functional interfaces using anonymous functions. Method references provide a shorthand syntax for referring to existing methods as lambda expressions. The Stream API allows functional-style operations on streams of values, including intermediate and terminal operations. The new Date/Time API provides a safer and more comprehensive replacement for the previous date/time classes in Java.
Java 8 will include many new features including lambdas, default methods on interfaces, and a date/time API. Lambdas allow implementing functional interfaces with expression syntax rather than anonymous classes, and method references allow referring to methods without invoking them. Default methods allow adding new functionality to interfaces without breaking existing implementations. The new date/time API in JSR-310 provides improved date/time handling functionality.
This document contains the notes from a presentation on best practices for Java 8. It discusses 10 topics: 1) general adoption of Java 8, 2) lambdas and method references, 3) functional interfaces, 4) Optional, 5) streams and collections, 6) streams outside of collections, 7) functional programming with strings, 8) parallel streams, 9) simplifying design patterns with functional programming, and 10) other Java 8 features. For each topic, it provides high-level best practices such as preferring method references to lambdas, avoiding null returns, and testing that parallel streams provide real performance benefits.
Java 8 came out early last year and Java 7 is now, at the end of life, making Java 8 the only Oracle supported option. However, since developers value stability over trendiness, many of us are still working with Java 7, or even 6. Let’s look at some features of Java 8, and provide some arguments to persuade your code to upgrade with best practices.
The document discusses lambda expressions in Java 8. It defines lambda expressions as anonymous functions that can be passed around as method parameters or returned from methods. Lambda expressions allow treating functions as first-class citizens in Java by letting functions be passed around as arguments to other functions. The document provides examples of lambda expressions in Java 8 and how they can be used with functional interfaces, method references, the forEach() method, and streams. It also discusses scope and type of lambda expressions and provides code samples demonstrating streams and stream pipelines.
Slides from my JAX London 2016 talk, discussing how the new features affect library design. Follows on from the Java SE 8 Best Practices talk - http://www.slideshare.net/scolebourne/java-se-8-best-practices-53975908
The document discusses new features introduced in Java 8, including allowing static and default methods in interfaces, lambda expressions, and the Stream API. Key points include: interfaces can now contain static and default methods; lambda expressions provide a concise way to implement functional interfaces and allow passing code as a method argument; and the Stream API allows operations on sequences of data through intermediate and terminal operations.
The document discusses lambda expressions in Java 8. It provides background on the lambda calculus and functional programming. Lambda expressions allow anonymous functions and are implemented using functional interfaces in Java 8. This enables a more functional style of programming. Lambda expressions can access variables from their enclosing scope and method references provide a concise way to pass existing methods. The streams API allows functional-style operations on collections and supports sequential and parallel processing.
The document is a presentation on lambda expressions in Java 8 given by Isaac Carter. It introduces lambda expressions and functional programming concepts in Java 8 such as functional interfaces, streams, and method references. It provides examples of using lambda expressions with common Java 8 APIs like forEach(), Predicate, and stream(). The presentation emphasizes thinking declaratively rather than imperatively in Java 8 and leveraging lambda expressions to let Java do more of the work.
Actors are a model of concurrent computation that treats isolated "actors" as the basic unit. Actors communicate asynchronously by message passing and avoid shared state. This model addresses issues in Java's thread/lock model like deadlocks. In Gpars, actors include stateless actors like DynamicDispatchActor and stateful actors like DefaultActor. The demo shows examples of stateless and stateful actors in Gpars.
The document discusses Java 8 features like lambda expressions, streams, and method references. It provides examples of filtering a list of books by pages or genre using lambda expressions and streams. Lambda expressions allow implementing functional interfaces concisely without anonymous classes. Streams provide a way to process data elements sequentially and support operations like filtering, mapping, matching, reducing, and collecting results.
Default methods and static methods allow interfaces to define new methods without breaking existing implementations. The lambda expressions feature introduces functional programming to Java through functional interfaces like Consumer and Function. The streams API provides a functional-style way to process and analyze collections through parallelization, optional return values, and collectors.
The document discusses the introduction and advantages of lambda expressions and functional programming in Java 8. Some key points include:
- Lambda expressions allow passing behaviors as arguments to methods, simplifying code by removing bulky anonymous class syntax. This enables more powerful and expressive APIs.
- Streams provide a way to process collections of data in a declarative way, leveraging laziness to improve efficiency. Operations can be pipelined for fluent processing.
- Functional programming with immutable data and avoidance of side effects makes code more modular and easier to reason about, enabling optimizations like parallelism. While not natively supported, Java 8 features like lambda expressions facilitate a more functional approach.
In Java 8, the java.util.function has numerous built-in interfaces. Other packages in the Java library (notably java.util.stream package) make use of the interfaces defined in this package. Java 8 developers should be familiar with using key interfaces provided in this package. This presentation provides an overview of four key functional interfaces (Consumer, Supplier, Function, and Predicate) provided in this package.
Introduction to functional idioms in Java 8, language-extending functional libraries and short overview of reasons for adoption of such programming style.
Examples and snippets available here: https://github.com/lbialy/functionaljava8
Java is Object Oriented Programming. Java 8 is the latest version of the Java which is used by many companies for the development in many areas. Mobile, Web, Standalone applications.
Cover Basic concept for Functional Programming in Java. Define new functional interfaces, lambda expressions, how to translate lambda expression, JVM deal with new byte code etc. This is not the perfect slides for functional programming, but trying cover simple basic functional programming.
Java 8 Streams And Common Operations By Harmeet Singh(Taara)Harmeet Singh(Taara)
In this, we are discuss about Java 8 Streams. Common Operations . Java 8 Streams are huge topic, so i am not cover all the things, but try to cover the basics operations of Streams. Before this, please refer my previous presentation "Functional programming in java 8", because of clear some basic concept for functional programming. For the reference use Java 8 API docs.
Lambda expressions allow implementing functional interfaces using anonymous functions. Method references provide a shorthand syntax for referring to existing methods as lambda expressions. The Stream API allows functional-style operations on streams of values, including intermediate and terminal operations. The new Date/Time API provides a safer and more comprehensive replacement for the previous date/time classes in Java.
Java 8 will include many new features including lambdas, default methods on interfaces, and a date/time API. Lambdas allow implementing functional interfaces with expression syntax rather than anonymous classes, and method references allow referring to methods without invoking them. Default methods allow adding new functionality to interfaces without breaking existing implementations. The new date/time API in JSR-310 provides improved date/time handling functionality.
This document contains the notes from a presentation on best practices for Java 8. It discusses 10 topics: 1) general adoption of Java 8, 2) lambdas and method references, 3) functional interfaces, 4) Optional, 5) streams and collections, 6) streams outside of collections, 7) functional programming with strings, 8) parallel streams, 9) simplifying design patterns with functional programming, and 10) other Java 8 features. For each topic, it provides high-level best practices such as preferring method references to lambdas, avoiding null returns, and testing that parallel streams provide real performance benefits.
Java 8 came out early last year and Java 7 is now, at the end of life, making Java 8 the only Oracle supported option. However, since developers value stability over trendiness, many of us are still working with Java 7, or even 6. Let’s look at some features of Java 8, and provide some arguments to persuade your code to upgrade with best practices.
The document discusses lambda expressions in Java 8. It defines lambda expressions as anonymous functions that can be passed around as method parameters or returned from methods. Lambda expressions allow treating functions as first-class citizens in Java by letting functions be passed around as arguments to other functions. The document provides examples of lambda expressions in Java 8 and how they can be used with functional interfaces, method references, the forEach() method, and streams. It also discusses scope and type of lambda expressions and provides code samples demonstrating streams and stream pipelines.
Slides from my JAX London 2016 talk, discussing how the new features affect library design. Follows on from the Java SE 8 Best Practices talk - http://www.slideshare.net/scolebourne/java-se-8-best-practices-53975908
The document discusses new features introduced in Java 8, including allowing static and default methods in interfaces, lambda expressions, and the Stream API. Key points include: interfaces can now contain static and default methods; lambda expressions provide a concise way to implement functional interfaces and allow passing code as a method argument; and the Stream API allows operations on sequences of data through intermediate and terminal operations.
The document discusses lambda expressions in Java 8. It provides background on the lambda calculus and functional programming. Lambda expressions allow anonymous functions and are implemented using functional interfaces in Java 8. This enables a more functional style of programming. Lambda expressions can access variables from their enclosing scope and method references provide a concise way to pass existing methods. The streams API allows functional-style operations on collections and supports sequential and parallel processing.
The document is a presentation on lambda expressions in Java 8 given by Isaac Carter. It introduces lambda expressions and functional programming concepts in Java 8 such as functional interfaces, streams, and method references. It provides examples of using lambda expressions with common Java 8 APIs like forEach(), Predicate, and stream(). The presentation emphasizes thinking declaratively rather than imperatively in Java 8 and leveraging lambda expressions to let Java do more of the work.
Actors are a model of concurrent computation that treats isolated "actors" as the basic unit. Actors communicate asynchronously by message passing and avoid shared state. This model addresses issues in Java's thread/lock model like deadlocks. In Gpars, actors include stateless actors like DynamicDispatchActor and stateful actors like DefaultActor. The demo shows examples of stateless and stateful actors in Gpars.
The document discusses Java 8 features like lambda expressions, streams, and method references. It provides examples of filtering a list of books by pages or genre using lambda expressions and streams. Lambda expressions allow implementing functional interfaces concisely without anonymous classes. Streams provide a way to process data elements sequentially and support operations like filtering, mapping, matching, reducing, and collecting results.
Default methods and static methods allow interfaces to define new methods without breaking existing implementations. The lambda expressions feature introduces functional programming to Java through functional interfaces like Consumer and Function. The streams API provides a functional-style way to process and analyze collections through parallelization, optional return values, and collectors.
The document discusses the introduction and advantages of lambda expressions and functional programming in Java 8. Some key points include:
- Lambda expressions allow passing behaviors as arguments to methods, simplifying code by removing bulky anonymous class syntax. This enables more powerful and expressive APIs.
- Streams provide a way to process collections of data in a declarative way, leveraging laziness to improve efficiency. Operations can be pipelined for fluent processing.
- Functional programming with immutable data and avoidance of side effects makes code more modular and easier to reason about, enabling optimizations like parallelism. While not natively supported, Java 8 features like lambda expressions facilitate a more functional approach.
In Java 8, the java.util.function has numerous built-in interfaces. Other packages in the Java library (notably java.util.stream package) make use of the interfaces defined in this package. Java 8 developers should be familiar with using key interfaces provided in this package. This presentation provides an overview of four key functional interfaces (Consumer, Supplier, Function, and Predicate) provided in this package.
This document provides an overview of new features in Java 8 including lambda expressions, interface improvements, and streams. Lambda expressions allow for anonymous functions and method references in Java. Functional interfaces define a single abstract method that lambda expressions can implement. Interface changes allow interfaces to define static and default methods. Streams provide a functional-style way to process collections of objects through intermediate and terminal operations like filter, map, reduce, and forEach.
Java 8 introduced several new features including lambda expressions, functional interfaces, and streams to support functional programming. Interfaces can now contain default and static methods to allow multiple inheritance. Streams provide a way to process collections of data elements sequentially and support parallel processing.
Java 8 introduced several new features including lambda expressions, which allow functional-style programming in Java through functional interfaces containing a single abstract method, streams, which provide a way to process collections of objects in a declarative way, and default and static methods in interfaces to enable multiple inheritance. The document provides examples of using these new Java 8 features such as lambda expressions, functional interfaces, streams, and default and static methods in interfaces.
Java 8 introduced several new features including lambda expressions, default methods in interfaces, streams API and others. Lambda expressions allow implementing functional interfaces using anonymous functions. Interfaces can now define default and static methods. The streams API allows performing bulk operations on collections in a declarative way. Some performance improvements in Java 8 include faster common data structures like HashMap, garbage collector improvements and enhanced fork/join framework.
Java 8 new features or the ones you might actually useSharon Rozinsky
Lambda expressions allow passing functions as arguments and simplify anonymous classes. Functional interfaces define a single abstract method that lambda expressions or method references can implement. Default methods enable adding new methods to interfaces without breaking existing code. Streams provide a declarative way to process collections through pipelines of intermediate and terminal operations. Other new features include date/time API improvements and the Optional class for null handling.
This document provides an introduction to functional programming concepts in Java 8 including lambdas, streams, and examples of how to apply functional programming techniques. It outlines key functional programming concepts like declarative programming and composing small functions without side effects. It also covers Java 8 features like lambda expressions, functional interfaces, and the Stream API for filtering, mapping, and reducing collections in a declarative way. Examples are provided for sorting a list, finding word lengths, summing numbers, and filtering/mapping over collections in a functional style.
The slides of my JavaOne 2016 talk. This talk is a tutorial on how to write lambda expressions, how to compose them using default methods in functional interfaces, and how to create factory methods in those interfaces. Many examples and patterns are provided.
This presentaion provides and overview of the new features of Java 8, namely default methods, functional interfaces, lambdas, method references, streams and Optional vs NullPointerException.
This presentation by Arkadii Tetelman (Lead Software Engineer, GlobalLogic) was delivered at Java.io 3.0 conference in Kharkiv on March 22, 2016.
This document discusses the history and evolution of functional programming in Java, including lambda expressions and streams. It describes how lambda expressions allow passing behaviors as arguments to methods like normal data. This improves API design, opportunities for optimization, and code readability. Streams encourage a lazy, pipelined style and can execute operations in parallel. Functional idioms like immutability and pure functions help enforce correctness and isolation of side effects.
Do you want to learn functional programming in Java using lambda expressions introduced in Java 8? Do you want to explore the foundational concepts to explore powerful stream API? This presentation provides an overview of lambda functions introduced in Java 8 through examples. Topics covered: What is functional programming, creating lambda expressions, functional interfaces, built-in functional interfaces, and method references.
Make sure you have JDK 8 installed for trying out the programs as you go through the self-contained programming examples.
The document provides an overview of new features in Java 8 including lambda expressions, functional interfaces, default and static interface methods, method references, stream API, and date/time API. Lambda expressions allow for anonymous functions and functional interfaces provide functional signatures. Default and static interface methods allow interfaces to define implementations. Method references provide shorthand syntax for lambda expressions. The stream API supports functional-style processing of collections through intermediate and terminal operations. The new date/time API replaces the Calendar class with more easily used and immutable classes like LocalDate.
The slides of my JavaOne 2017 talk. It describes how you can create API using functional interfaces, default and static methods starting with Java 8. You can watch the video here: https://www.youtube.com/watch?v=64UO1YjVcZ0
Java 8 introduces lambda expressions and default interface methods (also known as virtual extension methods) which allow adding new functionality to existing interfaces without breaking backwards compatibility. While this helps add lambda support to existing Java collections, it has limitations compared to Scala's approach using traits, which allow true multiple inheritance of both behavior and state in a typesafe manner. Scala also introduced the "pimp my library" pattern using implicits which allows extending existing classes with new methods, providing more flexibility for library evolution than Java 8's virtual extension methods.
This document summarizes key parts of Java 8 including lambda expressions, method references, default methods, streams API improvements, removal of PermGen space, and the new date/time API. It provides code examples and explanations of lambda syntax and functional interfaces. It also discusses advantages of the streams API like lazy evaluation and parallelization. Finally, it briefly outlines the motivation for removing PermGen and standardizing the date/time API in Java 8.
Java 8 was released in 2014 and introduced several new features including lambda expressions, functional interfaces, method references, and default methods in interfaces. It also included a new Stream API for functional-style data processing, a date/time API, and Project Nashorn for embedding JavaScript in Java applications. Future versions like Java 9 will focus on modularity, new APIs, and further improvements.
The document discusses functional programming and lambda expressions in Java 8. It begins by defining functional programming and predicates from predicate logic. It then discusses the key properties of functional programming including no states, passing control, single large function, and no cycles. The document provides examples of determining if a number is prime in both imperative and declarative styles using Java 8 lambda expressions. It also provides examples of getting the first doubled number greater than 3 from a list using both declarative and imperative approaches. The examples demonstrate the use of streams, filters, maps and other functional operations.
SOCRadar's Aviation Industry Q1 Incident Report is out now!
The aviation industry has always been a prime target for cybercriminals due to its critical infrastructure and high stakes. In the first quarter of 2024, the sector faced an alarming surge in cybersecurity threats, revealing its vulnerabilities and the relentless sophistication of cyber attackers.
SOCRadar’s Aviation Industry, Quarterly Incident Report, provides an in-depth analysis of these threats, detected and examined through our extensive monitoring of hacker forums, Telegram channels, and dark web platforms.
What is Augmented Reality Image Trackingpavan998932
Augmented Reality (AR) Image Tracking is a technology that enables AR applications to recognize and track images in the real world, overlaying digital content onto them. This enhances the user's interaction with their environment by providing additional information and interactive elements directly tied to physical images.
Utilocate offers a comprehensive solution for locate ticket management by automating and streamlining the entire process. By integrating with Geospatial Information Systems (GIS), it provides accurate mapping and visualization of utility locations, enhancing decision-making and reducing the risk of errors. The system's advanced data analytics tools help identify trends, predict potential issues, and optimize resource allocation, making the locate ticket management process smarter and more efficient. Additionally, automated ticket management ensures consistency and reduces human error, while real-time notifications keep all relevant personnel informed and ready to respond promptly.
The system's ability to streamline workflows and automate ticket routing significantly reduces the time taken to process each ticket, making the process faster and more efficient. Mobile access allows field technicians to update ticket information on the go, ensuring that the latest information is always available and accelerating the locate process. Overall, Utilocate not only enhances the efficiency and accuracy of locate ticket management but also improves safety by minimizing the risk of utility damage through precise and timely locates.
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
Software Engineering, Software Consulting, Tech Lead, Spring Boot, Spring Cloud, Spring Core, Spring JDBC, Spring Transaction, Spring MVC, OpenShift Cloud Platform, Kafka, REST, SOAP, LLD & HLD.
E-commerce Application Development Company.pdfHornet Dynamics
Your business can reach new heights with our assistance as we design solutions that are specifically appropriate for your goals and vision. Our eCommerce application solutions can digitally coordinate all retail operations processes to meet the demands of the marketplace while maintaining business continuity.
Hand Rolled Applicative User ValidationCode KataPhilip Schwarz
Could you use a simple piece of Scala validation code (granted, a very simplistic one too!) that you can rewrite, now and again, to refresh your basic understanding of Applicative operators <*>, <*, *>?
The goal is not to write perfect code showcasing validation, but rather, to provide a small, rough-and ready exercise to reinforce your muscle-memory.
Despite its grandiose-sounding title, this deck consists of just three slides showing the Scala 3 code to be rewritten whenever the details of the operators begin to fade away.
The code is my rough and ready translation of a Haskell user-validation program found in a book called Finding Success (and Failure) in Haskell - Fall in love with applicative functors.
Mobile App Development Company In Noida | Drona InfotechDrona Infotech
Looking for a reliable mobile app development company in Noida? Look no further than Drona Infotech. We specialize in creating customized apps for your business needs.
Visit Us For : https://www.dronainfotech.com/mobile-application-development/
Atelier - Innover avec l’IA Générative et les graphes de connaissancesNeo4j
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Allez au-delà du battage médiatique autour de l’IA et découvrez des techniques pratiques pour utiliser l’IA de manière responsable à travers les données de votre organisation. Explorez comment utiliser les graphes de connaissances pour augmenter la précision, la transparence et la capacité d’explication dans les systèmes d’IA générative. Vous partirez avec une expérience pratique combinant les relations entre les données et les LLM pour apporter du contexte spécifique à votre domaine et améliorer votre raisonnement.
Amenez votre ordinateur portable et nous vous guiderons sur la mise en place de votre propre pile d’IA générative, en vous fournissant des exemples pratiques et codés pour démarrer en quelques minutes.
Enterprise Resource Planning System includes various modules that reduce any business's workload. Additionally, it organizes the workflows, which drives towards enhancing productivity. Here are a detailed explanation of the ERP modules. Going through the points will help you understand how the software is changing the work dynamics.
To know more details here: https://blogs.nyggs.com/nyggs/enterprise-resource-planning-erp-system-modules/
Takashi Kobayashi and Hironori Washizaki, "SWEBOK Guide and Future of SE Education," First International Symposium on the Future of Software Engineering (FUSE), June 3-6, 2024, Okinawa, Japan
GraphSummit Paris - The art of the possible with Graph TechnologyNeo4j
Sudhir Hasbe, Chief Product Officer, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxrickgrimesss22
Discover the essential features to incorporate in your Winzo clone app to boost business growth, enhance user engagement, and drive revenue. Learn how to create a compelling gaming experience that stands out in the competitive market.
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsPeter Muessig
The UI5 tooling is the development and build tooling of UI5. It is built in a modular and extensible way so that it can be easily extended by your needs. This session will showcase various tooling extensions which can boost your development experience by far so that you can really work offline, transpile your code in your project to use even newer versions of EcmaScript (than 2022 which is supported right now by the UI5 tooling), consume any npm package of your choice in your project, using different kind of proxies, and even stitching UI5 projects during development together to mimic your target environment.
1. JAVA 8 - BY EXAMPLE!
PATTERNS AND PRACTICES FOR LAMBDAS, STREAMS,
OPTIONAL...
Createdby /MarkHarrison @markglh
2. INTERFACE DEFAULT METHODS
Interfaces can now have default & static methods!
Allows new interface methods to be added without breaking
existing implementations
Multiple inheritance!
public interface Comparator<T> {
default Comparator<T> reversed() {
// Implementation here
}
public static Comparator<T> naturalOrder() {
// Implementation here
}
}
3. MULTIPLE INHERITANCE...
What if a class inherits the same default method from two
interfaces???
1.Class methods always win. Whether it’s this class or the
superclass, it will take priority
2.If multiple interfaces de ne the same method with a
default implementation, then the most speci c is selected
(the child in inheritance terms)
3.If it’s not obvious then the compiler will cry, we need to
explicitly choose: INTERFACE.super.METHODNAME
4. LAMBDAS YOU SAY?
Basically just a shorthand method implementation
Concise and much improved replacement for Anonymous
inner classes
Makes it easy to pass behaviour around
Pass the behaviour into the method, ips the design on its
head
Lexically scoped (this is effectively shared with the
surrounding method)
5. SYNTAX PLEASE!
(int x, int y) -> x + y
Argument types can be inferred by the compiler:
(x, y) -> x + y
Zero-arg Lambdas are also possible:
() -> "Java 8!"
But how can we use them?
Consumer<String> inferredConsumer =
x -> System.out.println(x);
7. FUNCTIONAL INTERFACES
A Functional Interface is any interface with one Single
Abstract Method
The parameters that the Lambda accepts and returns must
match the interface (including exceptions)
@FunctionalInterface annotation is provided to
highlight these interfaces, it is just a marker though, any SAM
interface will work - the annotation simply enforces this at
compile time
So... When we pass or assign a Lambda:
1. First the Lambda is converted into a Functional Interface
2. Secondly it is invoked via this generated implementation
8. LAMBDA EXAMPLE 1 - PREDICATES
Have you ever written code like this?
@FunctionalInterface //Added in Java8
public interface Predicate<T> {
boolean test(T t);
}
private void printMatchingPeople(
List<Person> people,
Predicate<Person> predicate) {
for (Person person : people) {
if (predicate.test(person)) {
System.out.println(person);
}
}
}
9. LAMBDA EXAMPLE 1 - PREDICATES
Pre Java 8:
public class PersonOver50Predicate
implements Predicate<Person> {
public boolean test(Person person) {
return person.getAge() > 50;
}
}
printMatchingPeople(loadsOfPeople,
new PersonOver50Predicate());
10. LAMBDA EXAMPLE 1 - PREDICATES
Java 8:
printMatchingPeople(loadsOfPeople,
x -> x.getAge() > 50);
Notice the signature matches that of the Predicate, the compiler
automatically gures out the rest
What if we had an existing Predicate we wanted to enhance?
Composite Predicates FTW... :-)
Predicate<Person> ageCheck = x -> x.getAge() > 50;
printMatchingPeople(loadsOfPeople,
ageCheck.and(x -> x.getIq() > 100));
11. LAMBDA EXAMPLE 2 - RUNNABLE
Pre Java 8 mess:
Runnable r1 = new Runnable() {
@Override
public void run() {
System.out.println("Meh!");
}
};
r1.run();
Java 8:
Runnable r = () -> System.out.println("Woop!");
r.run();
12. LAMBDA EXAMPLE 3 - COLLECTIONS
Lambdas make lots of new Collection methods possible...
List<String> strings = new ArrayList<>();
Collections.addAll(strings, "Java", "7", "FTW");
Do something on every element in the List
strings.forEach(x -> System.out.print(x + " "));
//Prints: "Java 7 FTW"
13. LAMBDA EXAMPLE 4 - MORE COLLECTIONS
Replace every matching element in the List
strings.replaceAll(x -> x == "7" ? "8" : x);
strings.forEach(x -> System.out.print(x + " "));
//Prints: "Java 8 FTW"
Remove matching elements from the List
strings.removeIf(x -> x == "8");
strings.forEach(x -> System.out.print(x + " "));
//Prints: Java FTW
14. LAMBDA EXAMPLE 5 - COMPARATORS
@FunctionalInterface //Added in Java8 version
public interface Comparator<T> {
int compare(T o1, T o2);
//Java 8 adds loads of default methods
}
15. LAMBDA EXAMPLE 6 - COMPARATORS 2
List<Person> loadsOfPeople = ...;
Pre Java 8:
public class SortByPersonAge
implements Comparator<Person> {
public int compare(Person p1, Person p2) {
return p1.getAge() - p2.getAge();
}
}
Collections.sort(loadsOfPeople,
new SortByPersonAge());
Java 8:
Collections.sort(loadsOfPeople,
(p1, p2) -> p1.getAge() - p2.getAge());
16. LAMBDA EXAMPLE 7 - COMPARATORS 3
As usual in Java 8... the Comparator interface provides plenty
of useful default & static methods...
//"comparing" static method simplifies creation
Comparator<Person> newComparator =
Comparator.comparing(e -> e.getIq());
//"thenComparing" combines comparators
Collections.sort(loadsOfPeople,
newComparator.thenComparing(
Comparator.comparing(e -> e.getAge())));
18. INTRODUCING METHOD REFERENCES
Any method can be automatically “lifted” into a function. It
must simply meet contract of the FunctionalInterface
Can be easier to debug & test than Lambdas, more descriptive
stack traces
Promotes re-use, keeping code DRY
Uses the "::" syntax
19. METHOD REFERENCES TYPES
Reference to... Example
a static method Class::staticMethodName
an instance method of
a speci c object
object::instanceMethodName
an instance method of
an arbitrary object
Class::methodName
a constructor ClassName::new
20. REFERENCE TO A STATIC METHOD
A simple reference to a static method
//isPersonOver50 is a static method
printMatchingPeople(loadsOfPeople,
PersonPredicates::isPersonOver50);
This is equivalent to
printMatchingPeople(loadsOfPeople,
x -> x.getAge() > 50);
21. REFERENCE TO AN INSTANCE METHOD OF A
SPECIFIC OBJECT
A reference to a method on an object instance
List<String> strings = ...
//print is a method on the "out" PrintStream object
strings.forEach(System.out::print);
This is equivalent to
strings.forEach(x -> System.out.print(x));
22. REFERENCE TO AN INSTANCE METHOD OF AN
ARBITRARY OBJECT
Examine this simpli ed de nition of a map function
public interface Function<T,R> {
public R apply(T t);
}
public <T, R> List<R> map(Function<T, R> function,
List<T> source) {
/* applies the function to each element,
converting it from T to R */
}
23. REFERENCE TO AN INSTANCE METHOD OF AN
ARBITRARY OBJECT CONT...
Although it looks like we're referencing a Class method, we're
invoking an instance method on the object(s) passed in the call
List<Person> loadsOfPeople = ...
List<Integer> namesOfPeople =
map(Person::getAge, loadsOfPeople);
This is equivalent to
map(person -> person.getAge(), loadsOfPeople);
24. REFERENCE TO A CONSTRUCTOR
Uses the constructor to create new objects, the constructor
signature must match that of the @FunctionalInterface
List<String> digits = Arrays.asList("1", "2", "3");
//Transforms a String into a new Integer
List<Integer> numbers = map(Integer::new, digits);
This is equivalent to
map(s -> new Integer(s), digits);
25. WHAT'S WRONG WITH COLLECTIONS
Every application uses Collections, however Collections are
dif cult to query and aggregate, requiring several levels of
iteration and conditionals, basically it’s messy and painful
Writing multi-threaded code to do this manually is dif cult to
write and maintain
Imagine writing this manually
Stream<String> words=Stream.of("Java", "8", "FTW");
Map<String, Long> letterToNumberOfOccurrences =
words.map(w -> w.split(""))
.flatMap(Arrays::stream)
.collect(Collectors.groupingBy(
Function.identity(),
Collectors.counting()));
//Prints: //{a=2, T=1, F=1, v=1, W=1, 8=1, J=1}
26. INTRODUCING STREAMS!
A Stream is a conceptually xed data structure in which
elements are computed on demand
Streams iterate internally, you don’t have to worry about
handling the iteration
Pipelining: Akin to the “pipe” command in unix, allowing
aggregations to be chained together
Automatic optimisation: short-circuiting and lazy processing
Can be in nite
Can be executed in parallel automatically using
parallelStream or parallel()
27. MORE STREAMS...
Can be created from multiple sources:
Arrays.stream(...), Stream.of(1, 2, 3, 4),
Stream.iterate(...), Stream.range(...),
Random.ints(), Files.lines(...)...
Two types of operations:
Intermediate (aggregation): lter, map, atMap, sorted ...
Terminal: collect, reduce, forEach, ndAny ...
Specialised Streams:
IntStream, LongStream and DoubleStream: better
performance for those unboxed types
28. MAP
public <R> Stream<R> map(Function<T, R> mapper);
The mapper Function converts each element from T to R. The
result is then added, as is, to the Stream
29. FLATMAP
public <R> Stream<R> flatMap(Function<T,
Stream<R>> mapper);
The mapper Function converts each element from T to a
Stream of R
This is the key difference to map, the function itself returns a
Stream rather than one element
This Stream is then attened (merged) into the main Stream
To put it another way: atMap lets you replace each value of a
Stream with another Stream, and then it concatenates all the
generated streams into one single stream
30. REDUCE
public T reduce(T identity,
BinaryOperator<T> accumulator);
public Optional<T> reduce(
BinaryOperator<T> accumulator);
//This is the function contained in BinaryOperator
R apply(T t, U u);
Terminal Operation
Takes a Stream of values and repeatedly applies the
accumulator to reduce them into a single value
The accumulator is passed the total so far (T) and the current
element (U)
If passed, identity provides the initial value, rather than the
rst element
31. REDUCE CONTINUED...
int totalAgeUsingReduce = loadsOfPeople.stream()
.map(Person::getAge) //contains 5, 10, 15
.reduce(0, (total, current) -> total + current);
1.First we map the Person to the age int
2.reduce then starts at 0, and adds the current element, 5
3.reduce continues by adding the current total 5, to the next
element, 10
4. nally reduce adds the current total 15, to the next element
15
5.Tada, we've added up all the ages: 30!
32. COLLECTORS
The collect method is a terminal operation which takes various
"recipes", called Collectors for accumulating the elements of
a stream into a summary result, or converting to a speci c type
(such as a List)
List<String> listOfStrings = loadsOfPeople.stream()
.map(x -> x.getName())
.collect(Collectors.toList());
The argument passed to collect is an object of type java
.util.stream.Collector
It describes how to accumulate the elements of a stream into
a nal result
Can be used for Grouping, Partitioning, Averaging, ...
33. STREAMS EXAMPLE 1
List<Integer> numbers = Arrays.asList(1, 2 ... 8);
List<Integer> twoEvenSquares = numbers.stream()
.filter(n -> n % 2 == 0) //Filter odd numbers
.map(n -> n * n) ////Multiply by itself
.limit(2)//Limit to two results
.collect(Collectors.toList()); //Finish!
Imagine a println in each step...
filtering 1
filtering 2
mapping 2
filtering 3
filtering 4
mapping 4
35. STREAMS EXAMPLE 2
List<String> youngerPeopleSortedByIq =
loadsOfPeople.stream()
.filter(x -> x.getAge() < 50)
.sorted(Comparator
.comparing(Person::getIq).reversed())
.map(Person::getName)
.collect(Collectors.toList());
1. Filter out all people older than 50
2. Inverse sort the remaining people by IQ
3. map each person to their name (convert to a Stream<String>)
4. Convert the result to a List
36. STREAMS EXAMPLE 3 - SUM
int combinedAge =
loadsOfPeople.stream()
.mapToInt(Person::getAge) //returns IntStream
.sum(); //this HAS to be a specialised Stream
1. map each person to their age, producing an IntStream
2. sum the results, also supports average
37. STREAMS EXAMPLE 4 - MAP, REDUCE
String xml =
"<people>" +
loadsOfPeople.stream()
.map(x -> "<person>"+ x.getName() +"</person>")
.reduce("", String::concat) //start with ""
+ "</people>";
map each Person to an XML element
(<person>Steve</person>), then use String.concat to reduce
the Stream into one XML String
<people>
<person>Dave</person>
<person>Helen</person>
<person>Laura</person>
<person>Ben</person>
</people>
38. STREAMS EXAMPLE 5 - MAP
List<Stream<Person>> clonedPeople =
loadsOfPeople.stream()
.map(person -> Stream.of(person, person.dolly()))
.collect(Collectors.toList());
1.map creates a new Stream containing two people
2.This Stream is then added to the main Stream as-is, leaving
us with a pretty useless: List<Stream<Person>>
39. STREAMS EXAMPLE 6 - FLATMAP
List<Person> clonedPeople2 = loadsOfPeople.stream()
.flatMap(person -> Stream.of(person,
person.dolly()))
.collect(Collectors.toList());
1. atMap combines each element from the new Streams into
one Stream<Person>
2.So now we've got what we wanted in the rst place, a
List<Person>
Sweeet!
40. STREAMS EXAMPLE 7 - REDUCE
int totalAgeUsingReduce = loadsOfPeople.stream()
.map(Person::getAge)
.reduce((total, current) -> total + current)
.get(); //get the result from the Optional
This is the same as the previous example, the difference being
we don't specify a default value for reduce
Not specifying a default value means the result is Optional...
if the Stream is empty then so is the result!
41. STREAMS EXAMPLE 8 - GROUPING
Map<Integer, List<Person>> peopleGroupedByAge =
loadsOfPeople.stream()
.filter(x -> x.getIq() > 110)
.collect(Collectors.groupingBy(Person::getAge));
The collect method groups the ltered results by age,
producing a Map<age, <Person>>
{52=[Person{... age=52, iq=113, gender=MALE}],
60=[Person{... age=60, iq=120, gender=FEMALE}],
28=[Person{... age=28, iq=190, gender=MALE}]}
42. STREAMS EXAMPLE 9 - PARTITIONING
Map<Boolean, List<Person>> peoplePartitionedByAge =
loadsOfPeople.stream().filter(x -> x.getIq() > 110)
.collect(Collectors
.partitioningBy(x -> x.getAge() > 55));
The collect method partitions the ltered results by age
The Map will have two entries, true and false, according to the
Predicate
{false=[Person{... age=28, iq=190, gender=MALE}],
true=[Person{... age=60, iq=120, gender=FEMALE}]}
43. STREAMS EXAMPLE 10 - MULTIPLE GROUPS
Map<Integer, Double> peopleGroupedBySexAndAvgAge =
loadsOfPeople.stream()
.filter(x -> x.getIq() > 110)
.collect(
Collectors.groupingBy(Person::getAge,
Collectors.averagingInt(Person::getIq)));
We can group by multiple Collectors
Here we group by age and the average IQ of that group
{52=113.0, 60=117.5, 28=190.0}
44. STREAMS EXAMPLE 11 - FINDANY
loadsOfPeople.stream()
.filter(t -> t.getGender() == Person.Sex.FEMALE)
.findAny()
.ifPresent(System.out::println);
findAny either returns an element or nothing, hence we get
an Optional
ifPresent executes the Lambda if we get a result
45. STREAMS EXAMPLE 12 - PARALLEL
Lets iterate over 10,000,000 elements!
x -> Stream.iterate(1L, i -> i + 1)
.limit(x)
.reduce(Long::sum).get();
Executes in 80ms - we incur a penalty here because the long is
repeatedly boxed and unboxed
Executes in 211ms?! It turns out parallel isn't always a free win!
x -> Stream.iterate(1L, i -> i + 1)
.parallel().limit(x)
.reduce(Long::sum).get();
46.
47. STREAMS EXAMPLE 13 - PARALLEL WIN!
x -> LongStream.rangeClosed(1L, x)
.reduce(Long::sum).getAsLong();
Executes in 24ms - much better using an unboxed Stream
Executes in 7ms - now that the Stream isn't dynamic, parallel
works much better!
x -> LongStream.rangeClosed(1L, x)
.parallel()
.reduce(Long::sum).getAsLong();
48. OPTIONAL
Use Optional instead of passing null around, helps prevent
NullPointerExceptions
Optional is a container that’s either empty or present, in
which case it contains a value
So anytime that you’re thinking of return or accepting a null
value in a method, use Optional instead!
public class Computer {
private Optional<Mainboard> mainboard;
}
public class Mainboard {
private Optional<Cpu> cpu;
}
public class Cpu {
private String type;
}
49. USING OPTIONAL
Several ways to create an Optional:
Optional.of(cpu); //Throws an NPE if cpu is null
Optional.ofNullable(cpu); //empty if cpu is null
Getting the contents from the Optional:
cpu.get(); //get CPU or throw NoSuchElementException
cpu.orElse(new Cpu()); //safe get, provides default
And more...
cpu.isPresent(); //true if present, false if empty
cpu.ifPresent(x -> System.out.println(x.getType()));
Also supports map, atMap and lter!
50. OPTIONAL EXAMPLE 1 - BASICS
if (mainboard.isPresent() &&
mainboard.get().getCpu().isPresent()) {
mainboard.get().getCpu().get().getType();
}
Eww! Lets try something else!
***Fails to compile, calling getType on an Optional... if only
we could atten it???
Optional<String> cpuType =
mainboard.map(Mainboard::getCpu)
.map(Cpu::getType); //Optional<Optional<Cpu>>
51. OPTIONAL EXAMPLE 2 - FLATMAP
Optional<String> stringOptional = mainboard
.flatMap(Mainboard::getCpu)
.map(Cpu::getType);
Lets take this further and safely get cpu type of a Computer!
Computer computer = new Computer(mainboard);
String cpu = computer.getMainboard()
.flatMap(Mainboard::getCpu)
.map(Cpu::getType)
.filter(x -> "Intel".equals(x))
.orElse("Nothing we're interested in!");
52. IT'S BEEN EMOTIONAL...
Slides at
Source at
Follow me
markglh.github.io/Java8Madlab-Slides
github.com/markglh/Java8Madlab-Examples
@markglh
53. RECOMMENDED READING
Lambdas Part 1 (Ted Neward)
Lambdas Part 2 (Ted Neward)
Lambda Expressions vs Method References (Edwin Dalorzo)
Youtube: Java 8 - more readable and exible code (Raoul-
Gabriel Urma)
Youtube: Lambda Expressions & Streams (Adib Saikali)
Java 8 Streams Part 1 (Raoul-Gabriel Urma)
Java 8 Streams Part 2 (Raoul-Gabriel Urma)
Optional - No more NPE's (Raoul-Gabriel Urma)