Skip to content

Coding Style Guidelines

Bruno edited this page Sep 23, 2013 · 2 revisions

Developers of Skeptik should follow the guidelines below and (with lesser priority) the Scala Style Guide.

Where to implement classes, objects and traits

In principle, a class/object/trait C should be implemented in its own file, with filename C.scala, thus following the Java convention. However, in Scala it is much more common to have small classes and traits. Therefore, to avoid the proliferation of files, the following conventions should be used:

  • If a class C has many simple subclasses C1,...,Cm that express simple variations of C; then C1,...,Cm can be implemented in the same file where C is implemented.

  • If a trait T is sufficiently simple and can be only mixed with a class C, then T can be implemented in the same file where C is implemented.

  • Think twice before creating a trait T that is used by a single class C. In such cases, it is almost always better to implement the trait code directly as a method in C. (If in the future a new class C' might need the same method, it is easy to separate to create a trait T to be inherited by both C and C'.)

Clone this wiki locally