@onionsoup probably because static methods are a bit of a code smell in an OO language. They are much better represented by top-level functions in FP and the companion object is merely a way of grouping these functions.
o
onionsoup
06/06/2017, 2:31 PM
andyb: well but the result is the same. you have a bunch of methods inside a class and you call them using the class name. if the static methods were a code smell then why aren't the companion object's methods a code smell?
n
nulldev
06/06/2017, 2:39 PM
Because companion objects are real objects.
Static methods do not belong to any object. Companion objects are singleton objects attached to a class.
a
andyb
06/06/2017, 2:42 PM
It also provides a cleaner separation from the instance properties on the class.