the ouroboros methodology - bguse112/wiki.files/ourb-method.pdf · guy wiener (bgu) the ouroboros...
TRANSCRIPT
The Ouroboros Methodology
Guy Wiener
Ben-Gurion University
13/6/2011
Software Engineering 2011
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 1 / 58
Software Development Methodologies Today
Agile
Develop
TestRefactor
Model-Based
Itemname
Displayscreen
System
parts
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 2 / 58
Model-Driven Development
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 3 / 58
Model-Driven Development
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 3 / 58
Model-Driven Development
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 3 / 58
Using Software Models
Testing before buildingGuidingValidatingCommunicatingVisualizingReducing complexityRaising the level of abstractionStoring knowledgeGenerating code
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 4 / 58
Model-Driven Development
ProsStores knowledgePowerful tools
ConsAdds ceremonySlows down changes
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 5 / 58
Agile Development
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 6 / 58
Agile Development
The Agile ManifestoIndividuals and interactions over processes and toolsWorking software over comprehensive documentationCustomer collaboration over contract negotiationResponding to change over following a plan
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 7 / 58
Agile Development
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 8 / 58
Agile Development
Agile practicesTime-framed iterations, often shortLow amount of ceremonyCustomer feedbackTestingRefactoring
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 9 / 58
Agile Development
ProsResponsive to changeLess administrativa
ConsLooses knowledgeNo tools support
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 10 / 58
Bridging the Gap
Lightweight modelingLink specs and codeModel queriesRound-trip workflow
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 11 / 58
The Ouroboros Workflow
Model
Query Link
Code
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 12 / 58
Outline
1 Background
2 Modeling
3 Queries and Views
4 Coding and Linking
5 Summary
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 13 / 58
Background
Outline
1 BackgroundOPMProlog
2 Modeling
3 Queries and Views
4 Coding and Linking
5 Summary
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 14 / 58
Background OPM
Outline
1 BackgroundOPMProlog
2 Modeling
3 Queries and Views
4 Coding and Linking
5 Summary
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 15 / 58
Background OPM
OPMObject-Process Methodology (Dori 2002)
FeaturesSimple: ∼ 20 basic declarationsSingle diagram typeDual representation: Textual and graphicalScaling operators
Language Elements
EntitiesObjectsProcessesStates
RelationsBuilt-inTagged
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 16 / 58
Background OPM
OPD
Object-Process DiagramsObjects are boxesProcesses are ellipses
Object states are octagonsRelations are arrows
Entities and Relations
X Yf
Tagged relation f
X Y X instance Y
X Y Y extends X
X Y X consists Y
X Y X exhibits Y
X Y X implements Y
X Y X invokes Y
X Y X yields Y
X Y Y requires X
X Y X handles Y
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 17 / 58
Background OPM
OPDExample Diagram
person
married
single
couple
man
woman
rabbi
marrying
registry
ring
1..2
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 18 / 58
Background OPM
OPL
Object-Process LanguageA textual format for OPMComposed of sentencesEach sentence is a declaration or a relation
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 19 / 58
Background OPM
OPLExample paragraph
object person states single, married.object man, woman, couple, registry, rabbi, ring.process marrying.man, woman extends person.couple consists man, woman.marrying changes person from single to married.marrying consumes ring(1,2).marrying yields couple.
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 20 / 58
Background Prolog
Outline
1 BackgroundOPMProlog
2 Modeling
3 Queries and Views
4 Coding and Linking
5 Summary
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 21 / 58
Background Prolog
Prolog
Origin1972 — Alain Colmerauer designs the logic language Prolog. Hisgoal is to create a language with the intelligence of a two year old.He proves he has reached his goal by showing a Prolog session thatsays "No." to every query.
(Taken from the brief, incomplete, and mostly wrong history ofprogramming languages by James Iry)
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 22 / 58
Background Prolog
Prolog in a Nutshell
father(john, jack).mother(jane, jack).father(john, jill).mother(jane, jill).father(jim, jules).mother(jill, jules).
parent(X, Y) :- father(X, Y).parent(X, Y) :- mother(X, Y).
sibling(X, Y) :-parent(Z, X),parent(Z, Y),X \= Y.
only_child(X) :-\+ sibling(X, _).
?- father(john, X), mother(Y, X).X = jack, Y = jane ;X = jill, Y = jane
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 23 / 58
Background Prolog
Prolog in a Nutshell
father(john, jack).mother(jane, jack).father(john, jill).mother(jane, jill).father(jim, jules).mother(jill, jules).
parent(X, Y) :- father(X, Y).parent(X, Y) :- mother(X, Y).
sibling(X, Y) :-parent(Z, X),parent(Z, Y),X \= Y.
only_child(X) :-\+ sibling(X, _).
?- father(john, X), mother(Y, X).X = jack, Y = jane ;X = jill, Y = jane
Atom
Functor
Variable
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 23 / 58
Background Prolog
Prolog in a Nutshell
father(john, jack).mother(jane, jack).father(john, jill).mother(jane, jill).father(jim, jules).mother(jill, jules).
parent(X, Y) :- father(X, Y).parent(X, Y) :- mother(X, Y).
sibling(X, Y) :-parent(Z, X),parent(Z, Y),X \= Y.
only_child(X) :-\+ sibling(X, _).
?- father(john, X), mother(Y, X).X = jack, Y = jane ;X = jill, Y = jane
Fact
Rule
HeadBody
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 23 / 58
Background Prolog
Prolog in a Nutshell
father(john, jack).mother(jane, jack).father(john, jill).mother(jane, jill).father(jim, jules).mother(jill, jules).
parent(X, Y) :- father(X, Y).parent(X, Y) :- mother(X, Y).
sibling(X, Y) :-parent(Z, X),parent(Z, Y),X \= Y.
only_child(X) :-\+ sibling(X, _).
?- father(john, X), mother(Y, X).X = jack, Y = jane ;X = jill, Y = jane
Query
Assignment
Goal
Negation
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 23 / 58
Modeling
Outline
1 Background
2 Modeling
3 Queries and Views
4 Coding and Linking
5 Summary
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 24 / 58
Modeling
Ouroboros Models
An example model
object person states single, married.object man, woman, couple, registry, rabbi, ring.process marrying.man, woman extends person.couple consists man, woman.marrying changes person from single to married.marrying consumes ring(1,2).marrying yields couple.
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 25 / 58
Modeling
Ouroboros Models
Prolog predicates for the example model
object(person).object(man).object(woman)....process(marrying).state(person::single).state(person::married).
extends(man, person).extends(woman, person).consists(couple, man).consists(couple, woman).consumes(marrying, ring).produces(marrying, couple)....
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 26 / 58
Modeling
Model Programming
Model rules
process(listener(W)) :- instance(W, window).requires(listener(W), W) :- instance(W, window).
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 27 / 58
Queries and Views
Outline
1 Background
2 Modeling
3 Queries and ViewsQueriesViews
4 Coding and Linking
5 Summary
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 28 / 58
Queries and Views Queries
Outline
1 Background
2 Modeling
3 Queries and ViewsQueriesViews
4 Coding and Linking
5 Summary
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 29 / 58
Queries and Views Queries
Queries
Objects in the system
?- object(X).X = person ;X = man ;X = woman; ...
What extends a base?
?- extends(X, person).X = man ;X = woman
Relations in the system
?- relation(R).R = consists ;R = extends ; ...
How two things arerelated?
?- relation(R),call(R, couple, man).
R = consists.
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 30 / 58
Queries and Views Queries
More Queries
Use cases
use_case(Proc) :-process(Proc),object(User),handles(User, Proc),\+ (process(Top), consists(Top, Proc)).
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 31 / 58
Queries and Views Queries
More Queries
Conversion functions
convert(Proc, From, To) :-process(Proc),consumes(Proc, From),yields(Proc, To),\+ requires(Proc, _),\+ handles(_, Proc),\+ (consumes(Proc, X), X \= From),\+ (yields(Proc, Y), Y \= To).
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 32 / 58
Queries and Views Views
Outline
1 Background
2 Modeling
3 Queries and ViewsQueriesViews
4 Coding and Linking
5 Summary
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 33 / 58
Queries and Views Views
Views
How to partition a complex system?1 Define a view predicate2 Run graphical or textual visualizations
Example view – A system diagram
sd(object(X)) :- use_case(U), handles(X, U).sd(process(U)) :- use_case(U).sd(handles(X, U)) :- handles(X, U).
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 34 / 58
Queries and Views Views
Views
Example view – A system diagram
?- sd(X).X = process(marrying) ;X = object(rabbi) ;X = handles(rabbi, marrying)
Textual
process marrying.object rabbi.rabbi handles marrying.
Graphical
rabbi marrying
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 35 / 58
Coding and Linking
Outline
1 Background
2 Modeling
3 Queries and Views
4 Coding and LinkingCode SummaryLinking Code and SpecsIntegrated Queries
5 Summary
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 36 / 58
Coding and Linking Code Summary
Outline
1 Background
2 Modeling
3 Queries and Views
4 Coding and LinkingCode SummaryLinking Code and SpecsIntegrated Queries
5 Summary
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 37 / 58
Coding and Linking Code Summary
From Source Code To Facts
What is needed?Syntactic parsingRepresent parsed code in knowledge base
Existing logic parsersErlang The parsed code is part of the debug infoJava JTransformer (over Eclipse), JTL
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 38 / 58
Coding and Linking Code Summary
Importing Parsed Code
An Erlang Program — Records
-module(login_srv).-record(user,{username, password, name}).-record(login_ok,{username, time}).-record(login_fail,{username, password, time}).
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 39 / 58
Coding and Linking Code Summary
Importing Parsed Code
An Erlang Program — Functions
start() ->% Server init code...
login(Username, Password) ->Users = get(users),Log = get(log), ...
last_attempt(Username) ->Log = get(log), ...
failed_attempts(Username) ->Log = get(log), ...
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 40 / 58
Coding and Linking Code Summary
Importing Parsed Code
Parsed Code — Records
erl_file(’login_srv.erl’,[attribute(1, file, ’login_srv.erl’(1)),attribute(1, module, login_srv),attribute(2, export, [...]),attribute(4, record,user([record_field(4, atom(4, username)),
record_field(4, atom(4, password)),record_field(4, atom(4, name))])),
...
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 41 / 58
Coding and Linking Code Summary
Importing Parsed Code
Parsed Code — Functions
function(12, login, 2,[clause(12,
[var(13, ’Username’), var(13, ’Password’)], [],[match(15, var(14, ’Users’),
call(14, atom(14, get),[atom(14, users)])),
match(15, var(15, ’Log’),call(15, atom(15, get),
[atom(15, log)])),...]
)])...]).
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 42 / 58
Coding and Linking Code Summary
Code Summary
Code
create_disk_log(Filename,MaxBytes, MaxFiles,ConfigList) ->Format = proplists:get_value(disk_log_fmt,ConfigList, external),open(Filename, MaxBytes,MaxFiles, Format).
Summary
create_disk_log
get_value open
proplists
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 43 / 58
Coding and Linking Code Summary
Code Summary
Code
create_disk_log(Filename,MaxBytes, MaxFiles,ConfigList) ->Format = proplists:get_value(disk_log_fmt,ConfigList, external),open(Filename, MaxBytes,MaxFiles, Format).
Summary
create_disk_log
get_value open
proplists
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 43 / 58
Coding and Linking Code Summary
Code Summary
Rules
object(erl:Record) :- erl_record(Record).object(erl:Field) :- erl_record_field(_, Field).exhibits(erl:Record, erl:Field) :-erl_record_field(Record, Field).
object(erl:Module) :- erl_module(Module).process(erl:Name) :-erl_func(_, _, _, Name).
exhibits(erl:Module, erl:Name) :-erl_func(Module, _, _, Name).
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 44 / 58
Coding and Linking Code Summary
Code Summary
erl:log
erl:login_srv
erl:users
erl:login_srv:failed_attempts
erl:login_srv:last_attempt
erl:login_srv:loginerl:login_srv:start
erl:login_fail
erl:password erl:timeerl:username
erl:login_ok
erl:name
erl:user
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 45 / 58
Coding and Linking Linking Code and Specs
Outline
1 Background
2 Modeling
3 Queries and Views
4 Coding and LinkingCode SummaryLinking Code and SpecsIntegrated Queries
5 Summary
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 46 / 58
Coding and Linking Linking Code and Specs
Synchronizing the Model and Code
The implements relationimplements(Imp, Spec) The entity Imp implements Spec.
Detecting where the model and the code arenot synchronized\+implements(_, Thing) Thing has no implementation.\+implements(Thing, _) Thing has no specification.
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 47 / 58
Coding and Linking Linking Code and Specs
Synchronizing the Model and Code
The implements relationimplements(Imp, Spec) The entity Imp implements Spec.
Detecting where the model and the code arenot synchronized\+implements(_, Thing) Thing has no implementation.\+implements(Thing, _) Thing has no specification.
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 47 / 58
Coding and Linking Linking Code and Specs
Linking Specs and Code SummaryThe specifications
log_entry
login_fail
login_ok
time
username password
login_srv
log
0..n
userusers
0..n
failed_attempts
last_attempt
login
start
name
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 48 / 58
Coding and Linking Linking Code and Specs
Linking Specs and Code SummarySpecification and Implementation
The implements relation
erl:login_ok implements login_ok.erl:time implements time.
implements(erl:X, Y) :- ...
Specs and SummarySummary reflects codestructureSpecs use modelingabstractions
log_entrytimeusername
login_fail
password
login_ok
erl:login_fail
erl:password
erl:timeerl:username
erl:login_ok
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 49 / 58
Coding and Linking Integrated Queries
Outline
1 Background
2 Modeling
3 Queries and Views
4 Coding and LinkingCode SummaryLinking Code and SpecsIntegrated Queries
5 Summary
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 50 / 58
Coding and Linking Integrated Queries
Compatibility
Persistency check
no_persistency :-object(X),\+ (process(P),
consist(P, X)),\+ implements(sql:_, X).
Compatibility queriesValidate policyFind irregulars
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 51 / 58
Coding and Linking Integrated Queries
Impact Analysis
Connected
connected(X, Y, R) :-relation(R),call(R, X, Y).
Also has a recursive version
Context queriesTraceabilityImpactProximity
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 52 / 58
Coding and Linking Integrated Queries
Incremental Changes
Missing implementation Update code and re-linkMissing specification Update specs and re-linkFailed policy check Fix matched codePlanned changes Consult impact analysis
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 53 / 58
Summary
Outline
1 Background
2 Modeling
3 Queries and Views
4 Coding and Linking
5 Summary
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 54 / 58
Summary
Software Modeling in an Agile Environment
Modeling with minimaladded ceremonyQueries provide immediatebenefitPreserves domainknowledgeIdentifies and supportsincremental changes
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 55 / 58
Summary
Not Discussed Here
Model programming (in depth)Code generation
Compatibility rules + Existing code factbase =Generate missing code
Model extractionPatterns, platforms and their properties
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 56 / 58
Summary
Links and References
OPM “Object-Process Methodology: A Holistic SystemPardigm”, Dov Dori, 2002
Erlang http://www.erlang.org/
JTransformer http://sewiki.iai.uni-bonn.de/research/jtransformer/
Ouroboros http://www.cs.bgu.ac.il/~gwiener/software/opmpl/
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 57 / 58
Summary
Thank you!
Questions?
Guy Wiener (BGU) The Ouroboros Methodology 13/6/2011 58 / 58