Scala Language Best Practices Don't pack too much in one expression.

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

  • Find meaningful names for computation units.
  • Use for comprehensions or map to combine computations together.

Let's say you have something like this:

if (userAuthorized.nonEmtpy) {
  makeRequest().map {
    case Success(respone) =>
      someProcessing(..)
      if (resendToUser) {
        sendToUser(...)
      }
    ...
  }
}

If all your functions return Either or another Validation-like type, you can write:

for {
  user     <- authorizeUser
  response <- requestToThirdParty(user)
  _        <- someProcessing(...)
} {
  sendToUser
}


Got any Scala Language Question?