Groovy for Domain-specific Languages - Second Edition

(nextflipdebug2) #1
Chapter 11

[ 289 ]

Reward types

We are in the business of encouraging the subscriber to continue to consume content
out of plan or to upgrade to a higher plan. So our rewards programs will offer
incentives that apply at the time of purchase or upgrade. Rewards usually consist
of allocating free points, but we also want to be able to offer free content or
extended access.


Our partners are the studios, game developers, and record labels that publish
our content. We don't mind what content the subscriber consumes so long as our
revenue comes in. As our partners get a revenue share based on which titles the
subscriber consumes, they will want to be able to sponsor promotions that target
specific content and specific publishers. In other words, these particular types of
targeted reward programs need to be activated at the point of consumption rather
than purchase.


Some examples of the types of rewards that we might like to deploy are:



  • Consume any new release this week and get 10 free access points on
    your account

  • Earn 10 percent bonus points for every game purchased

  • Watch any Disney movie for 25 percent off

  • Upgrade from basic to plus and get 100 free access points on your account


The reward DSL

Taking all of this into account, we can make an attempt at writing a DSL.
The requirements that we have for our DSL can be summarized as follows:



  • Rewards need to be triggered by different events in the system. These
    events are consumption (when a user consumes a product—that is, watch
    a movie, play a game, and so on), upgrades (when the user upgrades their
    subscription plan), and purchases (any time that the user spends some cash).

  • Rewards need to be based on one or more conditions, such as the user's
    spending history or the type of media being consumed.

  • Rewards can result in the granting of different benefits, for example free
    access to a video, bonus points, and extended access.

Free download pdf