# Java 8 workshop at Finn.no

DevFeed: [Java 8 workshop at Finn.no](<https://devfeed.tech/articles/java-8-workshop-at-finn-no-31990.md>)

Original publisher: [Read original article](<https://tech.finn.no2015/02/16/java-8-workshop-at-finnno/>)

Author: Sjur Millidahl

Published: 2015-02-16T07:50:16Z

Content type: tutorial

Language: en

Sources: [Finn.no](<https://devfeed.tech/sources/finn-no.md>)

Topics: [Java](<https://devfeed.tech/topics/java.md>), [coding style](<https://devfeed.tech/topics/coding-style.md>), [Code](<https://devfeed.tech/topics/code.md>), [exceptions](<https://devfeed.tech/topics/exceptions.md>)

Tags: [coding-style](<https://devfeed.tech/tags/coding-style.md>), [exceptions](<https://devfeed.tech/tags/exceptions.md>), [java](<https://devfeed.tech/tags/java.md>), [lambda](<https://devfeed.tech/tags/lambda.md>), [language](<https://devfeed.tech/tags/language.md>), [optional](<https://devfeed.tech/tags/optional.md>), [stream](<https://devfeed.tech/tags/stream.md>), [workshop](<https://devfeed.tech/tags/workshop.md>)

## AI overview

This article describes a two-part workshop at Finn.no on adopting Java 8's functional programming features. It covers streams and lambdas, then Optional and an in-house Either type for handling absent values and exceptions.

## Source excerpt

Pondering on the right lambda for the job With Java 8 comes a whole new set of language features. It even challenges the imperative coding-style of the Java programmer. Java is a core language in Finn.no. More and more of our java-modules are being built with Java 8, adopting new features of the language. A workshop was warranted, with the goal of bringing every developer up to speed on the functional paradigm of Java 8. In Finn.no, we want programmers to do stuff like this db.fetchLastDayAds() .stream() .filter(ad -> "bap-webstore".equals(ad.getAdType())) .flatMap(ad -> ad.getContacts().stream()) .distinct() .flatMap(per -> Optional.ofNullable(contact.getEmail()).map(Stream::of) .orElseGet(Stream::empty)) .peek(contact -> LOG.trace("Sending notification to "+per)) .forEach(this::sendNotification); While avoiding stuff like this IntStream.iterate(0, i -> (i + 1) % 2) .parallel() .distinct() .limit(10) .forEach(System.out::println); (Locking up all cores on a CPU is bad, and should only be done when the machine is right about to become self-aware and turn against you.) Several lambda-arrows pointing in the right direction here We split the workshop into two half days. The first day was dedicated to streams and lambdas. Everyone seemed keen on getting those tests green (a rhyme!). Day 2 we raised the bar with Optional and our in-house version of Either<L,R>. With these structures, much more code can be written functionally in a world where values might not exist (be null), and things may go wrong (throw exceptions). We need power.. lots of power! Both the word "monad" and the phrase "monadic domain" was uttered several times, but we still saw very few making the swoooosh-sound while flying a hand over their head (the internationally recognized sign of communicating that a topic is beyond mental capacity). This might mean that the timing was good, and developers are interested in the new features of Java 8. You may checkout the project and do the tasks yourself, by mak