The libraries in Cascade are loosely coupled from each other but share some familiar design patterns. We use each pattern to ensure Cascade code is readable and organized.
This document serves as a reference for patterns used in Cascade.
The following naming conventions were chosen by the Cascade development team:
object
s,class
es andtrait
s are camel cased starting with an uppercase letter.def
s,val
s,var
s andlazy val
s are camel cased starting with a lowercase letter.implicit class
names start withRich
.package object
names are short and lower case.package object
s are in their own file named${package}.scala
. We do this so that they're easier to find on the filesystem, in GitHub, etc...
The following error handling conventions were chosen by the Cascade development team:
Where possible, use Try
where
possible to pass errors to the caller of a def
. When the exception does not
matter to the caller, use
Option
.
However, throw exceptions in a few cases:
- Throw from
Akka
Actor
s so that the supervisor can decide what to do. - Throw from
def
s that have a@throws
annotation on them. We often do this when we override Java methods that have a thrown exception on them.
Generally, try to minimize throwing exceptions in favor of Try
and
Option
, and throw
only when there is a good reason.