FREE Subscription to Dr. Dobb’s Digest: Same Great Content, New Digital Edition
Site Archive (Complete)
Email
Print
Reprint

add to:
Del.icio.us
Digg
Google
Furl
Slashdot
Y! MyWeb
Blink
TABLE OF CONTENTS
May 31, 2007

Evolving a Domain-Specific Language

(Page 2 of 4)

What Makes a Good DSL?

A good DSL -- one that helps the people who are using it -- makes it easy to clearly represent information for a particular purpose. The following are some characteristics of a good DSL:

  • Well-defined scope. There is an easy-to-state single purpose for the DSL -- for example, "to describe the permitted sequence of states of issues in a project."
  • Minimality. There are no more concepts and relationships than are required for the ideas that need to be described with the DSL. If you can see a way to reduce the number without losing information, do so.
  • Familiarity. If there is a notation already in use in the domain -- railroad tracks? electrical circuits? -- base your notation on that. If the type of information is normally associated with a particular style of diagram -- statecharts -- use the conventions familiar there. Adapt the notation where you need to.
  • Bring out the important bits. The most important things should be the most obvious and easiest to change: names of states, transitions between them. Less important detail -- for example, the target namespace of the generated code -- can be left to the properties window. If you need to print out the full detail for some reviews, write a report template.
  • Moderate amount of redundancy. Ensure that when the user has made an important distinction, it was intentional. For example, we flag an error if the user has not marked a state with no incoming transitions as "start." On the other hand, users don't like to have to say everything twice, so don't overdo it.
  • Use the syntactic space. Most of the diagrams a user can draw should be meaningful. A language that is heavy with complex constraints probably doesn't fit the conceptual space well and is difficult to remember how to use. The big advantage of a DSL is that the notation guides you through useful things to say.
  • Graphs are not syntax trees. If you have an existing text notation, it is unlikely that its syntax tree will be the best graphical notation. See the example on regular expressions in the next section.
  • Allow for customization. Your DSL will not cover all the cases that users will require. Provide for further customization through handwritten code, preferably without forcing the users to alter generating templates.
  • Use the users' language. The language should be expressed in its users' terms, talking about their requirements -- rather than its implementations. Talk about issues rather than tables. Where it's difficult to avoid bringing in some implementation concerns, try to package them up in a single domain class, or by exploiting categories in the properties window. For example, in the DSL designer you'll find that properties that are mostly concerned with the form of the generated code are always gathered together under a "Code" category.

To illustrate the last few points further, we will consider the development of a different example.

Previous Page | 1 Introduction | 2 What Makes a Good DSL?</ | 3 Regular Expressions Example | 4 Candidate Notations Next Page
TOP 5 ARTICLES
No Top Articles.
DR. DOBB'S CAREER CENTER
Ready to take that job and shove it? open | close
Search jobs on Dr. Dobb's TechCareers
Function:

Keyword(s):

State:  
  • Post Your Resume
  • Employers Area
  • News & Features
  • Blogs & Forums
  • Career Resources

    Browse By:
    Location | Employer | City
  • Most Recent Posts:
    MEDIA CENTER  more
    NetSeminar
    Modernize your Development by Moving Build and Code Quality Upstream
    Moderated by Jon Erickson, Editor-in-Chief of Dr. Dobb's, this interactive panel discussion brings industry experts Anders Wallgren, CTO of Electric Cloud and Gwyn Fisher, CTO of Klocwork together for a candid discussion of the cost savings, productivity and quality benefits that can be achieved by stabilizing builds and code quality as early in the development cycle as possible.

    The reality of today's development environment - geographically distributed teams, the use of Agile development practices, increasing application complexity, etc. - is straining the viability of the traditional coding, build and release process. To stay ahead of the curve, development teams are modernizing their approach to dealing with these issues, and as a result are achieving new levels of development productivity. Register for the webcast.
    Date: Wednesday, July 15, 2009
    Time: 11 am PT/2 pm ET
    Modernize your Development by Moving Build and Code Quality Upstream
    Moderated by Jon Erickson, Editor-in-Chief of Dr. Dobb's, this interactive panel discussion brings industry experts Anders Wallgren, CTO of Electric Cloud and Gwyn Fisher, CTO of Klocwork together for a candid discussion of the cost savings, productivity and quality benefits that can be achieved by stabilizing builds and code quality as early in the development cycle as possible.

    The reality of today's development environment - geographically distributed teams, the use of Agile development practices, increasing application complexity, etc. - is straining the viability of the traditional coding, build and release process. To stay ahead of the curve, development teams are modernizing their approach to dealing with these issues, and as a result are achieving new levels of development productivity. Register for the webcast.
    Date: Wednesday, July 15, 2009
    Time: 11 am PT/2 pm ET
                                   
    INFO-LINK

    Resource Links: