2. What is scaffolding ?
• Scaffolds are
temporary structures
that physically support
workers while they
complete jobs that
would otherwise be
impossible
(HH93, p138)
3. Scaffolding in software
• Ruby on Rails
• *Rails scripting frameworks bring
blazing fast productivity in their own
specific technological space
• Mainly through Scaffolding !
4. Ruby on Rails Scaffolding
• Meta-Programming
• Scaffolding works at the code level
• Scaffolding engine operates on code as a model
• Can be either
– Static : on demand
– Dynamic : transparently on your behalf
Entity.rb
DAO.rb
6. What’s the point ?
• Model-Driven brings
quality, durability,
maintainability
• What about productivity ?
– Goal: Enhance modeling
expressiveness, simplicity
and overwhole productivity
7. What is Scaffolding applied
to Modeling ?
• Creating partial model structures on
behalf of the designer that he would
otherwise have to create by himself
9. Model Scaffolding
taxonomy
1. Classical code generation
2. Compensated code generation
3. « Blind » scaffolding
4. « In-Place » scaffolding
• Each static or dynamic
10. Sample problem domain
• 3-Tiers Architecture
• DSL containing concepts
– Entity
– DAO
– Service
• Java code is generated
• Légende
Generation
Reference
Model separation
File
Entity or DAO
Service
ScaffoldedGenerated
Hand-written
Color code
11. Classical code generation
1/2
• Entities are modeled
• Entity and DAO source
codes are generated
from the modeled Entity
• Problem: What if you
want to define queries in
your model ?
Entity
Entity.java
DAO.java
Model
Text
12. Classical code generation
2/2
• Entity and DAOs are modeled
• Entity source code is generated
from the modeled Entity
• DAO source code is generated
from modeled DAO
• DAOs which are not modeled
are not generated
• Problem: You need to define all
DAOs…
• Even those that only do CRUD
Entity
Entity.java
DAO.java
Model
Text
DAO
13. Compensated code
generation
• Source code is still generated
for modeled elements
• For Entities which have no
modeled DAO, we
compensate by generating
source code for the DAO from
the modeled Entity
• Advantage: Only custom DAOs
are modeled
• Problem: DAO code
generation logic is duplicated
– Entity -> DAO.java
– DAO -> DAO.java
Entity
One DAO
OneEntity
Two
One.java
OneDAO.java
Two.java
TwoDAO.java
Model
Text
14. Generation « Blind » Model
Scaffolding
• Each model is a step in the MDSD
chain
• An intermediate step is introduced
• Each model can only « see » the
model before
• Existing elements are copied as is
• A DAO is generated for each entity
which has no DAO
• Advantage: Only one DAO code
generation logic
• Problem: How do you reference
scaffolded elements
Entity
One
Entity
One
Entity
Two DAO
TwoDao
Entity
Two
DAO
TwoDao
DAO
OneDao
One.java
OneDAO.java
Two.java
TwoDAO.java
Model i
Model i-bis
Model i+1
15. How to reference scaffolded
elements ?
• The problem is illustrated by
introducing a service
• The ‘Alpha’ service can
reference the modeled DAO
‘TwoDao’ but not the
scaffolded DAO ‘OneDao’
• The scaffolded DAO ‘OneDao’
is located in a model that the
‘Alpha’ service cannot see
• Problem: « Blind » scaffolding
doesn’t allow scaffolded
elements referencing
Entity
One
Entity
One
DAO
OneDao
Service
Alpha
Modèle i
Modèle i-bis
Entity
Two
DAO
TwoDao
16. « In-place » Model Scaffolding
• ‘OneDao’ DAO is
scaffolded in the same
model as Entity ‘One’
• The DAO is « visible »
without being
materialized in the input
model
• Advantage: Le ‘Alpha’
service can reference the
scaffolded DAO ‘OneDao’
• Problem: How to
customize a scaffolded
element ?
Entity
One
DAO
OneDao
One.java
AlphaService.java
OneDao.java
Service
Alpha
Model i
Model i+1
17. Takeover 1/3: Overview
• User can take over
scaffolded elements
• The over taken element
is then materialized in
the input model
• Advantage: The DAO
can be customized
Entity
One
DAO
OneDao
Service
Alpha
Iteration n
Iteration n+1
Entity
One
DAO
OneDao
Service
Alpha
18. Takeover 2/3: Zoom
• After the DAO taking
over, CRUD methods
are still scaffolded
• Advantage: No need to
manually input
previously scaffolded
elements
Entity
One
Service
Alpha
Iteration n
Entity
One
Service
Alpha
DAO
OneDao
create
read
update
delete
DAO
OneDao
create
read
update
delete
Iteration n+1
19. Takeover 3/3: Customisation
• Let’s add a finder finder
• CRUD methods are still
scaffolded
• Advantage: Only
customizations are
hand written, CRUD
methods are scaffoldedEntity
One
Service
Alpha
DAO
OneDao
create
read
update
delete
myFinder
Entity
One
Service
Alpha
DAO
OneDao
create
read
update
delete
Iteration n+1
Iteration n+2
20. Deletion 1/2: The problem
• What happens if
the user deletes
an element for
which elements
were scaffolded ?
• Scaffolded
elements must
also be deleted
Entity
One
DAO
OneDao
One.java
AlphaService.java
OneDao.java
Service
Alpha
Model i
Model i+1
21. Deletion 2/2: solutions
• Need to keep track of scaffolded elements
• Only really a problem with dynamic « in-
place » scaffolding
• For static and/or « blind » scaffolding,
scaffolded elements can just be computed all
over again
23. What Scaffolding engine ?
• A model to model transformation engine ?
– ATL
– Xtend
– QVT Operational
– QVT Relational
– Obeo Transfo
– …
• A rule engine ?
– Drools
– Any OO Rule Engine …
24. A rule engine ??
• Scaffolding rules as production rules
• The model as a working memory
• Model elements as facts
• When a given condition is met, new facts are
inserted into working memory
• Those new facts are attached to the model as new
elements
25. Rule engine sync process
Entity
One
DAO
OneDao
Working MemoryModel
Entity
One
DAO
OneDao
reference
reference
synchronize
synchronize
Scaffolding
Rule
27. MDSD Scaffolding benefits
• Accelerates modeling
• Allows to quickly come up with a working model
• The user starts from the begining with a complete model
(complete in the direction the scaffolding takes him)
• Provides the user with a fast feedback
• Allows to enrich the input model as well as facilitating its
usage for the new user
• Brings flexibility while keeping simplicity
• Scaffolding can be complemented by code generation and
model validation
• The user can whenever he wants take over the scaffolded
elements in order to customize them
Editor's Notes
You might be wondering what scaffolding is
Those structures that you find on building sites
Here is a brief definition
It’s not important if you’ve not quite figured out what it is a the end of this slide
We’ll see pragmatic uses later on and should have figured it out by the time we get there
Scaffolding engine operates on the code as a model
Surprising that dynamic scaffolding has been dropped in ROR2
Maybe it’s because you lose control
Keeping control is really important
We’ll see later on how it’s achieved in modeling context
Static: The scaffolding occurs on demand. You ask for it explicitely
Dynamic: Scaffolding is going to occur transparently on your behalf
Broadly accepted that Model-Driven brings quality
You have to design each and every piece of the model that you’re working on
What if some pieces of the model could be defined on behalf of you ?
Temporary structures that facilitates user modeling while they complete jobs that they would otherwise have to do by themselves
Part of the model that is created on behalf of the user that he would otherwise have to create by himself.
Scaffolds are temporary structures that conceptually support designers while they complete jobs that would otherwise be cumbersome
Scaffolds are partial model structures created on behalf of the designer that conceptually support designers while they complete jobs that would otherwise be cumbersome
On modélise l’Entity et le DAO
Le code source de l’Entity est généré à partir de L’Entity modélisée
Le code source du DAO est généré à partir du DAO modélisé
Les DAO qui ne sont pas modélisés n’ont pas de code source généré
Problème: Nécessite de modéliser tous les DAO …
Même ceux qui ne font que du CRUD
Rule engine
Alternate computational model
Instead of the usual imperative model
Provides a list of production rules
Each rule has a condition and an action
When the condition is met, new facts are asserted