Site Archive (Complete)
Email
Print
Reprint

add to:
Del.icio.us
Digg
Google
Furl
Slashdot
Y! MyWeb
Blink
May 31, 2007
Evolving a Domain-Specific Language

(Page 1 of 4)
Steve Cook, Gareth Jones, Stuart Kent, Alan Cameron Wills
After designing and using a DSL for a while, you will inevitably want to change it

Steve Cook is a software architect for Microsoft, Gareth Jones is a professor of management at Texas A&M University, Stuart Kent is a program manager at Microsoft, and Alan Cameron Wills is technical director of TriReme International. This article was excerpted from their book Domain-Specific Development with Visual Studio DSL Tools. Copyright (c) 2007 Addison Wesley Professional. All rights reserved.


After designing and using a Doman-Specific Language (DSL) for a while, you will inevitably want to change it, and you will not want to lose the language instances that you have already created.

Changes in a DSL take one of the following forms:

  • Additions. New properties in a class or relationship; new classes; new relationships. The deserializer will take care of these, filling in default values when reading objects from older files.
  • Deletions. Properties, classes, or relationships removed. In this case, the deserializer will ignore the deleted elements.
  • Refactoring. A structure is replaced by something that represents the same information in a different way. For example, we might replace the Issue State Transition by a class with a pair of relationships on either side. Here, the deserializer will see some additions and some deletions but will not be able to do the translation automatically. Changes of property and relationship types come under the refactoring heading.

Of these, the language author needs to worry about refactorings. The following tactics mitigate the pain of change to some extent:

  • Separate refactorings. Identify and localize each refactoring, and plan separately how you will deal with each one. For example, one version change of the Issue State DSL might introduce a domain class to replace the Transition relationship, and might also introduce multiple issue types per project. As far as possible, we should keep those changes independent of each other.
  • Don't delete anything. Instead of deleting the old structure, just add the new one; for example, have both the Transition relationship and the domain class replacing it coexist in the same model. Deprecate the old structure by removing its tools from the toolbox, and any merge directives or connection builders that might deal with its creation, so that new instances can't be created. Then use one of the tactics that follow this one.
  • Ensure the tools work with both structures. During a migration period, ensure that the generating templates and other tools can work with both structures as much as possible. If the change is prompted by a changed requirement in what the tools generate, at least allow language users to edit and work with the old instances until they need to generate material from them.
  • Provide translation tools. One way is to provide a command that scans a store and updates the model in place. It is possible to make this happen on opening a file of an older version. Another convenient method of translating instance models is to write a generating template that creates the serialized form of the new version of the DSL from models of the older version. XSLT can also be used to translate one model file into another, given that they are both XML files.
  • Validate required fields. If you translate on opening an old file, make sure that your validation methods check any new fields so that the user is prompted to provide the required extra information.
  • Delete obsolete domain classes when you're sure all the instances are updated.
  • Publish the update plan to your language users so that they know when older structures will be obsolete.

Migration between language versions is an important and common problem. Having a forgiving file reader (deserializer) certainly relieves some of the pain, but you could do more. It is possible to conceive of tools that automate some of the above tactics. For example, one could maintain the history of changes to a domain model between versions and then use this information to generate a tool that does the conversion automatically.

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
    Audio
    2008 International Mathematica Conference
    Dr. Dobb's interviews Wolfram Research's Theo Gray, co-founder and Director of User Interfaces, and Roger Germundsson, Director of Research and Development, about the upcoming 2008 International Mathematica Conference.
    NetSeminar
    Extending Enterprise Value with Web 2.0
    In this webcast we will talk about how to simply build and quickly remix Web 2.0 applications and the role of the IT department and how they support mashups. We will discuss how IBM can help IT teams adapt existing enterprise systems as well as develop unique ones that can support end user driven mashups in a reliable, scalable and secure way. We will highlight a simple scenario adapting an enterprise information source for mashups and how to test it. We will also cover how IBM can help you build agile, fast and simple web applications based on dynamic scripting languages that dramatically reduces development time. Wednesday, September 24, 2008 - 12pm PT / 3pm ET
    The Great Debate: PostgreSQL vs. MySQL
    Common industry perceptions of MySQL and PostgreSQL aren't as true with the current generation of releases as they used to be. DBAs, developers, and IT managers and decision-makers will benefit from this presentation and live Q&A about the pros and cons of using PostgreSQL or MySQL, which will include a discussion about the ongoing trend towards using open source in the enterprise. Tuesday, October 7, 2008 - 9:00 AM PT / 12:00 PM ET
                                   
    EVENTS
    Software Development Best Practices 2008
    October 27-30, 2008
    Boston, MA
    Join us for Software Development Best Practices 2008, Dr. Dobb's premier east coast event, featuring world-class training on the entire software development lifecycle. Register today for a conference pass or a FREE Expo Pass!
    SD West 2009 Call for Papers
    SD West 2009 Call for Papers is Now Open!
    Please submit your speaking proposals by October 10, 2008 to be considered.

    Nominations for the Jolt Awards - the “Oscars” of the software development industry - are now open. Submit your Jolt-worthy products, books and technologies by October 24 to save 20%.
    INFO-LINK

    Resource Links:




    Related Sites: DotNetJunkies, SD Expo, SqlJunkies