Scala 2 and 3 for Experienced Developers

  • 3 Days
  • Intermediate
  • Virtual | Classroom
  • £ On Request

A high-speed and in-depth introduction to Scala for experienced developers

Book For My Team

Overview

Scala is a revolutionary language which has transformed what it means to be a programmer on the JVM. When compared with Java it offers enhanced support for Object Orientation, Functional Programming and Generics - all within a more concise syntax and unified type system. Since its first release in 2004 Scala has become the language of choice for large-scale, distributed, massively parallel applications. Prominent adopters include Twitter, Netflix and The Guardian.

As a result of this popularity Scala is now supported across a range of IDE's, has its own build tool (SBT) and a vibrant community of open source frameworks (including Cats, Akka and Play). The third version of the language is a major update. It introduces a new compiler, removes less successful features and greatly expands support for emerging coding styles.

This course provides a comprehensive guide to the language, as well as an introduction to key Scala libraries. Delegates spend most of their time on the second version of the language, but differences in version three are continually explored. Practical work can be done in either version.

By the end of the course, delegates will be confident in the fundamentals of Scala development. They will be able to use Cats abstractions, create services with Http4s and write tests using ScalaTest and ScalaCheck. The course can be deliveried using either IntelliJ or Visual Studio Code. Delegates must be experienced in a related language, such as Java, Kotlin, C# or Groovy.

Outline

First Steps with Scala

  • Where Scala stands compared to Java, Kotlin and Groovy
  • Creating and running projects using the SBT build tool
  • Work with Scala code in IntelliJ and Visual Studio Code
  • The standard documentation and other useful resources

Basic Programming

  • Introducing the Scala type system and type inference
  • The package system, default imports and the PreDef object
  • How conditionals expand into support for pattern matching
  • Pattern matching using values, types, regex and collections
  • How iteration expands into comprehensions and monads
  • Examples of using for comprehensions with collections

Object Orientation

  • A minimal class declaration in Scala
  • Primary and alternative constructors
  • Standard and specialised access levels
  • Different syntaxes for declaring methods
  • Creating base classes and class hierarchies
  • Companion Classes and factory methods
  • Using traits with both classes and objects
  • How a Scala inheritance tree is linearized
  • Options for performing implicit conversions

Pattern Matching in Depth

  • Using Case Classes for pattern matching
  • Adding Pattern Guards to match conditions
  • Partially specifying matches with wildcards
  • Deep matching using Case Constructors
  • Using Extractors instead of Case Classes

Functional Programming

  • Using functions as values in Scala code
  • Declaring lambdas using the underscore syntax
  • How lambdas can perserve state as closures
  • Creating and invoking Higher Order Functions
  • Practical examples of Higher Order Functions
  • Support for Partial Application and Currying
  • Creating Domain Specific Languages (DSL’s)

Generics in Scala

  • Review of Java Generics syntax and semantics
  • Problems posed by wildcards and non-reification
  • Adding Type Parameters to types and functions
  • Restricting parameters via Upper and Lower Bounds
  • Understanding when to use View and Context Bounds
  • How and when to indicate Co and Contravariance
  • Type Constructors and Higher Kinded Types

Working with Collections

  • Why there are multiple versions of Scala Collections
  • Picking the appropriate implementation for a project
  • The basics of working with Sequences, Sets and Maps
  • Operators commonly used to manipulate collections
  • Using the standard 'functional toolkit' operations
  • Notable extra operations particular to Scala
  • How the parallel collections are implemented

Features in Scala 3

  • Opportunities provided by the Dotty compiler
  • Existing Scala features that have been removed
  • Top level declarations for values and methods
  • Using Creator Applications to avoid 'new'
  • Proper support for Enumerations and ADT's
  • Literal Types and Opaque Type Aliases
  • Support for Extension Methods on types
  • Type classes via 'given' and 'using'
  • Improvements to the collections library

Agile Development

  • Using JUnit, Mockito etc. from Scala
  • Scala specific features in ScalaTest
  • Performing TDD and BDD with ScalaTest
  • Introduction to Property Based Testing
  • Generalizing test cases into properties
  • Performing PBT on the JVM via ScalaCheck
  • Customizing and integrating ScalaCheck

The Cats Library

  • Abstractions found in advanced FP
  • Functors, Endofunctors and Bifunctors
  • Applicatives, Semigroups and Monads
  • How Cats provides these abstractions
  • Pure Functional Coding via the IO Monad
  • Using IO and Fibres via Cats Effects
  • Integrating Cats with ScalaTest

The Http4s Framework

  • The concept of 'Your Server as a Function'
  • Http4s as an implementation of this design
  • How Http4s uses Cats Effect and Streaming
  • Creating a new Http4s project via SBT
  • Defining RESTful Services via the DSL
  • Testing services and creating clients
  • Using middleware to augment services

Requirements

Delegates must have several years commercial experience in a related programming language. For example Java, C#, Kotlin, Groovy, Haskell or Ruby.

Garth Gilmour
Google Developer ExpertGoogle Developer Expert

25 years coding and educating. 1000+ deliveries of (almost) everything to everyone.

Follow Garth
For a breakdown of what to expect in our training, check out our training overview page.

The course was excellent. The trainer was very friendly and helpful. Seems to know his stuff very well. I had an excellent head start with Scala.

Deloitte logo
Atlassian logo
Workday logo
BMW logo
Amex logo
McAfee logo
PWC logo