
This is part three of a three part course, the first part covers converting to Scala from other programming languages and part two covers Scala language features that might be different from other languages or perhaps even unique. This part three finishes the tour of powerful language features with case classes and pattern matching, then moves on to the most important core library features, like collections, futures, and also covers building and working with Java.
Slides and exercises are attached to the next lecture.
Explore advanced Scala pattern matching, including guards, type narrowing, try, case classes and constructor patterns, and core libraries like options, collections, and tuples, plus custom extractors.
Explore option types as a safe alternative to nulls and practice pattern matching on options with guards, case clauses, and none handling, including idiomatic getOrElse usage.
Learn typed pattern matches in scala to narrow types safely, replacing runtime checks and casts with type patterns like case i of int, enabling guards and method calls.
Explore how partial functions become pattern matches in Scala, using curly brace cases to define either partial or complete functions, and replace map calls with direct pattern matching.
Enforce exhaustiveness with sealed class hierarchies in Scala to ensure pattern matching covers all algebraic data types, and receive compile-time warnings on missing cases to avoid runtime errors.
Learn to implement custom extractors in scala using an unapply method, returning options, to parse coordinate strings into latitude and longitude with pattern matching.
Learn how to initialize lists in Scala using the apply method and right‑associative cons, with nil, and use fill, tabulate, and range to generate sequences like 0 to 9.
Convert vectors, sets, maps, and strings to lists in Scala using toList, noting set order is not guaranteed and strings become lists of chars.
Explore fold alternatives in Scala applied, part 3, using built-in list operations like sum and product. Demonstrate make string with a separator, preamble, and postamble to intersperse words.
Explore powerful collection methods in Scala, including transpose, flatten, and sum, and learn to group by to build a histogram from data.
Convert collections to list, vector, array, set, or map with concise to-type methods, noting maps require a sequence of pairs. Expect 2.13 syntax shifts to to queue and builder usage.
Explore immutable sets, their unique elements, and non-ordered storage. Use set operations: intersect, diff, and union, plus the apply method as a predicate to count vowels.
A view is a lazy, functional collection based on an existing one without modifying it, recording mapped functions and applying them just in time, trading off sparse access against iteration.
Continue module 14 exercises, using provided implementations to compare your versions, and practice constructing a mutation or polymorphism map before advancing to sbt and Java libraries in module 15.
Explore building Scala projects with Scala and Java together, navigate edge cases, master SBT as the primary build tool, and discuss other options while constructing custom tasks.
Master the build.sbt file basics, including a minimal build file, a Scala-like DSL with three key operators (:=, +=, ++=), optional blank lines, and embedding Scala code inside curly braces.
Explore a minimal sbt build, with project name, organization, licenses, and compiler options. Understand scala versions, cross compilation, percent vs percent percent dependencies, and plugin publishing to bintray.
learn how to create a custom sbt setting and task, define setting keys and boolean flags, and compose them to mark a project as awesome.
Learn how to call Java from Scala, import Java libraries, and use Java methods with Scala syntax, including infix calls, primitive boxing, and SAM conversions on the JVM.
Scala 2.12 with Java 8 enables lighter function literals that compile to method handles. Scala functions now act as Java function interfaces with single abstract methods and Java 8 streams.
Practice module 15 by calling a fake Java library in tests to explore booleans, nulls, and array lists of integers, gaining Scala–Java interop fluency; module 16 covers futures.
Learn how futures work: they start and may be unresolved, completed with success, or completed with failure; using map or flatMap keeps the thread unblocked while returning a future result.
Learn how to compose futures in Scala for non-blocking asynchronous programming, using map, flatMap, and for expressions to chain results without blocking.
Explore non blocking future operations like map, flatMap, collect, and filter, and narrow a future of any to a specific type with success or failure. Use transform to handle outcomes.
Explore how futures handle unresolved, successful, and failed states, and learn three recovery patterns, fallback to, recover, and recover with, to transform failures into usable results.
Explore future sequence operations like first completed, futures reverse, and foldleft over a future of sequence, noting non-cancelable futures, non-blocking processing, and the empty-sequence risk of reduce left.
Explore the Scala futures mechanism by creating a promise as the server-side channel for a result, then push a value or exception to complete the future non-blockingly.
Explore retrying patterns for unreliable external services, using a simulated counter to model failures and eventual success, and implement a framework to retry until success.
Scala Applied, part 3 is the final part of this Scala programming language course. The course in its entirety is aimed at giving you a full, day-to-day working knowledge of Scala programming, including some of the most common core library APIs.
This part starts with a final language feature for Scala (continuing from the other language features covered in parts 1 and 2). Pattern matching, partial functions and case classes are examined, how they can be used together, and how partial functions can help you avoid certain runtime errors by validating input to a function before you call it.
Then we delve into the collections API in the core libraries (a very in-depth 2 module examination of the capabilities and performance tradeoffs of the various collection options), and finish up with a look at using Scala on Java projects, using Java libraries from Scala and how to harness build tools (particularly SBT) to build your project and even write custom settings and tasks. Following that we look at the Futures API in the core libraries.
This course is also a good lead-in to the Stairway to Scala Advanced 3 part course which concentrates on in-depth language features, higher level functional abstractions, common patterns and idioms, type theory and other more advanced Scala concepts that will be particularly helpful for anyone writing their own libraries and APIs in Scala.