- Always specify an explicit sbt.version
- Ensure you run in production with GC logging enabled
- Prefer immutability
- Prefer the latest version of Scala. At the time of writing
3.1.2
is the latest version, so2.13.8
may be acceptable. if you are still using2.12.x
you should plan to migrate. - If some dependencies are unavailable for the latest version, it is acceptable to use the latest patch version of the previous minor version but try to avoid it. If you have a dependency that isn't available for one of these versions, it's effectively dead and you should plan how to move away from it.
- If you come to a codebase using an older version of Scala, it should be upgraded before any new features are added.
- Run on a Corretto LTS version of Java, no lower than Java 11. At the time of writing this means Corretto 11 or 17. For tips on upgrading from Java 8, see here.
- Avoid dependency injection in general.
Dependency injection is a software design pattern that implements inversion of control between a client
and a service
for resolving dependencies. The term injection
refers to a third party (named the injector
) which is responsible for constructing the services and injecting them into the client. Usual injectors
are dependency injection frameworks such as guice
, dagger
, macwire
, spring
.
Instead of injecting
your dependencies, you should simply pass them as parameters of functions you are calling. This enable referential transparency of your programs.
Most of the time, dependency injection does not solve a real business problem. You don't need to have a single place where you define which concrete instance your trait should be used. This isaccidental complexity
, as coined by Fred Brooks in No Silver Bullet
With The play framework you should always use compile-time dependency injection which refers to an object oriented way to specify your components declaratively in scala.