Upload
others
View
2
Download
0
Embed Size (px)
Citation preview
Bidirectional transformations
workshop at Cargilfield
Perdita Stevens
University of Edinburgh
June 2017
Who am I? What’s my job?
Perdita Stevens
(Robin Bradfield’s mother!)
Professor of Mathematics of Software Engineering
University of Edinburgh
What’s software?
opposite of hardware
all the computery stuff you can’t break with a hammer...
Have you written a Scratch program?
Like that but bigger...
What’s software?
opposite of hardware
all the computery stuff you can’t break with a hammer...
Have you written a Scratch program?
Like that but bigger...
What’s software?
opposite of hardware
all the computery stuff you can’t break with a hammer...
Have you written a Scratch program?
Like that but bigger...
Almost random example bit of code
void SAL_CALL BaseContainerControl::dispose() throw( RuntimeException,
std::exception )
{
// Tell everything that this container is now gone.
// It’s faster if you listen to both the control and the container.
// Ready for multithreading
MutexGuard aGuard( m_aMutex );
// remove listeners
EventObject aObject;
aObject.Source.set( static_cast<XControlContainer*>(this), UNO_QUERY );
m_aListeners.disposeAndClear( aObject );
// remove controls
Sequence< Reference< XControl > > seqCtrls = getControls();
Reference< XControl > * pCtrls =
seqCtrls.getArray();
sal_uInt32 nCtrls =
seqCtrls.getLength();
size_t nMaxCount =
maControlInfoList.size();
size_t nCount = 0;
for ( nCount = 0; nCount < nMaxCount; ++nCount )
{
delete maControlInfoList[ nCount ];
}
maControlInfoList.clear();
for ( nCount = 0; nCount < nCtrls; ++nCount )
{
pCtrls [ nCount ] -> removeEventListener ( static_cast<
XEventListener* >( static_cast< XWindowListener* >( this ) ) );
pCtrls [ nCount ] -> dispose ( );
}
// call baseclass
BaseControl::dispose();
}
Size...“In a Nutshell, LibreOffice...
...
has had 452,587 commits made by 1,672 contributors representing9,087,155 lines of code
...
is mostly written in C++ with an average number of source codecomments
...
has a well established, mature codebase maintained by a very largedevelopment team with stable Y-O-Y commits
...
took an estimated 2,773 years of effort (COCOMO model) startingwith its first commit in September, 2000 ending with its mostrecent commit 18 days ago ”https://www.openhub.net/p/libreoffice as at 19/6/17
Other examples
Lines of code in:
A simple game on a mobile phone: about 10,000
A heart pacemaker: about 80,000
The Hubble Space Telescope: about 2,000,000
Curiosity Mars Rover: about 2,500,000 (or is it about5,000,000? Does it matter?)
A Boeing 787: about 14,000,000
Average modern high-end car: about 100,000,000
All Google’s code, in 2015: about 2,000,000,000
Sources: http://www.visualcapitalist.com/millions-lines-of-code/
http://www.itworld.com/article/2985099/application-management/
thats-one-big-repository-heres-how-many-lines-of-code-google-has.html
Other examples
Lines of code in:
A simple game on a mobile phone: about 10,000
A heart pacemaker: about 80,000
The Hubble Space Telescope: about 2,000,000
Curiosity Mars Rover: about 2,500,000 (or is it about5,000,000? Does it matter?)
A Boeing 787: about 14,000,000
Average modern high-end car: about 100,000,000
All Google’s code, in 2015: about 2,000,000,000
Sources: http://www.visualcapitalist.com/millions-lines-of-code/
http://www.itworld.com/article/2985099/application-management/
thats-one-big-repository-heres-how-many-lines-of-code-google-has.html
Other examples
Lines of code in:
A simple game on a mobile phone: about 10,000
A heart pacemaker: about 80,000
The Hubble Space Telescope: about 2,000,000
Curiosity Mars Rover: about 2,500,000 (or is it about5,000,000? Does it matter?)
A Boeing 787: about 14,000,000
Average modern high-end car: about 100,000,000
All Google’s code, in 2015: about 2,000,000,000
Sources: http://www.visualcapitalist.com/millions-lines-of-code/
http://www.itworld.com/article/2985099/application-management/
thats-one-big-repository-heres-how-many-lines-of-code-google-has.html
Other examples
Lines of code in:
A simple game on a mobile phone: about 10,000
A heart pacemaker: about 80,000
The Hubble Space Telescope: about 2,000,000
Curiosity Mars Rover: about 2,500,000 (or is it about5,000,000? Does it matter?)
A Boeing 787: about 14,000,000
Average modern high-end car: about 100,000,000
All Google’s code, in 2015: about 2,000,000,000
Sources: http://www.visualcapitalist.com/millions-lines-of-code/
http://www.itworld.com/article/2985099/application-management/
thats-one-big-repository-heres-how-many-lines-of-code-google-has.html
Other examples
Lines of code in:
A simple game on a mobile phone: about 10,000
A heart pacemaker: about 80,000
The Hubble Space Telescope: about 2,000,000
Curiosity Mars Rover: about 2,500,000 (or is it about5,000,000? Does it matter?)
A Boeing 787: about 14,000,000
Average modern high-end car: about 100,000,000
All Google’s code, in 2015: about 2,000,000,000
Sources: http://www.visualcapitalist.com/millions-lines-of-code/
http://www.itworld.com/article/2985099/application-management/
thats-one-big-repository-heres-how-many-lines-of-code-google-has.html
Other examples
Lines of code in:
A simple game on a mobile phone: about 10,000
A heart pacemaker: about 80,000
The Hubble Space Telescope: about 2,000,000
Curiosity Mars Rover: about 2,500,000 (or is it about5,000,000? Does it matter?)
A Boeing 787: about 14,000,000
Average modern high-end car: about 100,000,000
All Google’s code, in 2015: about 2,000,000,000
Sources: http://www.visualcapitalist.com/millions-lines-of-code/
http://www.itworld.com/article/2985099/application-management/
thats-one-big-repository-heres-how-many-lines-of-code-google-has.html
Other examples
Lines of code in:
A simple game on a mobile phone: about 10,000
A heart pacemaker: about 80,000
The Hubble Space Telescope: about 2,000,000
Curiosity Mars Rover: about 2,500,000 (or is it about5,000,000? Does it matter?)
A Boeing 787: about 14,000,000
Average modern high-end car: about 100,000,000
All Google’s code, in 2015: about 2,000,000,000
Sources: http://www.visualcapitalist.com/millions-lines-of-code/
http://www.itworld.com/article/2985099/application-management/
thats-one-big-repository-heres-how-many-lines-of-code-google-has.html
Other examples
Lines of code in:
A simple game on a mobile phone: about 10,000
A heart pacemaker: about 80,000
The Hubble Space Telescope: about 2,000,000
Curiosity Mars Rover: about 2,500,000 (or is it about5,000,000? Does it matter?)
A Boeing 787: about 14,000,000
Average modern high-end car: about 100,000,000
All Google’s code, in 2015: about 2,000,000,000
Sources: http://www.visualcapitalist.com/millions-lines-of-code/
http://www.itworld.com/article/2985099/application-management/
thats-one-big-repository-heres-how-many-lines-of-code-google-has.html
Other examples
Lines of code in:
A simple game on a mobile phone: about 10,000
A heart pacemaker: about 80,000
The Hubble Space Telescope: about 2,000,000
Curiosity Mars Rover: about 2,500,000 (or is it about5,000,000? Does it matter?)
A Boeing 787: about 14,000,000
Average modern high-end car: about 100,000,000
All Google’s code, in 2015: about 2,000,000,000
Sources: http://www.visualcapitalist.com/millions-lines-of-code/
http://www.itworld.com/article/2985099/application-management/
thats-one-big-repository-heres-how-many-lines-of-code-google-has.html
Problem
Software is too big and toocomplicated!
How do people cope?
Abstraction
Minecraft world built by Robin Bradfield
Abstraction
Minecraft world built by Robin Bradfield
Abstraction
Abstraction
is when you get rid of details that aren’t important right now
to focus on the things that are.
Abstraction in maths
+ =
1 shoe + 1 shoe = 2 shoes
1 + 1 = 2
Abstraction in maths
+ =
1 shoe + 1 shoe = 2 shoes
1 + 1 = 2
Abstraction in maths
+ =
1 shoe + 1 shoe = 2 shoes
1 + 1 = 2
Abstraction in software engineering
From punched cards:
to “high level code” like we saw beforevoid SAL_CALL BaseContainerControl::dispose() throw( RuntimeException,
std::exception )
{
// Tell everything that this container is now gone.
// It’s faster if you listen to both the control and the container.
// Ready for multithreading
MutexGuard aGuard( m_aMutex );
// remove listeners
EventObject aObject;
aObject.Source.set( static_cast<XControlContainer*>(this), UNO_QUERY );
m_aListeners.disposeAndClear( aObject );
// remove controls
Sequence< Reference< XControl > > seqCtrls = getControls();
Reference< XControl > * pCtrls =
seqCtrls.getArray();
sal_uInt32 nCtrls =
seqCtrls.getLength();
size_t nMaxCount =
maControlInfoList.size();
size_t nCount = 0;
for ( nCount = 0; nCount < nMaxCount; ++nCount )
{
delete maControlInfoList[ nCount ];
}
maControlInfoList.clear();
for ( nCount = 0; nCount < nCtrls; ++nCount )
{
pCtrls [ nCount ] -> removeEventListener ( static_cast<
XEventListener* >( static_cast< XWindowListener* >( this ) ) );
pCtrls [ nCount ] -> dispose ( );
}
// call baseclass
BaseControl::dispose();
}
to models, e.g. like this
By Kishorekumar 62 - Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=5766927
https://en.wikipedia.org/wiki/Unified_Modeling_Language
Model-driven development
Consistency
In the end two models have to be consistent, if they are both to beabstractions of the same software system.
What consistent means is very variable...
Now you’ll do an exercise in pairs about consistency.
Discussion
What can vary? How is it decided?
If you have a definition of consistency, and one model, canyou tell what the other model must be?
Discussion
What can vary? How is it decided?
If you have a definition of consistency, and one model, canyou tell what the other model must be?
UML class diagram
Robot
Head
smile()speak()
MovementPlanner
acquireObject()
Leg
jump()getHeightRequired()
Arm
wave()
UML sequence diagram:Robot :MovementPlanner :Leg
acquireObject()
jump()
getHeightRequired()
What if two models are not consistent?
This time your task is to make the models consistent, according tothe definition on the sheet, by changing the second model ifnecessary.
Discuss:
Is there a choice, or just one way to do it?
If there’s a choice, which way to restore consistency is best?
Why? How can we decide?
(Stretch) Can you explain how to restore this notion ofconsistency for any pair of models?
Writing bidirectional transformations
Deciding
what kind of consistency we need
how we can restore consistency automatically
is what the writer of a bidirectional transformation (bx) has to do.
We don’t yet have good languages in which to write bx – that’songoing research.
More ongoing research
What properties should bidirectional transformations have?
correctness: they actually should restore consistency!
hippocraticness: if the models are already consistent, restoringconsistency does nothing
least change: ???
More ongoing research
What properties should bidirectional transformations have?
correctness: they actually should restore consistency!
hippocraticness: if the models are already consistent, restoringconsistency does nothing
least change: ???
More ongoing research
What properties should bidirectional transformations have?
correctness: they actually should restore consistency!
hippocraticness: if the models are already consistent, restoringconsistency does nothing
least change: ???
About software engineering as a job
Today, programming is a big part of software engineering...
... but other parts are just as important, e.g., requirementsengineering.
Will change a lot in your working lives!
Work hard at your maths :-)
Questions?
Comments?