Scala Language Best Practices Prefer a Functional Style, Reasonably

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

By default:

  • Use val, not var, wherever possible. This allows you to take seamless advantage of a number of functional utilities, including work distribution.
  • Use recursion and comprehensionss, not loops.
  • Use immutable collections. This is a corrolary to using val whenever possible.
  • Focus on data transformations, CQRS-style logic, and not CRUD.

There are good reasons to choose non-functional style:

  • var can be used for local state (for example, inside an actor).
  • mutable gives better performance in certain situations.


Got any Scala Language Question?