Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Groovy for Domain-Specific Languages, Second Edition

You're reading from   Groovy for Domain-Specific Languages, Second Edition Extend and enhance your Java applications with domain-specific scripting in Groovy

Arrow left icon
Product type Paperback
Published in Sep 2015
Publisher
ISBN-13 9781849695404
Length 386 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Fergal Dearle Fergal Dearle
Author Profile Icon Fergal Dearle
Fergal Dearle
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Introduction to DSLs and Groovy FREE CHAPTER 2. Groovy Quick Start 3. Essential Groovy DSLs 4. The Groovy Language 5. Groovy Closures 6. Example DSL – GeeTwitter 7. Power Groovy DSL Features 8. AST Transformations 9. Existing Groovy DSLs 10. Building a Builder 11. Implementing a Rules DSL 12. Integrating It All Index

What this book covers

Chapter 1, Introduction to DSLs and Groovy, discusses how DSLs can be used in place of general-purpose languages to represent different parts of a system. You will see how adding DSLs to your applications can open up the development process to other stakeholders in the development process. You'll also see how, in extreme cases, the stakeholders themselves can even become co-developers of the system by using DSLs that let them represent their domain expertise in the code.

Chapter 2, Groovy Quick Start, covers the basics of installing Groovy and running simple Groovy scripts.

Chapter 3, Essential Groovy DSLs, covers two essential Groovy-based tools, Gradle and Spock. Gradle is a build, test, and deployment automation tool, which is powered by a Groovy DSL. Spock is a unit testing and specification framework built over JUnit. Both tools are used extensively throughout the book.

Chapter 4, The Groovy Language, covers a whistle-stop tour of the Groovy language. It also touches on most of the significant features of the language as a part of this tour.

Chapter 5, Groovy Closures, covers closures in some depth. It covers all of the important aspects of working with closures. You can explore the various ways to call a closure and the means of passing parameters. You will see how to pass closures as parameters to methods, and how this construct can allow the adding of mini DSL syntax to our code.

Chapter 6, Example DSL – GeeTwitter, focuses on how we can start with an existing Java-based API and evolve it into a simple user-friendly DSL that can be used by almost anybody. You'll learn the importance of removing boilerplate code and how you can structure our DSL in such a way that the boilerplate is invisible to our DSL users.

Chapter 7, Power Groovy DSL Features, covers all of the important features of the Groovy language, and looks in depth at how some of these features can be applied to developing DSLs.

Chapter 8, AST Transformations, covers how to use the Groovy abstract syntax tree (AST) transformations. AST transformations are a mechanism for us to hook into the Groovy compilation process. Here we look at compile time metaprogramming and see how we can use AST transformations to build code on the fly during the compilation process.

Chapter 9, Existing Groovy DSLs, discusses some existing Groovy DSLs that are in current use and are free to download.

Chapter 10, Building a Builder, explains how Groovy provides two useful support classes that make it much simpler to implement our own builders than if we used the MOP. You'll see how to use BuilderSupport and FactoryBuilderSupport to create our own builder classes.

Chapter 11, Implementing a Rules DSL, takes a look at Groovy bindings to see how they can be used in our DSL scripts. By placing closures strategically in the binding, you can emulate named blocks of code. You can also provide built-in methods and other shorthand by including closures and named Boolean values in the binding. These techniques can be used to great effect to write DSL scripts that can be read and understood by stakeholders outside of the programming audience.

Chapter 12, Integrating It All, takes all the knowledge from the previous chapters and builds a fully functioning web application based on a simple Game Engine DSL for Tic Tac Toe.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime