What is the โcorrectโ way for an object alias in Scala?
For example, let's say I need a RoleGroup in different parts of my application (which is divided into SBT subprojects)
trait RoleGroup object RoleGroup { case object ADMIN extends RoleGroup case object MEMBER extends RoleGroup case object PUBLIC extends RoleGroup }
Since I do not want to re-import RoleGroup, I decided to assign the RoleGroup attribute and the object in types and val analogies:
package com.developer package controller trait ControllerBase { type RoleGroup = controller.RoleGroup val RoleGroup = controller.RoleGroup ... }
and then the objects of the subproject package can expand the auxiliary feature in order to receive import for free:
package com.client package object member extends com.developer.controller.ControllerBase
I do the same for other case objects, which should be in scope. Is this a smart decision? those. Are there any flaws / problems that I should know about? All browser compiled and test pages are displayed in the same way as in a pre-refactored application, but I'm not sure if this is the best approach.
source share