Scala Kickstart for Java Refugees Training Course
Course Summary
Java developers have lately been flocking to Scala as a more powerful and expressive JVM language, yet when presented with real-world engineering problems and tight deadlines, many fall back on the Java development style they are most comfortable with. This course, "Scala Kickstart for Java Refugees," is a one day whirlwind tour of Scala's functional features. We introduce experienced Java developers to examples of well-designed, idiomatic Scala code, focusing on the practical benefits of the programming style that Scala offers.[top] Duration
1 day.
[top] Objectives
On completion of this course, students will have seen many of the most powerful and commonly-used features in Scala. Students will be able to explain core concepts and recognize where they apply to common software development tasks, including:
- type inference
- pattern matching
- algebraic data types
- higher-order functions
- immutability and referential transparency
- typeclasses and monads
[top] Prerequisites
Students enrolling in this course should have some formal background in Computer Science, and should be very comfortable with object-oriented programming (preferably in Java). Some basic terminology and concepts that we will assume are already familiar:
- Classes, instances and references
- Static vs. instance fields and methods
- Subtype polymorphism (
extends/implements) and parametric polymorphism ("generics")
[top] Instructors
Dan Rosen believes in beautiful code. Beautiful code is understandable and maintainable, it is self-documenting and self-testing, it is robust and scalable, it can be composed and reused. Beautiful code doesn't come around every day, and even the most elegant code can still have its warts, but when you see beautiful code, you know it.
For twelve years, Dan has been doing his best to write and help others write some damn fine code. Dan is author of Marakana's Scala Fundamentals course, the latest addition the the Marakana course catalog. Before joining Marakana, he worked as a Developer Advocate at Atlassian, teaching developers how to write plugins for Atlassian's collaboration and development tools. Prior to Atlassian, Dan worked in both engineering and sales for Coverity, helping developers maintain code quality using Coverity's sophisticated static and dynamic analysis tools.
Between Coverity, Atlassian and Marakana, his tutorials have covered C/C++ best practices, Java web development (including Maven, Spring, OSGi, Guava, and RESTful web services using Jersey and Jackson), front-end development using jQuery, and functional programming with Scala.
Dan's latest hobby is lurking on StackOverflow as user "mergeconflict," waiting for tricky Haskell and Scala language questions to jump on. More about Dan Rosen...
For twelve years, Dan has been doing his best to write and help others write some damn fine code. Dan is author of Marakana's Scala Fundamentals course, the latest addition the the Marakana course catalog. Before joining Marakana, he worked as a Developer Advocate at Atlassian, teaching developers how to write plugins for Atlassian's collaboration and development tools. Prior to Atlassian, Dan worked in both engineering and sales for Coverity, helping developers maintain code quality using Coverity's sophisticated static and dynamic analysis tools.
Between Coverity, Atlassian and Marakana, his tutorials have covered C/C++ best practices, Java web development (including Maven, Spring, OSGi, Guava, and RESTful web services using Jersey and Jackson), front-end development using jQuery, and functional programming with Scala.
Dan's latest hobby is lurking on StackOverflow as user "mergeconflict," waiting for tricky Haskell and Scala language questions to jump on. More about Dan Rosen...
[top] Outline
About Scala (~15 min.)
- Scala's pedigree: Java, Haskell, Pizza, GJ
- Who uses Scala? Debunking the Functional Programming "ivory tower" myth
Data and Control Flow (~45 min.)
- Quick syntax introduction: declaring classes, primary constructors and class members (
valandlazy val,var,def) - By-value and by-name parameters
- Scala's unified type hierarchy
Any/AnyVal/AnyRef,Unit,Null,Nothing
- Local type inference
- Pattern matching and control-flow expressions
match/caseif/elsefor/yieldtry/catch/finally(with pattern matching)
- Syntactic sugar: omitting dots and parentheses
Object-Oriented Programming in Brief (~60 min.)
- Encapsulation
- Classes, objects and companions
- Case classes and case objects
applyandunapply
- Inheritance and Polymorphism
- The "Uniform Access Principle"
- The
overridekeyword - Fine-grained access modifiers
- Traits, mix-in inheritance and linearization
- Dependency injection with the "cake" pattern
Functional Programming Basics (~120 min.)
- Functions are objects
def foo(a: A): Bis a functionA => Bor aFunction1[-A, +B]- Functions can be bound to variables and passed as parameters to other functions
- Standard functional collection methods:
filter,map,fold... - Anonymous functions (lambdas, closures)
- Syntactic sugar: the mysterious
_ - Currying and partial application: the "loan" pattern
Functional Design (~180 min.)
- Immutability, tail recursion and tail call optimization
- Implicits
- Typeclasses: a flexible alternative to subtype polymorphism
for-comprehensions and monadsOption: a warmer, fuzziernullFuture: composing asynchronous computationsReader: dependency injection done properly
Code Review, Special Topics, Q&A (time permitting)
- Reviewing, understanding and critiquing real-world code
- Language oddities: incorrect type inferences, unwanted variable bindings in patterns, infix and postfix method notation
- Focus on special topics of interest to the students (suggested: variance, phantom types, structural types, more monads)