Coding Style Guidelines - Paradoxika/Skeptik GitHub Wiki
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
Chas many simple subclassesC1,...,Cmthat express simple variations ofC; thenC1,...,Cmcan be implemented in the same file whereCis implemented. -
If a trait
Tis sufficiently simple and can be only mixed with a classC, thenTcan be implemented in the same file whereCis implemented. -
Think twice before creating a trait
Tthat 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 traitTto be inherited by bothCandC'.)