4. Naming convention
Camel case
Class KnoldusKnowledgeSession
Object – same like class
Methods, Variables, values, Annotations
def myFairMethod = ...
5. Parentheses for methods
foo1 can be accessed with or without parentheses
foo2 cannot be accessed with parentheses
Accessors do not define parentheses
Call site should follow the declaration convention
No parentheses, when the method has no side effect
6. Symbolic method names
! :: => Avoid
Symbolic method names should be reserved for
1. DSL
2. Logically mathematical operations (e.g. a + b
or c :: d)
3. Purely functional operations like joining
Monads (>>=)
13. Ordering in a class
New line between
declarations
Fields before use in
methods
def foo(bar: Baz): Bin = expr
def foo(bar: Baz) { // return type is Unit
expr
}
14. Functional Values
val f1 = { (a: Int, b: Int) => a + b }
val f2 = (a: Int, b: Int) => a + b
val f3 = (_: Int) + (_: Int)
val f4: (Int, Int) => Int = { _ + _ }
22. Avoid!
Method Returns → returns <what>
This class does XXX - > Does <what>
Links to Scala lib classes as [[scala.option]]
@return
Document what method 'does not' and 'should not' do
first sentence should be a summary of what the method does.
Subsequent sentences explain in further detail
23. Packages
Overview of main
classes
Examples of how to
Use class