Mdsf: Introduction to DSL (domain specific language)

Source: Internet
Author: User
ArticleDirectory
    • One Language
    • DSL content
    • DSL Architecture
    • Advantages of DSL applications
    • Styles)
    • Application scenarios
    • Books

Model-driven development (MDD), software factory, and domain-specific modeling (DSM) are all highly abstract development methods, the languages used by these methods are specific domain languages (DSL ). Compared with the general target language (C #/C ++/Java/Delphi), DSL is a development language designed for specific tasks, for example, SQL is a language dedicated to database processing,This article will introduce DSL.

One Language

Well-knownProgramming Language(Such as C # And Ruby) is a common language. MDA is based on the UML language, while model-driven development (MDD) is based on DSL. DSL is a language based on a specific field.Make the work closer to the customer's understanding, rather than the implementation itself,This facilitates all participants to communicate in the same language during the development process.

DSML

DSML is a domain-specific modelling language. DSML is used in the metaedit + DSM method described earlier, it is a DSL that can be used to build a graphic model. DSM gopprr is a metadata model used to build a DSML language.

DSL content
    • Problem domain and Problem Space
    • Syntax and Semantics
    • Cases, methods, and tools

DSL Architecture

    • DSL Script: the core of each DSL is a domain model, which defines various concepts represented by this language, the attributes of these concepts, and the relationship between them

      • A language used for building, configuring, or other purposes in the problem domain
      • It Can Be text, graphic, or both.
        • the graphic language is not just a chart. Otherwise, you can use the drawing software such as Visio to create a model, this model should be able to describe the system you are creating in a conceptual sense and map its content. A model can be represented by multiple charts at the same time. Each chart represents an aspect of the Model
        • text language user input allows quick typing.
        • the advantage of text language is that it can be compared and merged, while graphical expressions can easily see the association between content.
        • relatively speaking, text languages are more complex than graphics
    • semantic model)
      • A full representation of DSL script memory
      • sometimes this is the abstract syntax tree (AST)
      • separate parse and generate
    • Generate Code (generated code): one of the most important applications of DSL is to produce simple text-format artifacts, for example, Source Code , database script
      • an executable representation of DSL scripts
      • Semantic Interpretation Model
Advantages of DSL applications
    1. High-level reuse: If only common programming languages are used, only one problem can be solved at a time. However, if a development method in a specific field is used to design and implement some special languages, each special language can efficiently solve a similar problem.
    2. The software architecture using DSL can bridge the gap between various stages of the software engineering process, especially through code generation, which can be well designed and implemented.
    3. To involve field experts in the development process is not only the demand stage, but also the architecture stage.
    4. By working in the problem space, people who are not familiar with how to implement technology, including business people, can also better understand the model.
    5. The Model Expressed by DSL can be verified at the high abstraction level of the problem space, which means that errors caused by understanding and expression can be found at an early stage of the development cycle.
    6. A model has important business knowledge. It is easier to migrate a solution from one technology to another or between different versions of the same technology. Generally, you can modify the generator or interpreter as needed.
Styles)

BeforeOpenexpressapp: [opentest]-How to implement an automated testing frameworkThis article introduces an automated testing language implemented by using Ruby syntax on OEA, which is an internal DSL. WhilePreliminary plan for Modeling Support in openexpressappMetamodelengie described in is an external DSL.

External DSL can get rid of the restrictions of internal DSL host language and re-design a new language, but it increases the learning cost of learning a new language and requires the support of tools.

Design DSL

To reduce risks,We didn't start developing the framework and Its DSL right away.Instead, we should start from the existing code that can be used in some applications and gradually parameterize it to gradually discover the changes in different applications, then make these parts dependent on DSL.

The top-down approach tends to quickly build a complete and self-contained model with long-term considerations, helping to ensure structural consistency.. However, on the other hand, this method may easily lead to complicated model design at the conceptual layer, and this model is difficult to implement. Therefore, in practical application,It is more effective to use both top-down and bottom-up methods.A progressive approach can avoid excessive early investment risks, but regular consistency checks are required.

In 《Development Guide for specific fields of Visual Studio DSL toolsThe following steps are taken to design a DSL:

    1. Recognizing variability and discovering DSL: DSL is the variable part of your architecture model with your framework.
    2. Development domain model capture Variability
    3. Defining tags: Use common markup or conventions related to the markup method where appropriate
    4. Development Validation constraints: Identify the dependencies between trees and recognize the forced or prohibited loops in snapshots
    5. Development and Evolution framework: understand the code architecture of your DSL and write it in the Framework
    6. Test DSL: includes verification constraints and rules, generators and commands, and generated code.
    7. Evolution and Transplantation of DSL: ensures that the old model can be used in the new DSL version.
    8. Recognized DSL: range, minimum, common markup, moderate redundancy, reasonable use of syntax space, use of user terms
Application scenarios

......

Books

Martin Fowler spent several years writing a DSL book "domain specific languages". I haven't read it yet. If you are interested, first look at the series of articles it has written on the website domain specific ages.

 

Best practices for dsls and model-driven development

Reading Notes: Development Guide for specific fields of Visual Studio DSL tools

DSL Evolution


Recommended: online e-books you may need

 

You are welcome to reprint it. Please note: Reprinted fromZhou jingen [http://zhoujg.cnblogs.com/]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.