Markus Völter voelter@acm voelter.de
description
Transcript of Markus Völter voelter@acm voelter.de
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 1 -
MDSD Intro & Overview
Markus Vö[email protected]
Model-DrivenSoftware Development
Introduction and Overview
www.mdsd-buch.de
www.mdsd-book.org
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 2 -
MDSD Intro & Overview
Domain Driven Development
• Domain Driven Development is about making software development more domain-related as opposed to computing related. It is also about making software development in a certain domain more efficient.
Software TechnologyConcepts
Domain Concepts
Software TechnologyConcepts
Domain Concepts
mental workof developers
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 3 -
MDSD Intro & Overview
How MDSD works
• Developer develops model(s)based on certain metamodel(s), expressed using a DSL.
• Using code generation templates, the model is transformed to executable code.• Alternative: Interpretation
• Optionally, the generated code is merged with manually written code.
• One or more model-to-model transformation steps may precede code generation.
ModelModelModel
Transformer TranformationRules
Model
TransformerCode
GenerationTemplates
Generated CodeManuallyWrittenCode
optional
Metamodel
Metamodel
optio
nal,
can
be
repe
ated
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 4 -
MDSD Intro & Overview
Reasons for DDD
• Software Development is too complex and too expensive (now, this is a really new finding ) …
… because:• There is too little reuse• Technology changes faster than developers can learn • Knowledge and practices are hardly captured explicitly
and made available for reuse• Domain experts cannot understand all the technology
stuff involved in software development
• DDD aims at attacking some of these problems.We shall see how on the following slides.
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 5 -
MDSD Intro & Overview
What is a „Domain“
• A definition could be:
A domain is a bounded area of knowledge or interest.
• Examples (from the world of Software) include:• eBanking• Embedded Software• Web-Based eBusiness Applications• Control Software for 4-Cylinder Diesel Engines• Astronomical Image Processing Software
• Domains can have varios „scopes“ as well as various „flavours“ – see next slides.
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 6 -
MDSD Intro & Overview
Hierarchical Structuring of Domains
• Since Domains can be of any size or granularity, it is useful to structure domains hierarchically.
• Automotive Example:
• eBanking Example:
EmbeddedSystems
AutomotiveSystems
Engine Controllers
Diesel Gasoline4-Cyl
eBusinessApps
web-based
RichClients
e-Banking
moneytransfer
inv.bank.
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 7 -
MDSD Intro & Overview
„Kinds“ of Domains
• In the context of software development it is also useful to distinguish (at least) two kinds of domains:
• Technical Domains adress key technical issues related to software development such as•Distribution, Failover and Load-Balancin•Persistence and Transactions•GUI Design•Concurreny and Realtime
• Functional Domains represent the business/professional issues; examples include•Banking•Human resource management• Insurance•Engine Controllers•Astronomical Telescope Control
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 8 -
MDSD Intro & Overview
MDSD Core Concepts
Model
DomainSpecific
Language
Metamodeltextual
graphical
Domain
Ontology
bounded area ofknowlege/interest
semantics
precise/executable
multiple
partial
viewpoint
subdomains
composable
Metametamodeltarget
softwarearchitecture
softwarearchitecture
transform
compile
interpret
multi-step
single-step
noroundtrip
knowledge
several
designexpertise
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 9 -
MDSD Intro & Overview
Example 1: Model and Metamodel
interface Sensor { operation start():void; operation stop():void; operation measure():float;}interface Controller { operation reportProblem(Sensor s, String errorDesc ):void;}
*
{ordered}Interface
name : Stringtype : String
Operation
name : Stringtype : String
Parameter
type : String
Exception**
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 10 -
MDSD Intro & Overview
Example 2: Model (J2ME apps)
NumberEntryForm
a: Number ["a"] {a>0}b: Number ["b"] {b>0}
CalcResultDisplay
["The Result is "+c]{align=center}
["Abort"]
["Result"]
>> a,b c: Number;c = a + b
>> c
["Again"] ["Exit"]
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 11 -
MDSD Intro & Overview
Example 2: Metamodel (J2ME apps)
name : String
UIElement
Form
label : Stringconstraints: String
Display
varName : Stringlabel : Stringconstraints: String
Field
Flow
transportedVars: String
AutoFlow
label : StringtransportedVars: String
Button
Element
Start End
declaredVars: Stringexpression : String
Calculation
1 to
1 from
outbound*
inbound*
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 12 -
MDSD Intro & Overview
Example 3: Model (Components, Ports, Connectors)<system name=”weatherStation”> <node name=”main”> <container name=”main”> <instance name=”controller” type=”Control”/> </container> </node> <node name=”inside”> <container name=”sensorInside”> <instance name=”tempInside” type=”TemperatureSensor”>´ <param name=”unit” value=”centigrade”/> </instance> </container> </node> <node name=”outside”>…</node>
<!-- temperature sensor outside --> <connector name="toSensorTempOutside"> <providedPort instance="tempOutside" port="measurementPort"> <requiredPort instance="controller" port="sensorsPort"> </connector> <connector name="fromSensorTempOutside"> <providedPort instance="controller" port="controllerPort"> <requiredPort instance="tempOutside" port="controllerPort> </connector> <!-- humidity sensor outside --> <connector name="toSensorHumOutside">…</connector> <connector name="fromSensorHumOutside">…</connector> <!-- temperature sensor inside --> <connector name="toSensorTempInside">…</connector> <connector name="fromSensorTempInside">…</connector></system>
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 13 -
MDSD Intro & Overview
Example 3: Metamodel (Components, Ports, Connectors)
*
ComponentRef
name : String
ComponentInstance
1
System Node* *Connector
Type
1 type
DirectCallConnector
SharedMemoryConnector
CANConnector
{open}
ProvidedPortRef
RequiredPortRef
id : String
Connector
1 1source target
*
context Connectorinv: source.interface == target.interface
Container
*
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 14 -
MDSD Intro & Overview
Example 4: Workflow Model (UML + Stereotypes)
+ verfuegbarkeitPruefen( reservierungsBeginn : Date, reservierungsEnde: Date, gewaehlteStationID : String, gewaehlteKfzKlasseID : String ) : Collection
+ getReservierungsParameter() : ReservierungsParameterVO
+ kfzReservieren( reservierungsBeginn : Date, reservierungsEnde: Date, gewaehlteKfzNr : String, mitgliedsNr : String ) : ReservierungBestaetigenVO
<<ProcessObject>>ReservierungDurchfuehrenPO
- Mitglied : String- Station : String- Kfz : String- ReservierungsBeginn : Date- ReservierungsEnde : Date
<<ValueObject>>ReservierungBestaetigenVO
- stationen : Collection- kfzKlassen : Collection
<<ValueObject>>ReservierungsParameterVO
- ReservierungsBeginn : Date- ReservierungsEnde : Date- Station : String- KfzKlasse : String- KfzBezeichnung : String- KfzNr : String
<<ValueObject>>VerfuegbarkeitPruefenVO
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 15 -
MDSD Intro & Overview
Example 4: Workflow Model II (UML + Stereotypes)
+ AnmeldungErfolgreich() : Boolean
<<ActivityController>>BenutzerAnmeldenCtrl
+ Weiter()+ Ende()
- kennung : String- passwort : String
<<Presentation>>BenutzerAnmelden
- Name : String- Passwort : String- Kennung : String
<<ValueObject>>BenutzerAnmeldenVO
benutzerAnmelden( kennung : String, passwort : String ) : BenutzerAnmeldenVO
<<ProcessObject>>BenutzerAnmeldenPO
- <<Key>> Name : String- Passwort : String- Kennung : String
<<EntityObject>>Benutzer
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 16 -
MDSD Intro & Overview
Example 5: Power Grid
SomePlace: Generator
G11: GenerationElement
20KV: Bus
link11
T11: Transformer
link12
220KV: Buslink13end11
link14
SomeOtherPlace: SwitchingStation
end21
transmissionLine1
B21-220KV: Bus
link21
B22-10KV: Bus
T21: Transformer
link22
link23
link24
end22
SomePlace:Generator
SomeOtherPlace:SwitchingStation
end11 end21 end22
transmissionLine1
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 17 -
MDSD Intro & Overview
Example 5: Power Grid Metamodel
GenerationElement
MicroNode Link1 targetNode sources 0..*
1 sourceNode targets 0..*
Transformer Bus Endpoint
MacroNodeTransmission
Line
1 targetNode sources 0..*
1 sourceNode targets 0..*
0..*parts
Generator BranchPoint SwitchingStation
sourceEndPoint 1 1 targetEndPoint
targetTransmissionLine 0..1 0..1 sourceTransmissionLine
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 18 -
MDSD Intro & Overview
MDSD Core Values
• We prefer to validate software-under-construction over validating software requirements
• We work with domain-specific assets, which can be anything from models, components, frameworks, generators, to languages and techniques.
• We strive to automate software construction from domain models; therefore we consciously distinguish between building software factories and building software applications
• We support the emergence of supply chains for software development, which implies domain-specific specialization and enables mass customization
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 19 -
MDSD Intro & Overview
MDSD Core Building Blocks
• domain analysis
• meta modelling
• model-driven generation(and: model transformation)
• template languages
• domain-driven framework design
• the principles for agile software development
• the development and use of Open Source infrastructure
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 20 -
MDSD Intro & Overview
MDSD and Requirements/Analysis
• An often-asked question is: are MDSD models the same as requirements/analysis models?• They can be, but in general, they
are not.• Analyis/requirements models
are non-computational, MDSD models are compuatational.
somewhere the „intellectual work of development and problem solving“ has to be put into the system. Usually, this is on the stage from requirements/analysis to (computational) MDSD models.
• How can MDSD help with requirements?• Formalizing Requirements using a DSL is benefitial
because requirements become unambigious.
Model
SystemModel
Business Model(Domain Model)
LogicalModel
Physical Model(Deployment)
RequirementsModel
ComputationalModel
PIM PSM
Adap
ted
from
Fra
nkel
‘s b
ook
on M
DA
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 21 -
MDSD Intro & Overview
MDA and Model Driven Software Development Overview
Model
DomainSpecific
Language
Metamodeltextual
graphical
Domain
Ontology
bounded area ofknowlege/interest
semantics
precise/executable
multiple
partial
viewpoint
subdomains
composable
Metametamodel
transform
compile
interpret
multi-step
single-step
noroundtrip
UML+Profiles
MOF
OCL, Action Semantics
PIM, PSM, .... QVT
several targetsoftware
architecturesoftware
architecture
Applicationdesignexpertise
• Focus: Platform Independence, (Tool) Interop
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 22 -
MDSD Intro & Overview
Other related approaches
• Microsoft’s Software Factories:Focus on Reuse, Efficient Development, DSLs
• Domain-Specific (Visual) Modelling:Focus on (Visual) DSLs
• Generative Programming:Focus on Efficiency, “Automatic Manufactoring”, Software System Families
• Language-Oriented Programming:Focus on DSLs instead of Frameworks, incl. Editor/Debugger Support
all basically the same
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 23 -
MDSD Intro & Overview
MDSD and Agility
• Agile Manifesto:We are uncovering better ways of developing software by doing it and helping others do it. Through this work we have come to value: - Individuals and interactions over processes and tools - Working software over comprehensive documentation - Customer collaboration over contract negotiation - Responding to change over following a plan That is, while there is value in the items on the right, we value the items on the left more.
• MDSD-Models are no „paperwork“, they are the code which is translated to code automatically
• Agility does not oppose tools in general – compilers are ok, model transformers are a kind of compiler
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 24 -
MDSD Intro & Overview
MDSD and Agility II
• Project automation (ant, cruisecontrol) is ok in „agile minds“, so is automation of the writing of repetitive code
• Automation of the development process makes responding to change easier and faster (single source principle). • Changes in the model respond to changes in the functional
requirements• Changes in the templates/transformations can be used to
evolve the architecture
• The customer on-site can be integrated better, if we have languages that are better related to domain concepts as opposed to 3GL code or the like.• Pair programming between developer and domain expert is
more realistic.
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 25 -
MDSD Intro & Overview
MDSD and Agility III
• Tests can still be written manually (even before generation), generators can help is building mocks or scenarios
• We do not recommend a waterfall that first builds generators and then builds apps, rather, both are iteratively evolved in parallel. • Domains Architectures are based on experience, not
based on „big design upfront“
• Developers can do what they can do best:• Some deal with applications and customer requirements,• Others deal with technical architecture, platforms and
generators
• So: There is no problem with Agility and MDSD!
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 26 -
MDSD Intro & Overview
Reasons for using MDSD
• You want to provide a way for your domain-experts to formally specify their knowledge, and to provide a way for your technology people to define how this is implemented (using model transformations).
• You might want to provide different implementations (i.e. more concrete models) for the same model, perhaps because you want to run it on different platforms (.NET, Java, CORBA).
• You may want to capture knowledge about the domain, the technology, and their mapping in a clear, uncluttered format.
• In general, you don’t want to bother with implementation details when specifying your functionality.
• MDSD results in a fan-out, i.e. one set of models can be the source for transformations to several targets.
• Another reason for using MDSD: You are working in the context of product lines and software system families and need to develop domain-specific assets.
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 27 -
MDSD Intro & Overview
MDSD Benefits I
• Models are free of implementation artifacts – they directly represent domain knowledge and are thus reusable.
• Implementations for various platforms can be generated in principle – the technology change problem is adressed to some extend.
• Technology freaks and domain experts can take care of „their business“ (transformations and models, respectively) and need to care of each other‘s problems only in a limited way.
• Domain experts can play a direct role in development since they can more easily understand models expressed with a DSL as opposed to implementation code.
Domain Experts play the central role they deserve!
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 28 -
MDSD Intro & Overview
MDSD Benefits II
• Development becomes more efficient since repetitive implementation code can be generated automatically.
• Architectural contraints/rules/patterns can more easily be enforced, since the they are embedded in the templates rather than just being documented (and ignored).
This is especially important in really large teams, often in the context of Product-Line Engineering and Software System Families.
• Transformer/Generator can address cross-cutting concerns (just like an aspect weaver)
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 29 -
MDSD Intro & Overview
MDSD Predjudices
• MDSD does not require UML – any kind of modelling language is ok, graphical or textual
• Precise and complete models…• … are not the the same as „visualized code“ – the
abstraction level is higher• … are not the same as analysis models – analysis models
are not computational
• MDSD does not require – not even recommend – a waterfall. Development of the generative infrastructure is iterative and incremental.
• You do not need big and expensive tools – a lot of small and useful open source tools are available.
• You don‘t need to generate 100% of the code – it is ok, to also code some aspects in a 3GL.
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 30 -
MDSD Intro & Overview
Benefits for Software Quality
• MDSD requires an explicit, well-defined architecture. Defining an architecture this way improves the quality of the system (indpendent of whether it is generated or not).
• Transformations capture expert knowledge. The generated code reflects this expert knowledge uniformly.
• An Domain Archtitecture defines a strict programming model for the manually developed parts – again, uniformity and constrained-ness improves quality.
• Generator does not produce accidental errors – either things are always right or always wrong. This makes finding errors easier!
• Models can serve as an up-to-date and always current documentation.
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 31 -
MDSD Intro & Overview
Benefits for Software Quality II
• In general, MDSD forces you to take care of many good things, which you‘d like to have in any application development project:
• Domain/Application Scoping
• Variability Management
• Well-Defined Software Architecture, Architecture Metamodelling
• Trying to build a generator for a domain/target architecture enables your understanding of the domain/target architecture. This in itself is a huge benefit.
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 32 -
MDSD Intro & Overview
No Free Lunch - Challenges
• You need additional skills in your team (domain analysis , metamodelling, generator development, architecture)
You need a couple of good people who usually aren‘t easy to get, and who aren‘t cheap.
• Your development process needs to reflect the two-track nature of MDSD (domain architecture development, application development)
• Sometimes tools require some „creative use“ and improvisation ( use open source!)
• Remember: a fool with a tool is still a fool
generator
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 33 -
MDSD Intro & Overview
MDSD (compared to “normal” Software Development)
Level of Detail
Result ofAnalysis
virtual or realImplementation model Implementation
Info
rmat
ion
Gai
n
Start
GoalImplementation
Analysis
Design
Effort
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 34 -
MDSD Intro & Overview
MDSD Effort (stage 1)
Level of Detail
Results ofAnalysis
virtual or realimplementation model Implementation
Info
rmat
ion
Gai
n
Start
GoalImplemen-
tation
Analys
is
Effort
Modell
ing
Automation
Savings based onthe use of a semantically
rich platform
Savingsbecause
of Generation
A
A' B
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 35 -
MDSD Intro & Overview
MDSD Effort (stage 2)
Level of Detail
Results ofAnalysis
virtual or realimplementation model Implementation
Info
rmat
ion
Gai
n
Start
Goal
Analy
sis
Effort
Mod
ellin
g
Automation
Savings based onthe use of a semantically
rich platform
Savingsbecause
of generation
A
BA'
i n g e n i e u r b ü r o f ü r s o f t w a r e t e c h n o l o g i e w w w . v o e l t e r . d e © 2003 - 2006 M a rk u s V ö l t e r- 36 -
MDSD Intro & Overview
Some advertisement
• For those, who speak(or rather, read) german: Völter, Stahl: Modellgetriebene SoftwareentwicklungTechnik, Engineering, ManagementdPunkt, 2005www.mdsd-buch.de
• A very much updated translation isunder way:Model-Driven Software Development, Wiley, Q2 2006www.mdsd-book.org
Update currently in progress,
with Arno Haase and Sven Efftinge as
additional coauthors