2 ms·
There's two valid use cases for this: 1. Testing. The trait makes it easier to mock a dependency. In this case the second implementation is in the testing code
by dtech 8y ago
There's two valid use cases for this:
1. Testing. The trait makes it easier to mock a dependency. In this case the second implementation is in the testing codebase.
2. Quick overview and contract.
If you have a `trait DoThing { def firstThis() def thenThis() }` it very clearly shows what the trait is meant to do with what contract, even if the actual implementation is 500 LOC with 15 private methods.
- xchaotic 8y agoIt is this way for large projects. You write your function, the interface is tested, but the whole project becomes a big bloated mess. I don't think there's any better way to write large projects. Instead consider loosely coupled smaller projects. Perhaps this only moves the complexity elsewhere and you have a dependency hell, but arguably the same can be said for versioning parts of code.