Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Java Functional Programming

You're reading from   Learning Java Functional Programming Create robust and maintainable Java applications using the functional style of programming

Arrow left icon
Product type Paperback
Published in Oct 2015
Publisher
ISBN-13 9781783558483
Length 296 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Richard M. Reese Richard M. Reese
Author Profile Icon Richard M. Reese
Richard M. Reese
Richard M Reese Richard M Reese
Author Profile Icon Richard M Reese
Richard M Reese
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Getting Started with Functional Programming 2. Putting the Function in Functional Programming FREE CHAPTER 3. Function Composition and Fluent Interfaces 4. Streams and the Evaluation of Expressions 5. Recursion Techniques in Java 8 6. Optional and Monads 7. Supporting Design Patterns Using Functional Programming 8. Refactoring, Debugging, and Testing 9. Bringing It All Together Index

Summary


In this chapter, we demonstrated several of the Java 8 functional features to create a Zork-like game. Using console input, a player can navigate through a world picking up and dropping items along the way. New worlds can be configured using a file containing the description of the world.

We showed how to use the command pattern to handle commands. The commands were implemented using a combination of lambda expressions and other methods. Adding command aliases involved adding a different keyword to a hash map of commands.

Streams were used in a number of places to simplify processing and make the code more readable. Also used in conjunction with lists and maps was the forEach method, which replaced the need for imperative loops.

At several places in the chapter, we provided either an equivalent imperative solution or an equivalent functional solution for certain problems. In general, the functional approach was the better solution, as it was often cleaner and more maintainable. However...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime