I have a trait and some classes extending it. The problem is that all method in the trait should be implemented statically, so I put them in the corresponding companion objects. I wrote something like:
A.scala
trait A
C1.scala
class C1 extends A {
override def F = C1.F
}
object C1 extends A {
def F: String = ???
}
...
As the method F has to be implemented twice, I added a corresponding companion trait.
Now I have something like:
A.scala
trait A
AC.scala
trait AC {
def F: String
}
C1.scala
class C1 extends A {
}
object C1 extends AC {
def F: String = ???
}
C2.scala
class C2 extends A {
}
object C2 extends AC {
def F: String = ???
}
...
I feel a little strange because there is nothing but an empty trait A in A.scala. I wonder if there is any better way to organize the codes.