Chapter 2. The DSL in the wild

 

This chapter covers

  • Designing your first Java-based DSL
  • Using Groovy to make your DSL more expressive
  • Patterns of DSL implementation
  • Choosing a DSL type

In the previous chapter, you saw how DSLs improve communication between the development team and the domain experts. We discussed the overall architecture of DSLs and the various execution models that they support. But what good are those DSLs without a meaningful, real-world use case? Given a real-world problem, how can you judge whether designing a DSL would be a better solution than using the traditional model of software development? In this chapter, we dive into these real-world pragmatics of DSL design.

We’ll start with a motivating example of the ground-up design, implementation, and refinement of a real-world DSL from our preferred domain of the financial brokerage business. We’ll look at a couple of implementations, then proceed to explain some of the general patterns that you’ll come across when you design DSL implementations. Figure 2.1 shows a visual roadmap of how we’re going to explore real-world DSLs in this chapter.

Figure 2.1. Roadmap for chapter 2

2.1. Building your first Java DSL

2.2. Making friendlier DSLs

2.3. DSL implementation patterns

2.4. Choosing DSL implementations

2.5. Summary

2.6. References

sitemap