scala - What is the prefered way to factor out behavior -
let's have couple of classes internally sharing behavior
def workspace = plugin.get.reallyget.getworkspace what best way factor out? see 2 possibilities can used equivalently in using code.
trait workspaceprovider { def workspace = plugin.get.reallyget.getworkspace } and mix in or
object workspaceprovider { def workspace = plugin.get.reallyget.getworkspace } and import it. prefer , why?
the former preferable. latter static, un-mockable , hard test.
since you're thinking in terms of coupling (a thing) should familiarize cake pattern (it covered on 'net, starting paper in concept first described).
Comments
Post a Comment