I have 3 projects included in one project, let's call them project1, 2 and 3 and they are included in main project. The 1 one is a library, whereas the two others are console-executable projects.
For now I have 2 pretty much identical object Application in the projects 2 and 3:
package com.project1
abstract class Class123 extends Actor { ... }
abstract class Class456 { ... }
package com.project2
class Class123 extends package1.Class123 { ... }
class Class456 extends package1.Class456 { ... }
object Application extends App {
val system = ActorSystem()
val myActor = system.actorOf(Props[Class123])
val b = new Class456
// some actions
}
package com.project3
class Class123 extends package1.Class123 { ... }
class Class456 extends package1.Class456 { ... }
object Application extends App {
val system = ActorSystem()
val myActor = system.actorOf(Props[Class123])
val b = new Class456
// some actions
}
How do I reduce the amount of repetition? I can create object Application in package1, but it should be generic (which Scala doesn't allow to do) and I would have to inherit from it (it's not allowed by Scala either).
What do I do about it?