DSL * Tools in Visual Studio Stuart Kent Senior Program Manager Visual Studio Team System – DSL...

20
DSL DSL * * Tools in Visual Tools in Visual Studio Studio Stuart Kent Stuart Kent Senior Program Manager Senior Program Manager Visual Studio Team System – DSL Tools Visual Studio Team System – DSL Tools http://blogs.msdn.com/stuart_kent http://blogs.msdn.com/stuart_kent http://lab.msdn.microsoft.com/vs2005/teamsystem/worksho http://lab.msdn.microsoft.com/vs2005/teamsystem/worksho p/dsltools/ p/dsltools/ * DSL = Domain Specific Language

Transcript of DSL * Tools in Visual Studio Stuart Kent Senior Program Manager Visual Studio Team System – DSL...

Page 1: DSL * Tools in Visual Studio Stuart Kent Senior Program Manager Visual Studio Team System – DSL Tools

DSLDSL** Tools in Visual Studio Tools in Visual Studio Stuart KentStuart Kent

Senior Program ManagerSenior Program Manager

Visual Studio Team System – DSL ToolsVisual Studio Team System – DSL Tools

http://blogs.msdn.com/stuart_kenthttp://blogs.msdn.com/stuart_kent

http://lab.msdn.microsoft.com/vs2005/teamsystem/workshop/dsltools/http://lab.msdn.microsoft.com/vs2005/teamsystem/workshop/dsltools/

* DSL = Domain Specific Language

Page 2: DSL * Tools in Visual Studio Stuart Kent Senior Program Manager Visual Studio Team System – DSL Tools

What is a domain?What is a domain?

Implementation

Specification

Requirements

Deployment

BusinessSystems

Real-TimeSystems

Aircraftcontrol

systems

AirlineBaggageHandlingSystems

InsuranceManagement

Systems

Page 3: DSL * Tools in Visual Studio Stuart Kent Senior Program Manager Visual Studio Team System – DSL Tools

What is a language?What is a language?C(x) h C(x) t 2m xih = –

Textual Pictorial

Declarative

Procedural

class Magnox : NuclearPowerStation {

public void dropRods ()

jo biscuits 24 green

pat cakes 32 pink

Employeename

addresspromote

Jobdescription

payassign

0..*

a>b && c==d

call

CallRecord

call length

base rate: £/s

store

<CallRecord>

<caller><number>07713248</number>

Page 4: DSL * Tools in Visual Studio Stuart Kent Senior Program Manager Visual Studio Team System – DSL Tools

Domain Specific Languages (DSLs) make Domain Specific Languages (DSLs) make problems “Small Scale”problems “Small Scale”

Small scale =Small scale =

Not much design beyond existing platformNot much design beyond existing platform

easy to understandeasy to understand

agileagile

small team small team

early prototypesearly prototypes

easy maintenanceeasy maintenance

changes inexpensivechanges inexpensive

Page 5: DSL * Tools in Visual Studio Stuart Kent Senior Program Manager Visual Studio Team System – DSL Tools

Finding prime numbers is Small Finding prime numbers is Small Scale …Scale …

If we have a system that can:If we have a system that can:

do multiplication and divisiondo multiplication and division

do things repeatedlydo things repeatedly

_*__*__/__/_

_%__%_while (…) {…}while (…) {…}

C, Pascal, Fortran,…

Von Neumann computer with conventional CPU

language:platform:

Page 6: DSL * Tools in Visual Studio Stuart Kent Senior Program Manager Visual Studio Team System – DSL Tools

Finding parts lists is Small Scale …Finding parts lists is Small Scale …

If we have a system that can:If we have a system that can:

keep large lists of parts & scan them quicklykeep large lists of parts & scan them quickly

combine and filter the lists efficientlycombine and filter the lists efficiently

CREATE …CREATE …JOIN …… WHERE …

JOIN …… WHERE … SELECT …SELECT …

Relational Database SQL

platform: language:

Page 7: DSL * Tools in Visual Studio Stuart Kent Senior Program Manager Visual Studio Team System – DSL Tools

Developing a GUI is Small Scale …Developing a GUI is Small Scale …

If we have a system that can:If we have a system that can:

display combinations of windows and widgetsdisplay combinations of windows and widgets

show things and interact with user in themshow things and interact with user in them

Visual programminglanguages

Interactive appplatform

platform: language:

Page 8: DSL * Tools in Visual Studio Stuart Kent Senior Program Manager Visual Studio Team System – DSL Tools

if we have a if we have a languagelanguage of phone billing of phone billing

and a and a platformplatform to run it on to run it on

Phone billing systems are Small Phone billing systems are Small Scale …Scale …

Phone Billing Engine

call

calendarmonth

CallRecord

call length

base rate: £/s

call length

friend discount rate: £/sstore

friends calls

other calls

-

bill

billing period

store

Telephone Billing Scheme

Page 9: DSL * Tools in Visual Studio Stuart Kent Senior Program Manager Visual Studio Team System – DSL Tools

prospectinitiated

prospective sale

empty

overflow

Sat

weekly

accumulator4

£20

1 week delay

£30

prospectcancels

salesperson’saccount31

monthly

bank a/c

pay

7

£

tablet PC

customer

customer

-facingdeveloper

animator prototype

for review

tweak

hack

Using a domain specific languageUsing a domain specific language

generator phone billsystem

Page 10: DSL * Tools in Visual Studio Stuart Kent Senior Program Manager Visual Studio Team System – DSL Tools

Other things you can do…Other things you can do…

prospectinitiated

prospective sale

empty

overflow

Sat

weekly

accumulator4

£20

1 week delay

£30

prospectcancels

salesperson’saccount31

monthly

bank a/c

pay

7

£

generator phone billsystem

animator prototype

for review

generator list of parts

generator business plan

C#

XML

C#C#, Java

XML

SQL

mixed codeand configfiles

Page 11: DSL * Tools in Visual Studio Stuart Kent Senior Program Manager Visual Studio Team System – DSL Tools

prospectinitiated

prospective sale

empty

overflow

Sat

weekly

accumulator4

£20

1 week delay

£30

prospectcancels

salesperson’saccount

31

monthly

bank a/c

pay

7

£

animatorprototype for review

generator phone bill system

Other inputs to generationOther inputs to generation

functionalmodel

datamodel

existingapi model

tweak

hack

functional modelrefined/augmented

for performance

refine

etc

Page 12: DSL * Tools in Visual Studio Stuart Kent Senior Program Manager Visual Studio Team System – DSL Tools

““Mind The Gap” –Mind The Gap” –DSLs & Code GenerationDSLs & Code Generation

Model

Application Code

PlatformFrameworks

Model

Generated Code

Platform

Model

Application Code

PlatformFrameworks

Model

Generated Code

Platform

Model

Application Code

PlatformFrameworks

Model

Generated Code

Platform

Model

Application Code

PlatformFrameworks

Model

Generated Code

Platform

(b)(b)

Model

Application CodeDomain Specific

Framework

PlatformFrameworks

Model

Generated CodeFramework

Pattern Language

Platform

Model

Application CodeDomain Specific

Framework

PlatformFrameworks

Model

Generated CodeFramework

Pattern Language

Platform

Model

Application CodeDomain Specific

Framework

PlatformFrameworks

Model

Generated CodeFramework

Pattern Language

Platform

Model

Application CodeDomain Specific

Framework

PlatformFrameworks

Model

Generated Code

Framework

Platform

(c)(c)

Application Code

Model

PlatformFrameworks

Generated Code

Model

Platform

Application Code

Model

PlatformFrameworks

Generated Code

Model

Platform

Application Code

Model

PlatformFrameworks

Generated Code

Model

Platform

Application Code

Model

PlatformFrameworks

Generated Code

Model

Platform

(a)(a)

PlatformFrameworks

Application Code

Model

Platform

Generated Code

Model

PlatformFrameworks

Application Code

Model

Platform

Generated Code

Model

PlatformFrameworks

Application Code

Model

Platform

Generated Code

Model

PlatformFrameworks

Application Code

Model

Platform

Generated Code

Model

(d)(d)

Page 13: DSL * Tools in Visual Studio Stuart Kent Senior Program Manager Visual Studio Team System – DSL Tools

What are (could) DSLs (be) used for?What are (could) DSLs (be) used for?

To write models that drive code generatorsTo write models that drive code generators

Configuring code frameworks, configuring deploymentConfiguring code frameworks, configuring deployment

DSL unifies points of variability scattered amongst artefactsDSL unifies points of variability scattered amongst artefacts

Delivers software product linesDelivers software product lines

To write interpreted configuration filesTo write interpreted configuration files

Often expressed in XMLOften expressed in XML

To provide a domain-specific abstractions for the purposes of…To provide a domain-specific abstractions for the purposes of…

Simulation/animationSimulation/animation

Monitoring system executionMonitoring system execution

What-if analysisWhat-if analysis

Metric takingMetric taking

Generating business plans and reportsGenerating business plans and reports

……

As part of a software factoryAs part of a software factory

Combines all of the above Combines all of the above

Page 14: DSL * Tools in Visual Studio Stuart Kent Senior Program Manager Visual Studio Team System – DSL Tools

How are DSLs implemented now?How are DSLs implemented now?

XMLXMLSyntax very raw, no graphicsSyntax very raw, no graphics

Validation weakValidation weak

Multiple cross-referencing docs are difficult to manageMultiple cross-referencing docs are difficult to manage

N.B. Required for large models in a team environmentN.B. Required for large models in a team environment

UML profiles (UML + stereotypes / tagged values)UML profiles (UML + stereotypes / tagged values)XML persistence ugly & hard to handleXML persistence ugly & hard to handle

Stereotypes / tagged values not very powerfulStereotypes / tagged values not very powerful

UML profiles can bear little semantic resemblance to UML profiles can bear little semantic resemblance to mainstream UMLmainstream UML

Game of square peg in round holeGame of square peg in round hole

Packaging in UML is not so conducive to working with large Packaging in UML is not so conducive to working with large models in a team environmentmodels in a team environment

Page 15: DSL * Tools in Visual Studio Stuart Kent Senior Program Manager Visual Studio Team System – DSL Tools

How are DSLs implemented now?How are DSLs implemented now?

MOF/EMFMOF/EMFDeals with conceptual aspects of languageDeals with conceptual aspects of language

Rest of designer/editor is hand-codedRest of designer/editor is hand-coded

In meta-environmentsIn meta-environmentsReleases a meta-monster that can be hard to tameReleases a meta-monster that can be hard to tame

Often doesn’t scale to large models in a team Often doesn’t scale to large models in a team environmentenvironment

Tools not integrated into familiar IDEsTools not integrated into familiar IDEs

Page 16: DSL * Tools in Visual Studio Stuart Kent Senior Program Manager Visual Studio Team System – DSL Tools

DSL Tools in Visual Studio – V1DSL Tools in Visual Studio – V1

To make it cost-effective to develop DSL-To make it cost-effective to develop DSL-specific, visual designers hosted in Visual Studiospecific, visual designers hosted in Visual Studio

For SI’s & large enterprises (at least)For SI’s & large enterprises (at least)

For a particular class of DSLsFor a particular class of DSLs

In a way that makes the model data easily In a way that makes the model data easily accessible by automation tools, that are easy to accessible by automation tools, that are easy to author using XML and/or .Net technologyauthor using XML and/or .Net technology

In a way that enables working with large models in a In a way that enables working with large models in a team environmentteam environment

To make it cost-effective to author DSL-driven To make it cost-effective to author DSL-driven code/artefact generatorscode/artefact generators

Page 17: DSL * Tools in Visual Studio Stuart Kent Senior Program Manager Visual Studio Team System – DSL Tools

Mainline scenarioMainline scenarioWizard

Creates and configures VS “MDF Designer”

solution from (a) template(s)

Define DSL

Object model editorStructure

SerializationConstraints

Notation editorNotationExplorer

Properties gridValidation behaviour

Add codeBody of constraints

Diagram layoutOther enrichments

F5Generate

BuildLaunch VS Exp on debugging

solution

Debug

Build installer for deployment

Page 18: DSL * Tools in Visual Studio Stuart Kent Senior Program Manager Visual Studio Team System – DSL Tools

DemoDemo

We’ll build a designer from scratchWe’ll build a designer from scratch

Here’s a screenshot of the target Here’s a screenshot of the target designer…designer…

Page 19: DSL * Tools in Visual Studio Stuart Kent Senior Program Manager Visual Studio Team System – DSL Tools
Page 20: DSL * Tools in Visual Studio Stuart Kent Senior Program Manager Visual Studio Team System – DSL Tools

DSL Tools in Visual Studio DSL Tools in Visual Studio Stuart KentStuart Kent

Senior Program ManagerSenior Program Manager

Visual Studio Team System – DSL ToolsVisual Studio Team System – DSL Tools

http://blogs.msdn.com/stuart_kenthttp://blogs.msdn.com/stuart_kent

http://lab.msdn.microsoft.com/vs2005/teamsystem/workshop/dsltools/http://lab.msdn.microsoft.com/vs2005/teamsystem/workshop/dsltools/