Creating a Domain Specific Language: Get Out of the Trenches

The biggest challenge in designing your custom language constructs for use in Systir is deciding on the level and scope of the symbols you want to use. A macro like make_sure_application_works is of little use whereas statements like a = '5' and xml.parse(getResponse("http://google.com")).first_item are pure clutter and map to no requirements at all.

Always keep in mind that the purpose of the script is to test against a system requirement or user story. Therefore you should use constructs at or near that language level.

Guidelines

READABILITY cannot be stressed enough. It is of the utmost importance.

(Disclaimer: this section is under development; the author is just spouting a few items off the top of his head; notice that the example on the main Systir page breaks some of these ‘rules’.)

In your test language, IT IS OKAY TO:

  • Use long macro names to improve readability.
  • Make nearly-identical macros that imply light parameterization with slighlty different names.
  • Mess around with Ruby class definitions to bend the language to your will.
  • Add methods to the String and Fixnum classes to make your language read more cleanly.

In your test script, DO NOT:

  • Use parenthesis.
  • Create variables or objects.
  • Use concrete values.
  • Call macros for things that should be implicit.
  • Define new macros.
Edit