Part 1
Scala: Part 1: From Java to Scala with a Runnable sbt Project
Starting Scala 2 from Java and Spring: val and var, expressions, a first method, and a small sbt project you can run. The first step in the Scala/Play series.
Series
Learning Scala 2 and Play from a Java and Spring background, step by step: language fundamentals, sbt workflows, domain modelling, asynchronous services, with runnable examples and practical comparisons.
Part 1
Starting Scala 2 from Java and Spring: val and var, expressions, a first method, and a small sbt project you can run. The first step in the Scala/Play series.
Part 2
From a Java-style policy class to Scala 2 case classes: constructor properties, value equality versus identity, and copying data without changing the original.
Part 3
From Java Optional to Scala Option: represent presence with Some, absence with None, and handle both outcomes with a match expression using our runnable policy lookup.
Part 4
Transform a value inside Option, then choose a fallback where it belongs. A walkthrough for Java developers of Scala 2 map, lambdas and getOrElse, derived from match and verified in a runnable lab.
Part 5
Find a policy, find its email, and build a label. Understanding Scala 2 for-comprehensions by translating them into familiar flatMap and map calls, with all three optional outcomes made explicit.
Part 6
Three familiar operations, three different results. I explore Scala List with fictional insurance policies, compare it with Java streams, and reconnect find with Option.
Part 7
From one generator and an if guard to two lists and six combinations: I trace Scala for-comprehensions back to map, withFilter and flatMap, with runnable policy examples.
Part 8
I knew how to run sbt, but not how its build model worked. I built a small Scala 2.13 project and traced settings, tasks, scopes, Zinc, dependencies, Coursier and local publication back to the Maven concepts I already knew.
Part 9
A familiar Java interface idea becomes a Scala trait: define a policy repository, implement find, and inherit an exists method that calls the concrete lookup.
Part 10
I rebuilt Scala's Cake Pattern as a small checkout application, then traced its component traits, self-type requirements and test wiring from a Java and Spring perspective.
Part 11
From multiple parameter lists to compiler-supplied repository arguments: real missing and ambiguous implicit errors, explicit fixes, and the difference between a missing dependency and a missing policy.
Part 12
Coming from Java, a String with a lookup method looks wild. I unpack Scala 2 implicit classes into an ordinary wrapper, then show how the compiler can supply its repository argument too.
Part 13
From a Java/Spring perspective, I build Scala Either from explicit Left/Right cases to map, flatMap and a for-comprehension, with three verified lookup outcomes and failure reasons that survive the chain.
Part 14
From Java-style exception handling to composable Scala results: capture a throwing conversion, understand map versus flatMap, write the same chain with for, and recover only from a specific failure.
Part 15
I unpack AnyFunSuite from a Java developer’s perspective, test returned Right and Left values, check thrown exceptions with intercept, and verify that independent expectations catch real mistakes.
Part 16
I replace String failures with a sealed family of domain errors, keep Either composition unchanged, and choose human-readable messages only at the display boundary.
Part 17
I connect Future composition and recovery to the map/flatMap pattern, reproduce one-worker starvation safely, and finish with the distinction between a business Left and a failed Future.
Part 18
I replaced this site's Spring Boot backend with Scala 2.13, Play 3, Anorm and Twirl in one pull request. The rewrite was the easy part: this is how I fixed the contracts, kept the outbox wire format, and rehearsed the rollback on a restored production backup.
Part 19
A sealed trait removes impossible states from a model, but five details decide whether it holds: constructors, exhaustivity warnings, wildcards, Scala 2 inference and secrets in toString. I compiled each one on Scala 2.13.18.
Part 20
A hand-written unapply turns a catch block into a policy: pass your own errors through, wrap recoverable JVM exceptions, and let fatal ones propagate. A runnable Scala 2.13 demo shows exactly when the matcher calls it.