- New Scala developers
- Experienced Scala developers who mostly used the object-oriented side of Scala
We had both successes with people utterly new to Scala and Scala developers with more than eight years of experience. The course will be useful to you except if you are already an expert in functional programming.
Some familiarity with Scala syntax. For example, a couple of month of professional experience in Scala or attending a Scala MOOC
Module 1: Function
Scala is a language with first-class functions. This simple fact has a tremendous impact on how we program. In this module, we analyse the various syntax and concepts around functions in Scala. We also look at what is the functional programming subset of Scala and what are the benefits and restrictions of using it.
Objectives:
- Getting familiar with the various function encodings in Scala (val/def, curried/uncurried, lazy/strict parameters).
- Understand rules of type inference.
- Learn to detect if a function satisfies the functional programming subset.
Module 2: Side Effect
Functional programming is considerably restrictive. For example, we cannot do any actions like sending an email to our users or update a record in the database. Yet, that's something we need to do in our daily job. In this section, we will discuss the workarounds functional programmers found to interact with the outside world while respecting the limitation of functional programming. In particular, we examine Thunk, IO and some initiation to concurrency.
Objectives:
- Being able to write an entire program following functional programming principles.
- Learn how to test IO and laziness.
- Getting familiar with abstract API based on type parameters.
Module 3: Error Handling
They are many ways to deal with runtime errors. The easiest and most common method consists of throwing exceptions. Unfortunately, it is not compatible with the functional programming paradigm. In this module, we look at the problems caused by exceptions and the various ways we can safely encode errors in Scala.
Objectives:
- Learn when to use Option, Try and Either.
- Learn how to encode errors with Algebraic Data Type (ADT) and the various trade-offs.
- Practice how to accumulate errors or fail early.
Module 4: Type
We all have tendencies to use types that are too large for our purpose. This leads to either runtime exceptions or a lot of error handling logic. In this module, we look at using Algebraic Data Types (ADT) and type parameters to constraint our programs. We will also discuss various testing strategies and the best way to use types and tests together.
Objectives:
- Learn how to encode precisely business requirements with types.
- Getting more familiar with Scala type hierarchy and type parameters.
Each module has:
- a set of slides (linked above) located at
docs/$module.html
- one or more Scala objects containing exercises located at
exercises/src/main/scala/exercises/$module/...Exercises.scala
- one or more Scala objects containing all answers located at
exercises/src/main/scala/answers/$module/...Answers.scala
- two test suites (one for exercises, one for answers) located at
exercises/src/test/scala/exercises/$module/...Test.scala
Start each module with the slides, at some point you will be prompted to work on some exercises. Do the exercises and check your answers are correct by running the tests for this module. Finally, go back to the slides and repeat the process. If you have any question, please ask them on gitter.
sbt testExercises$X
For example tests for Error Handling module (module 3) is run with:
sbt testExercises3
Yes, the material is open source and it uses a permissive licence CC-BY-SA-4.0. However, the slides and exercises are currently made to be run by a trainer. Eventually, we aim to create an online version of this course. It will most likely be available mid or end of 2020.
We do encourage people who enjoy the course to make a donation using patreon.