What can be created with DSL?

Is DSL just for structural design or processes could also be designed
How DSL development is different from developing a framework from extensibility point of view and by aplying changes
How constraints are implemented are there any relations with OCL
Could DSL be used for Data modelling (keys, trigers, constraints)


Answer this question

What can be created with DSL?

  • RyanB88

    Yes, I'd expect a DSL to express only a given aspect or viewpoint of a problem.

    Let's suppose your company majors in software that drives airport baggage handling systems.

    Some of the code is the same in every system you deliver -- the bits that drive the junctions where bags come together, and makes sure they don't all pile up in a heap; and the bits for reading bar codes and driving the routing devices that divert a bag down one track or another. But some of the code changes every time. Partly that's just because every airport has some ad-hoc requirements of its own; partly, it's because there are specific things that always differ -- notably, the topology of the conveyor system.

    In fact, when you first meet with a new customer, it's never long before you're both up at the whiteboard drawing a diagram of the conveyor belts, the checkin desks, the carousels, the gates, holding bins, and so on. At first, these diagrams are just things your analysts use to talk with the customers. and Visio is as formal as they get. The analysts hand the diagrams over to the developers, along with the rest of the specifications, and the devs get to work and six months later they've created Yet Another Bag Handling System - loosely based on a theme honed across all the previous contracts.

    But then one night you wake up with a brilliant idea: you could generate some of the code from those diagrams. Not all of it, to be sure, but a good chunk of it. That would save the developers a lot of time.

    To get to that point, of course, you have to do some refactoring to get the software sufficiently generic.  And you have to adapt it to accept some form of configuration file, or some plug-in code, that defines the bag track topology. (The plug-in patterns are usually partial classes or delegates or subclasses, as Brian says.) 

    Then you can define a language in DSL Tools, with all the belts and checkins etc; and author a template that converts a model in Belt Topology Language to the configuration file(s) or plug-in code.  Then when you get the next customer, that aspect of the system is a breeze.  And you can generate a hardware parts list from BTL as well.

    That still leaves a lot of variable stuff that isn't covered - all the ad-hoc requirements; and some other stuff that changes systematically, that we might invent a separate language for. That's where we use the plug-in or weaving stuff. And sure as anything, the next customer will come up with some weird bag-managing device we've never seen before, so we'll have to adapt our language or plug extra bits in.



  • Phoenix wolfe

    Are there any plans to move the templates into the DSL project instead of the project where you use the DSL

    Ideally I don't want the users of my DSL to be able to change the templates, nor even see them. They should rather just see the created artefacts, right I feel the right user interface design would be that the node for the DSL file in a project can be expanded and that all the artefacts created from that DSL appear there. This would be in sync with the model used for other DSLs like WinForms, XSD desigern etc.

  • Mehul123

    Thanks Alan. Gives me a bit more to look at. And I was actually wondering how GAT Would figure into all of this...

    But, that example you gave is still somewhat academic. I mean the aim has to be to build an VS integrated designer, like the class designer and deploytment designer, that are bound within a project to the generated artifacts. Creating and editing templates in the debug environment from dsl is obviously not the end result you are looking for, and going to be limited in use.

  • Bito

    Aidas

    Yes, a project will often use several DSLs.  The overall context for DSLs is our Software Factories vision, see http://msdn.microsoft.com/architecture/overview/softwarefactories/

    In terms of your question, DSLs are "heterogeneous".  We provide a text templating engine that allows you to generate any kind of code or textual artifact. You can generate multiple different files in different languages from the same language.

    Steve Cook [MSFT]

  • James Divine

    Dear MS DSL Team,

    I am really impressed by what you have come up with so far. But what you really must also provide is an example of how your tools can actually help a user create an end product.

    Please keep in mind, 99% of users of Visual Studio do not churn out software(s) like a factory. They create one or a few applications and they are stuck with their creation for years to come, often 10-20 years. In those long years, their creation must be constantly modified and upgraded (release after release, just like your Visual Studio itself). The most important thing you guys can help is to synchronize the code (all sorts) with design (and necessary documentation).

    As for your factory, please do take some time to demonstrate ONE simple, but real application, demonstrating to us how your DSL can help produce an application (such as a typical web application) from design to the end product.

    Great job so far, look forward to seeing even more.

    Many thanks


  • phil_lee

    At present, the aim is to make tools from which code and configuration files etc can be generated, where -unlike CD - the models are *not* 2-way synchronised with the generated artefacts. Generative toolsets have their own useful properties -- see, for example, the book Generative Programming by Czarnecki & Eisenecker. 
    But as you say, we do have bigger ambitions in the longer term.



  • freewind

    Thank you, Steve, for your response!

    Is it true, that for developing a project several DSL's will be (and should be ) used

    Is DSL output homegeniuos i.e. one DSL generates just one type of code
    For class development there is a Class Designer - which generates C#
    For web user interacion process it would be possible to construct a custom DSL which generates aspx and let's say for client Java Scrips an other DSL
    I mean DSL's are distributed horizontally in the project.
    Or
    DSL output is heterogeniuos i.e. one DSL could generate code from JavaScript to SQL. In case of framework
    Or both ways are possible
    Or am I completely wrong

    PS I'm not able to use DSL Tools beta yet, but I hope I'll straighten out soon Smile


  • Damien White

    I feel like I'm missing a basic part of the picture here. I've run through all the examples, and can understand how DSL tools can be used to generate modelling languages, and construct models using that language.

    But how is the transformation to an end artifact such code to be accomplished I am assuming that we then have to write additional tools to perform the transformation based on the model I've seen how they work in visual studio with the distributed system diagrams (which are I belive dsl based), but am wondering what we are supposed to be doing set up our versions of processing for say the "Implement Application..." and "Implement All Application..." from the model.

    Eg, with say an Entity Relationship model, we specify the dsl, and then create a model representing our schema, create entities with attributes etc. But then we need to be able to create (for example) a database creation script from it, and vice versa. How does the toolset assist with this process Or doesn't it Is this related to the "text templating engine" you mention If so, I'm unable to find any references to this elsewhere on msdn.

    It'd be nice to have an integrated example, rather than just fragments of simple academic examples. Say for the Application Diagram setup - the DSL, the tools for doing the transformation, etc.

    Thanks.

  • c#_novice

    Aidas, in answer to your several questions:

    >Is DSL just for structural design or processes could also be designed

    You can design a domain-specific language with structural and/or process semantics.  An example of a structural language would be a designer for data entities or classes; an example of a process language would be a flowchart or state diagram.  These and many others are possible.

    >How DSL development is different from developing a framework from extensibility point of view and by aplying changes

    A DSL is often designed to be complementary to a framework.  A DSL can be used to generate code that completes a framework.

    >How constraints are implemented are there any relations with OCL

    We will be providing a constraint evaluation framework in a future version of the DSL Tools.  In this framework, constraints will be defined by a combination of declarative techniques plus attributed code. We do not plan to support OCL in the current version.

    >Could DSL be used for Data modelling (keys, trigers, constraints)

    Yes, certainly: these concepts can be modelled in the domain model and used to generate data definition and code files.

    Steve Cook [MSFT]

  • hoowahfun

    That's a great idea, and one that's already on our list of things to consider (with usual caveats about juggling the effort we have available).  At present, the best you can do is to make the template a tiny bit more hidden, by using an @import directive (see how they're used in most of the template files in a DSL project).



  • Zeeshan

    Felix,

    I am in the process of creating a DSL based on an existing product / toolset, so I'll give a picture as to how I see our DSL being used.
    I have no idea how close this is to the Software Factories ideals, but I do believe it is a practical and useful scenario.

    I imagine our customers will create a new project in VS to encapsulate that part of the solution where our DSL is appropriate. This project will reference and/or be referenced by other projects in a solution that covers the entire application under development.

    Within this project the users will be able to draw a diagram (or set of diagrams) based on the DSL.
    From those diagrams they can produce both code and documentation (even if and when code generation becomes 100% perfect I believe there will always be a demand for documentation).

    The code will not be 100% complete. We are not going to attempt to anticipate how the user wants this code to interact with the rest of the solution (certainly not in version 1) so there will be places for handwritten code, or code written by other code generators based on WSDL or persistence engines or whatever. This other code will be integrated through some combination of partial classes and appropriate use of abstract classes and virtual methods.

    So the effect will be that for the piece of the puzzle covered by our DSL the user will be able to use the abstraction provided by the DSL. That piece can then be written with greater speed/flexibility/predictability/etc. That piece will be encapsulated and isolated from the rest of the puzzle in good OO fashion.

    (All of this is IMHO. YMMV. etc.)

    Brian.

  • Sam Stokes

    Hi Michael,

    Yes, the idea is that, as a language author, you write templates (rather like asp files, if you've seen them) to generate artifacts -- they can be code or config files or documents or whatever you like. Then when you or colleagues are using the language, the template reads the model and creates an artifact from it. You can have many templates reading the same model, so can get a big stack of stuff generated from one model.

    To see a very simple example of this working, if you've installed the DSL Tools:
     * Create a new DSL project (File>New Project> Other Project Types/Extensibility/Domain-Specific; then choose, let's say, Entity-Relation template in the wizard).
     * Hit ctrl-F5 to build the language designer and run it in an Experimental hive of VS
     * Open Empty.xyz and pull some shapes onto the drawing surface. Change the names of some boxes.
     * Save it
     * In the Solution Explorer (you might have to find its tab again), open MyLanguageReport.ReportTemplate
     * Edit "filename='Full.xyz'"  --> "filename='Empty.xyz'"  (line 3)
     * Save it
     * Open its subsidiary file -- in the solution explorer, click the [+] next to MyLanguageReport.ReportTemplate
     * Notice how your model has generated this html

    Now, if you're feeling enthusiastic, here's some experiments to try:
     * In the solution explorer, make a copy of the .ReportTemplate file. Check that the new copy has its "Custom Tool" property set to "TextTemplatingFileGenerator"
     * Open the new template file and change line 2 to say exension=".cs" or ".sql" or whatever you like. Save it and notice that the subsidiary file is now called "....cs" or whatever
     * Change the template code to generate some sql or C# etc.  Notice that you're using the language defined in the DSLDM file, back in the language-authoring instance of VS. For example, if you've got Entity x, you can say x.ReferencedEntity, as defined in the grammar.
     * Whenever you save the template (or even switch to look at a different file, which I find a bit irritating) the generator re-runs.
     * When you've got your new template working, go back to your .xyz model and change it. Then save and hit the "Transform All Templates" button at the top of the solution explorer. Notice now that both your new template and the original have updated. You can imagine how you could generate a whole project full of files, all derived from your model.

     

    An example we're hatching -- yes, you're right we should put up some decent examples, and we're addressing that -- is a language for defining the sequence of pages in a wizard in the form of a flow chart. As a user of the language, you first generate a project that contains a number of templates - either just take a copy of an existing one, or use the new GAT system -- then draw the required sequence of pages in the ".uip" language file. Then you hit the "Transform All Templates" button, and the project files get updated to code for the wizard you've defined. Then you can hit F5 and run the wizard; and then use the winforms editor on each page, to fix its layout.


    - Alan Wills



  • new2

    I have questions on the concepts behinds as well as the standard procedure to define a new model.

    In Software Factories, we have software line development and software development so as to automate fully or partially the code generation. How can DSL separate the two kinds of development And if the code can only be partially generation, how do developers integrate hand-written code with the automatically generated code

    What does DSL really mean in technical sense I know that DSL is a modelling language not for documentation but automating the production of families of software or software for particular problem domain. It seems that there is some gray area. Are the creation or modification of templates part of the language Or the way I create a model part of the language

    Your examples have given me some insight to modify templates. But, I am not so clear how I can create a new model. Surely, I understand that I have to draw some stuff like UML class diagrams. Is that all I have to do

    Thanks.

  • What can be created with DSL?