Course Overview
Rest assured that this course will cover all relevant bases to make sure you have all the necessary skills to work with key Scala frameworks and APIs:
- Testing (with ScalaTest and Specs2)
- Database access with ScalikeJDBC and Slick
- Introduction to Akka (actors, http and an introduction to streams, persistence, remote/cluster)
Course Prerequisites
In order to get the best from this course it is highly recommended that students should be at least familiar with the basics of the Scala Programming language. (Ideally their knowledge of Scala should reach the level established by our Core Scala Course). Knowledge of APIs such as JDBC and JUnit is helpful, but not necessary.
Outline
Testing
Introduction
- Recap of automatic software testing
- Testing styles
- Discuss popular Testing Frameworks for Scala
ScalaTest
- Overview of ScalaTest
- Testing styles (
FunSuite
,WordSpec
,FlatSpec
,FunSpec
, …) - Using Given-when-then
- Running tests (using sbt, maven, junit, …)
- Writing assertions
- Using the Matcher DSL
- Writing fixtures
Scala Mock
- Introduction to Scalamock
- Discuss different mocking techniques (function, proxy and macro)
- Integrate with ScalaTest and Specs2
- Discuss and use expectation-first (mocking)
- Discuss and use record-then-verify (stubbing)
- using argument matchers
- expect method/function calls
- mocking behaviour by returning values
ScalaCheck
- Introduce property-based testing
- Introduce scalacheck
- Introduce the architecture (key types)
- Running and integrating with other test frameworks
- Defining generators
- Configuration (thresholds, number of workers etc.)
- Add reporting
- Discuss various property-based patterns
- Discuss extensions (e.g, using shapeless)
Database access
In this session, we explore two popular persistent Frameworks ScalikeJDBC and Slick. On a bespoke course, we focus on only one if you already know which one you will be using.
Introduction
- Overview of database apis/Frameworks
- Using java based solutions
ScalikeJDBC
- Configuring and using connection pools
- Performing queries (
single
,first
,list
andforeach
) - Using SQL interpolation
- Binding parameters
- Using Type Binders
- Updating, Executing and batch
- Generating scala code from a database schema
- Managing transactions
- Using the Type-safe DSL
- Brief intro in ScalikeJDBC-Async
Introduction to Slick
- Introduction to Slick
- Discuss Supported databases
- Introduction to Slick's Functional Relational Mapping (FRM)
- Understanding Slick's architecture (
Database
,DBIOAction
,Rep
,Database
, …) - Setting up connections (Typesafe Config, JDBC, datasources, …)
- Generating code from a database schema
- Running queries
- Filtering results using for-comprehensions
- Using projections
- Joining tables
- Managing sessions and transactions
- Using SQL directly
- Using Slick and Reactive Streams
Akka
In this session, we explore the Akka actor-based solution. You will get familiar with the general architecture of Akka and writing actor-based solutions. We will also expose you to some other Akka modules such as Streams, Persistence and Remoting/Cluster. A special lesson at the end gives you a thorough introduction to Akka HTTP to build restful services.
Introduction
- Introduction to the Akka ecosystem
- Discuss Akka Modules (Actors, Streams, Http, …)
- Introduce Actor Systems
Akka Actors
- Introduction to Akka Actors
- Sending/Receiving messages
- Tell and Ask
- Actor hierarchies and supervision
- The actor life-cycle
- Discuss different supervision strategies
- Monitoring actors
- Using Actor Selections
- Discuss types of actors (Router, FSM, Persistent)
- Creating Router actors (random, round-robin, balanced, broadcast, …)
- Managing Actor's behaviour using become/unbecome
- Stashing and unstashing messages
- Managing Actor's state using FSM
- Testing Actors
Other Modules (Demonstrations)
- Demonstration of Akka Persistence (including snapshots and Persistence Query)
- Demonstration of Actor Remoting and Actor Cluster
- Discuss Akka Streams
Introduction to Akka Http (Server side)
- Introduction of Akka Http
- Introduce the Routing DSL
- Implementing a Rest API with akka-http
- List of key Directives
- Working with json
Get in touch to find out more about how you can tailor this course to fit your needs or those of your team.