Chapter 4. Building DSLs

 

In this chapter

  • How to build an application based on DSLs
  • Creating the Message-Routing DSL
  • Creating the Authorization DSL
  • Creating the Quote-Generation DSL

In this chapter, we’ll look at how to design an application that uses DSLs to do much of its work. We’ll cover several of those DSLs in detail (and leave others for later), and we’ll explore how to build, instantiate, and execute those DSLs in the context of our application. We’re going to focus on two types of DSLs, the ones most commonly used in business applications: technical DSLs and business DSLs.

Technical DSLs are generally used as bootstrapping and configuration mechanisms to make it easier to modify a part of a system. In general, those DSLs enable recurring tasks, usually of a one-off nature. Scripting is a common use for technical DSLs—configuration or build scripts, for example. Combining the power of a flexible language with a DSL designed for the task at hand makes for a powerful tool. Everything you do with a technical DSL can be done using code, but the DSL should make it easier and simpler. A DSL makes it easy to produce a one-off solution to a problem.

4.1. Designing a system with DSLs

4.2. Creating the Message-Routing DSL

4.3. Creating the Authorization DSL

4.4. The “dark side” of using a DSL

4.5. The Quote-Generation DSL

4.6. Summary

sitemap