Scala best practices I wish someone'd told me about
summary
Arrays compare by reference so use sameElements not equals; always annotate public return types to avoid ABI breaks; avoid Enumeration — use sealed trait ADTs with final case classes; custom extractors and structural types cause unsafe pattern-match and runtime reflection, prefer type classes; encode errors with Option/Either/Try (or make error types extend Exception for Java interop); don't use non-local return or implicit conversions; run scalafix/scapegoat/wartremover and upgrade to Scala 3 where many issues are fixed.
AI-written summary · about
chapters (17)
- 0:00Intro
- 1:39Array comparison
- 3:44Type annotation
- 5:30Unicode operators
- 7:19Enumerations
- 10:22Sealed traits
- 12:19Algebraic Data Types
- 15:45Case classes
- 18:40Custom extractors
- 20:55Structural types
- 24:04Exceptions
- 31:38The return keyword
- 33:57Implicit conversions
- 36:31Implicit resolution
- 39:47String concatenation
- 42:04Enforcing best practices
- 43:26More good and bad practices
related talks
52mScala Best Practices I Wish Someone'd Told Me About
39mA few tips on modelling things in Scala
27mScala bad practices or how to keep your job for life
42mWhat Scala can learn from Rust, Swift, and C++
30mLessons Learned from 15 Years of Scala in the Wild
38mThinking Less with Scala
45mDesign Patterns in Scala
31mSCALATEST: YOU'RE ASSERTING IT WRONG
