Case Class naming convention
- by KChaloux
In my recent adventures in Scala, I've found case classes to be a really nice alternative to enums when I need to include a bit of logic or several values with them. I often find myself writing structures that look like this, however:
object Foo{
case class Foo(name: String, value: Int, other: Double)
val BAR = Foo("bar", 1, 1.0)
val BAZ = Foo("baz", 2, 1.5)
val QUUX = Foo("quux", 3, 1.75)
}
I'm primarily worried here about the naming of the object and the case class. Since they're the same thing, I end up with Foo.Foo to get to the inner class. Would it be wise to name the case class something along the lines of FooCase instead? I'm not sure if the potential ambiguity might mess with the type system if I have to do anything with subtypes or inheritance.