« Return to Thread: annotations or traits to better scale scala up

Re: annotations or traits to better scale scala up

by Eric Willigers :: Rate this Message:

Reply to Author | View in Thread

Walter Smith wrote:
> DontExtend: This class is meant to just be called by client code; avoid the
> much stronger coupling by implementing a trait or extending a class. This
> privilege is left to the library itself.

package mylibrary

// Only library code may extend
class DontExtend private[mylibrary](args: List[Any]) {

     private[mylibrary] def this() { this(Nil) }
}

> DontCall: This class or trait is a callback for the client code to extend
> and the library to call. Don't do that at home.

package mylibrary

abstract class DontCall {

     // Abstract. User code implements
     def implementation(): Unit

     // Only library code may call
     private[mylibrary] final def call() { implementation() }
}

 « Return to Thread: annotations or traits to better scale scala up