Add subclass responsibility error
Sometimes methods are defined in non abstract classes that should be overrridden in subclasses. This is currently done with
protected def getShardedChunkPathAndRange(chunkIndex: Array[Int]): Fox[(VaultPath, NumericRange[Long])] = ???
or
protected def getShardedChunkPathAndRange(chunkIndex: Array[Int]): Fox[(VaultPath, NumericRange[Long])] = ??? // Defined in subclass
I would like something more expressive, such as
protected def getShardedChunkPathAndRange(chunkIndex: Array[Int]): Fox[(VaultPath, NumericRange[Long])] = SubclassResponsibility
like in Smalltalk
Good idea! The ??? is certainly not very pretty.
What do you have in mind specifically?Should the behavior also change? Or just how this looks in code?
I’m wondering if we could solve this problem in another way entirely with a clever combination of traits? (So that the kind-of-abstract base class/trait does not have to have this ??? in the first place?)
I was thinking replacing the ??? in code so that it is more expressive. The behavior does not have to change (an exception is thrown when called). Just seeing ??? it is not clear if that means "Case can not happen, trust me bro" or "I don't care" or this.