Chapter 11
[ 287 ]
Marketers constantly devise new ways to promote products and services to
customers, but often the problem is that these promotions can be difficult to manage
when they need to be implemented in the various backend systems. Configuring
a reward could involve applying cross-cutting logic across several systems.
Developing and deploying a promotion can take weeks or months to complete,
while the marketing department wants to be able to respond to the conditions in
the market today.
In this next example, we will take an imaginary broadband service provider that
provides access to on-demand video and games content. We will devise a simple
Groovy-based DSL that expresses reward programs in simple-to-understand terms.
Although the DSL code is not going to be developed by a marketer, a marketer
should be able to understand what the code does simply by reading it. This DSL
also has the added benefit of being something that can be deployed directly. As such,
the DSL should be able to serve as both the specification and the implementation of
the reward.
Designing the DSL
Before attempting to design our DSL, it makes sense for us to review our business
domain and understand our requirements.
BroadbandPlus
Users of BroadbandPlus, our imaginary broadband service, can subscribe to
three levels of access: BASIC, PLUS, and PREMIUM. There is a range of content that a
subscriber can consume, including games, movies, and music. Each subscriber can
consume any mix of content up to the maximum allowed on their plan, after which
they need to pay for any additional content that they consume.
To simplify everything, we will track and allow the subscriber to pick and mix their
content. Each type of media consumed has an "access point" value, which is debited
from the user's account when they consume it. Each subscriber type is allocated a set
number of access points each month, based on their plan. The following table shows
how the access points structure works:
Subscription plan Monthly subscription Access points
Basic $9.99 120
Plus $19.99 250
Premium $39.99 550