Traits as stackable modifications

Before we learn about stackable modifications, we should know why we may need them, shouldn't we? Yes, so the best way to understand that is by using an example. Suppose there's a consumer of a service. He can pay to subscribe to a particular service. That service, for example your DTH TV subscription service, includes several channel packages. Now, what's of interest to us here is that we may want to implement this service. For implementation, we want to have a list of channels or packages the consumer is subscribed to. At the beginning of the month, he subscribed to a particular package, let's say BasicPackage. So we said the following:

new Service with BasicPackage 

This, in fact is self-explanatory. We ...

Get Learning Scala Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.