Matan,
In addition to Jon and Roland's explanations, here's how I practically use it.
I've a class that does a tedious job with a web site:
- figure out the list of patients
- get current payment data
- scan through all claims and process them.
The "before cake" solution would be to either have all this in one class, or introduce delegates doing this or that.
The cake solution is to create specific traits for patients extraction, for payment data extractions, for claims processing, like
trait ClaimsHandler { self: ProcessorOfEverything =>
/* claim-related code */
}
and then write
class ProcessorOfEverything extends Something with PatientsExtractor with PaymentsExtractor with ClaimsHandler { /* almost nothing here */}
This could be refactored further down into cleaner components, if necessary.
The side effect is also that testability is easily available.