Modern applications often need to describe complex workflows involving multiple external systems. These are notoriously difficult to get right as it requires handling errors, various retry strategies and non-determinism because of concurrent executions. In this course, you will learn how to solve this problem using both imperative and functional programming.
By the end of the course, you will be able to read and write code using popular Scala libraries such as cats-effect, Monix and ZIO. This skill is in high demand.
Modern applications often need to describe complex workflows involving multiple external systems. These are notoriously difficult to get right as it requires handling errors, various retry strategies and non-determinism because of concurrent executions. In this course, you will learn how to solve this problem using both imperative and functional programming.
By the end of the course, you will be able to read and write code using popular Scala libraries such as cats-effect, Monix and ZIO. This skill is in high demand.
Several companies use this curriculum to on-board and train engineers. Here is a non-exhaustive list:
Lunatech
Kaluza / OVO Energy
Autoscout24
Pirum Systems
Cleverbase
These companies are constantly hiring new Scala developers. Don’t hesitate to reach out to them and mention that you took this course.
I designed this content for backend developers. It is extremely practical and hands-on. Specifically, this means that you will:
Write lots of Scala code
Test it using both example-based and property-based tests
Experience issues caused by blocking logic and concurrent execution
Work your way to efficient solutions in small and incremental steps
I will guide you through all the exercises and provide a complete set of solutions. My goal is to unlock your full potential as a functional Scala developer by demystifying complex concepts using explanations that are free of confusing jargon.
For those familiar with FP-Tower courses, this course corresponds to chapter 5 of Foundations of Functional Programming in Scala.
Enroll now, and enjoy the course.
Custom random generators
arbitrary lets us fetch the default random generator for a type, if there is one:
import org.scalacheck.Arbitrary.arbitrary
arbitrary[String]
// res: Gen[String] = ...
Then, we can use the methods filter or filterNot to modify an existing generator.
val invalidYesNoInputGen: Gen[String] = arbitrary[String].filter(word => word != "Y" && word != "N")
invalidYesNoInputGen is a random generator of String which will never produce the single letter String "Y" and "N".
Note that if the predicate of filter is too restrictive, it could take a long time for finding a valid value. For example, the code below generates a random Strings and discards all values that do NOT start with "abc".
arbitrary[String].filter(_.startsWith("abc"))
To prevent long or even infinite waiting time, Scalacheck throws an Exception if it discards too many values.
[Error] Gave up after 0 successful property evaluations. 51 evaluations were discarded.
If you want a generator of String starting with "abc", a better solution would be to generate a random String and then, prepend it with "abc".
arbitrary[String].map(randomString => "abc" ++ randomString)
Missing code
In the video, I mention a function called parseDate which is not included in the code.
def parseDate(line: String): LocalDate = LocalDate.parse(line, dateOfBirthFormatter)
We can also define a corresponding formatter function
def formatDateOfBirth(date: LocalDate): String = dateOfBirthFormatter.format(date)
References
Extension methods by Alvin Alexander https://alvinalexander.com/scala/implicit-extension-methods-functions-scala-2-3-dotty/
References
Fabio Labella — How do Fibers Work? https://www.youtube.com/watch?v=x5_MmZVLiSM
OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.
Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.
Find this site helpful? Tell a friend about us.
We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.
Your purchases help us maintain our catalog and keep our servers humming without ads.
Thank you for supporting OpenCourser.