O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Best Practices in Scala Programming

Video Description

Anyone starting a project in Scala, expanding a Scala project, or looking to establish coding standards as a means for helping junior Scala programmers come up to speed, will value this overview of Scala best practices by Scala expert Joshua Backfield.

Backfield's extensive experience in both object-oriented programming and functional programming make him a Scala authority. He has ported multiple native C applications to Scala, introduced many coworkers to Scala, and taught them the underlying functional programming concepts. He uses that experience to offer a set of Scala guidelines that should make your Scala code base as great as it can be.

  • Review and master the coding standards used by expert Scala programmers
  • Learn methods for ensuring that junior level programmers adhere to coding standards
  • Understand the norms for var and val usages and functions as objects
  • Review standards for immutable vs. mutable data structures and for pattern matching
  • Master axioms in OOP for use cases, instance methods, and mixing vs. deep inheritance
  • Learn standards for advanced features like avoiding postfix notation and dynamic typing
  • Understand best practices for syntax, concurrency, and self-documenting code
Joshua F. Backfield, author of the O'Reilly title Becoming Functional: Steps for Transforming Into a Functional Programmer, has been a Senior Software Engineer at SPARC and Dell SecureWorks. In addition to Scala, his specialties include: Linux, LiftWeb, Squeryl, Java, Spring MVC, Spring, JAX-WS, C, C++, Perl, MySQL, BSD Socket, Functional Programming, and Akka. He holds an M.S. in Computer Science from DePaul University and a B.S. in Electronic Systems from Southern Illinois University-Carbondale.

Table of Contents

  1. Introduction
    1. Welcome To The Course 00:01:50
    2. About The Author 00:00:45
    3. How To Access Your Working Files 00:01:15
  2. Using Val And Var
    1. Overview Of Val And Var 00:01:08
    2. Common Usages Of Val 00:05:45
    3. Common Usages Of Var 00:05:28
    4. Using Var Vs. Mutable Datatypes 00:07:18
    5. Using Var In Loop Contexts 00:05:53
  3. Functions As Objects
    1. Storing Defs Inside Of Vars 00:04:01
    2. Storing Functions In Lists And Maps 00:05:26
    3. Abstract Function Bodies When Possible 00:06:21
    4. Functions Should Be Testable 00:04:45
  4. Immutable Vs. Mutable
    1. Using Mutable Data Structures 00:05:14
    2. Using Immutable Data Structures 00:04:48
  5. Pattern Matching
    1. Do Not Pattern Match For All Statements 00:03:09
    2. Cover All Outcomes Of A Pattern Match 00:05:07
    3. Prefer Value Matches Over Guards When Possible 00:05:16
    4. Prefer To Map/Filter Over An Option Rather Than Pattern Matching 00:06:38
    5. Prefer Pattern Matching To Type Casting 00:04:41
  6. Lazy Val
    1. Cost Of A Lazy Val 00:05:51
    2. Common Usages Of Lazy Val 00:05:12
    3. Using A Factory And Lazy Val Pattern 00:03:19
  7. Oop
    1. Useless Traits 00:04:19
    2. Using Case Classes Effectively 00:02:47
    3. Instance Methods Invoking Static Methods 00:03:32
    4. No Classes Inside Of Package Objects 00:03:27
    5. Prefer Mixing Over Deep Inheritance 00:07:48
  8. Syntax
    1. Do Not Use The Return Keyword 00:05:29
    2. Do Not Use Exceptions For Validation And Flow Of Control 00:08:56
    3. Do Not Use Null 00:04:07
    4. Do Not Use Option.Get 00:03:36
    5. Explicit Return Types 00:04:27
  9. Concurrency
    1. Prefer The Actor Model Over Manual Runnable/Thread 00:05:44
    2. Always Prefer A Single Producer 00:05:22
    3. Thread Safety Of Public Apis 00:04:31
    4. Blocking I/O On A Separate Thread Pool 00:09:46
    5. Futures Are Not The End Answer 00:04:56
    6. Prefer An Ask Over Exposing Internal Actor Workings 00:05:39
    7. Actors Should Only Accept Data 00:06:36
  10. Advanced Language Features
    1. Avoid Postfix Notation 00:05:41
    2. Avoid Implicit 00:09:44
    3. Avoid Complex Structural Typing 00:06:17
    4. Avoid Dynamic Typing 00:07:11
  11. General Programming
    1. Proper Naming Of Variables And Functions 00:04:07
    2. Long Line Splitting 00:07:48
    3. Return Types For Methods 00:03:04
    4. Catch Exceptions When Possible 00:03:15
    5. Self-Documenting Code 00:04:43
  12. Conclusion
    1. Wrap Up And Thank You 00:01:04