-
Notifications
You must be signed in to change notification settings - Fork 25
Coding Style Guidelines
Developers of Skeptik should follow the guidelines below and (with lesser priority) the Scala Style Guide.
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 subclassesC1
,...,Cm
that express simple variations ofC
; thenC1
,...,Cm
can be implemented in the same file whereC
is implemented. -
If a trait
T
is sufficiently simple and can be only mixed with a classC
, thenT
can be implemented in the same file whereC
is implemented. -
Think twice before creating a trait
T
that is used by a single classC
. In such cases, it is almost always better to implement the trait code directly as a method inC
. (If in the future a new classC'
might need the same method, it is easy to separate to create a traitT
to be inherited by bothC
andC'
.)