Domain Specific Development Stuart Kent, Senior Program Manager, Visual Studio Team System, Microsoft Copyright Microsoft 2006
Domain Specific Development Pattern Model Abstraction of the variable part, expressed in a Domain Specific Language Framework, API, Interpreter, Integrate Fixed Part Hand-crafted Generate, interpret, some of each Microsoft 2006 2
Contents Domain Specific Development Pattern Demo 1 Wizard UIP example DSD a Software Factory Pattern Domain Specific Languages (DSLs) Integration: Generation versus Interpretation from/of models Costs & benefits of the DSD approach DSL Tools in Visual Studio Demo 2 Building and deploying a DSL What Next? DSL Tools What Next? Software Factories Microsoft 2006 3
Demo 1 Wizard User Interaction Process Model Expressed in Graphical Page Flow DSL UIP framework Windows Forms Integrate Fixed Part Additional control logic code added Generate: Some control logic code Starter UI Config file that s interpreted Microsoft 2006 4
Reminder DSD Pattern Model Abstraction of the variable part, expressed in a Domain Specific Language Framework, API, Interpreter, Integrate Fixed Part Hand-crafted Generate, interpret, some of each Microsoft 2006 5
Domain Specific Language Classification domain specific language Horizontal GUI web business logic database deployment Vertical telephone bills insurance ticketing hardware construction next slide general purpose specific Microsoft 2006 6
Parts of a DSL + validation Domain Model Microsoft 2006 7
Reminder DSD Pattern Model Abstraction of the variable part, expressed in a Domain Specific Language Framework, API, Interpreter, Integrate Fixed Part Hand-crafted Generate, interpret, some of each Microsoft 2006 8
What does Integrate mean? Generate Generate code that talks to framework APIs E.g. completely new classes Generate code that completes a framework Interpret E.g. C# partial classes The model file itself, or some data pushed into a live environment from the model (e.g. xml configuration file, data in a database) is interpreted A Combination of the above Easier to produce initially More customization options Behavior can be changed at run-time Fewer artifacts to keep in sync Microsoft 2006 9
Customization (1) What? Customize/extend the behavior expressed by the model + fixed part Why? However good the fixed part, not every point of variability will have been predicted Some things (e.g. complex logic) are just easier to express in code avoids reinventing programming languages in a DSL There will be undiscovered bugs in the code generators / interpreter / framework which need to be fixed somehow DSL Area customization Microsoft 2006 10
Customization (2) customization Platform customization DSL Area Customization step Hand crafted code for specific plug-points Expert customization step Change the code generators Change the framework Microsoft 2006 11
Customization (2) Platform customization DSL Area Interpretation Customization step Hand crafted code for specific plug-points Expert customization step Generation Change the code generators Change the framework Microsoft 2006 12
Domain Specific Development Cost / Benefit Benefits Cost Fewer copies of the same code to maintain Fix bug in code generators or framework fixes for all Change in requirements (e.g. business rules) = change in model Change in technology = change in code generators / framework Better communication with stakeholders Creating/maintaining the DSL / code generators / framework potentially across many projects and versions Model Integrate Fixed Part Goal of Microsoft DSL Tools is to bring down this cost Microsoft 2006 13
DSL Tools in Visual Studio What? Tools for authoring and deploying DSLs and templatebased text artefact (e.g. code) generators Where? Now installed as part of the Visual Studio SDK http://msdn.microsoft.com/vstudio/extend/ Also see http://msdn.microsoft.com/vstudio/dsltools/ When? About to release Version 1 (Sept 06) Microsoft 2006 14
Reminder Parts of a DSL + validation Domain Model DSL Tools V1 Microsoft 2006 15
Designer for a DSL in Visual Studio Microsoft 2006 16
DSL Tools Modeling Platform In-memory graph database with rich services (e.g., transactions, serialization, rules, ) Artifact generation Extensible drawing surface with support for routing and auto-layout Visual Studio UI integration for components like toolbox, menus, properties grid, explorer Templating Engine Checks constraints and guides user to resolve issues Validation F work Design Surface Framework Domain Model Framework Shell Framework Microsoft 2006 17
DSL Tools Architecture of a Designer DSL Definition hand crafted designer extensions text templates generated directive processor Templating Engine hand coded validation logic Validation F work generate generated serializers generated domain classes generated shape 2 class mappings generated shapes Design Surface Framework Domain Model Framework generated shell code Shell Framework Microsoft 2006 18
A DSL for Activities Rejected Apply for pre-approved Loan Accepted Setup on-line account for customer Create credit check report Microsoft 2006 19
Defining a DSL, Step 1: Define Domain model Apply for pre-approved Loan Setup on-line account for customer Create credit check report Microsoft 2006 20
Defining a DSL, Step 2: Define Notation Rounded Rectangle Outline color: orange Fill color: white Apply for pre-approved loan Text Decorator Position: Source, bottom Accepted Text Decorator Position: Center Connector solid orange filled arrowhead Microsoft 2006 21
Defining a DSL, Step 3 Define visualization of domain model via notation elements Shape Domain Model Apply for pre-approved loan Microsoft 2006 22
Demo 2 Building & Deploying a DSL Microsoft 2006 23
Contents Domain Specific Development Pattern Demo 1 Wizard UIP example DSD a Software Factory Pattern Domain Specific Languages (DSLs) Integration: Generation versus Interpretation from/of models Costs & benefits of the DSD approach DSL Tools in Visual Studio Demo 2 Building and deploying a DSL What Next? DSL Tools What Next? Software Factories Microsoft 2006 24
What Next? DSL Tools Key problem is how to deal with large-scale models Possible solutions Visualize the model through multiple diagrams, possibly involving many designers Better facilities for expand/collapse, exploiting model structure (e.g. trees) Zooming in/out of diagrams Drill-in/drill-out with different notations being used for different levels of detail Use of autolayout Break up model into multiple files to support finer-grained source control Small designers integrated into software factories What else? Also new notations, better authoring, Microsoft 2006 25
What Next? Software factory platform DSL Tools become part of a wider Software Factory platform A software factory is a configuration of a software development environment aimed at developing systems in a particular domain E.g. you may have a software factory aimed at building web front ends for enterprise systems Software factories might need further customization on a per project basis, or indeed constructed for a specific project (generative programming) E.g. code generators may need to be adjusted to account for existing legacy systems Software factories integrate: DSLs associated with viewpoints Code generation actions Discovery actions Orchestration & coordination of DSLs, mappings between DSLs and actions Guidance for users of the factory, that integrate with the orchestration & coordination of actions & DSLs We (Microsoft) are working on this now Microsoft 2006 26