October 2019
Intermediate to advanced
434 pages
11h 54m
English
When thinking about how to create our DSL, we'll want to consider what syntax we would like to have, as well as what our solution would look like without a DSL. Let's start by imagining what our code might look like without using any kind of DSL.
Without a DSL, we might write code that looks something like this:
val order = Order("123")order.items.put(Sprite, 1)order.items.put(Coke, 1)val pizza1 = HawaiianPizza()pizza1.toppings.add(Pepperoni)val pizza2 = BuildYourOwn()pizza2.toppings.add(Pepperoni)pizza2.toppings.add(Olive)order.items.put(pizza1, 1)order.items.put(pizza2, 1)
In this code, we're able to create all of our items in a very ordered, imperative way. It's pretty easy to follow, but there is ...
Read now
Unlock full access