Things your mother didn't tell you about architecture and GUIs Part II

advertisement
Things your mother
didn't tell you about
architecture and GUIs
Part II
ROOTS 2007
Trygve Reenskaug
Department of Informatics
University of Oslo
PowerPoint and Java code at
folk.uio.no/trygver/2007/roots07.zip
What it is All About
Doug Engelbart:
computer augmentation
mental
model
?
?
data
?
use
cases
2007.04.26-ROOTS-Architecture #2
?
Computer
operations
© Trygve Reenskaug 2007
2016.05.29
Slide 3
Scripting vs.
Direct Manipulation
1)
2)
3)
4)
5)
6)
Out of main door
Turn right
5th left
Right at 4th light
½ left at 1st light
You’re there
S
F
2007.04.26-ROOTS-Architecture #2
© Trygve Reenskaug 2007
2016.05.29
Slide 4
User’s Mental Model
Activity Planning Network
actA
actC
Define
Use
Cases
2 weeks
Code
Algorithms
3 weeks
actD
System
Integration
actB
Define & Code
Domain
Class attributes
2 weeks
7 weeks
2007.04.26-ROOTS-Architecture #2
© Trygve Reenskaug 2007
2016.05.29
Slide 5
User – Machine Interaction
user
mental
model
data
Domain
Data
GUI
User
GUI bridges
gap between
brain and data
2007.04.26-ROOTS-Architecture #2
© Trygve Reenskaug 2007
2016.05.29
Slide 6
Model – View - Controller
user
mental
model
Controller
1
1
1
User
View
*
data
*
1
Model
View
work with
User
Model
seen through View
Controller creates and coordinates
Run Demo
multiple Views
2007.04.26-ROOTS-Architecture #2
© Trygve Reenskaug 2007
2016.05.29
Slide 7
Use Case example
A Functional Requirement
Use Case # N: frontloading function
• An activity is characterized by its
duration, earlyStart time, earlyFinish time,
its predecessors and successors activities.
• By default, earlyFinish = earlyStart + duration
special activities may have more complex algorithms
• An activity can start when all its predecessors are finished:
earlyStart = MAX (earlyFinish all predecessors)
Run Demo
2007.04.26-ROOTS-Architecture #2
© Trygve Reenskaug 2007
2016.05.29
Slide 8
frontloading – 1
UML Diagrams
COLLABORATION
frontpreds [*]
frontloader [1]
Critical Questions:
1. What are the roles?
2. How are they interconnected?
3.
3. How do they interact?
INTERACTION
frontloader [1] frontpreds [*]
frontload()
earlyFinish()
2007.04.26-ROOTS-Architecture #2
© Trygve Reenskaug 2007
2016.05.29
Slide 9
The Essence of Object Orientation:
Objects interact to achieve a given goal
Critical questions:
1. What are the relevant objects?
• The relevant objects are seen as a structure of
Roles.
• A role names the usage of one or more objects.
• The name is seen as an alias for those objects.
2. How are they connected?
• A Collaboration describes the structure of roles.
3. How do they interact?
• An Algorithm specifies the interaction in terms of
the roles.
2007.04.26-ROOTS-Architecture #2
© Trygve Reenskaug 2007
2016.05.29
Slide 10
Class and Role – 1
Steven Pinker: How The Mind Works
Classification:
Group on common features (inst.vars. & methods)
Role (Artifact) : Group on common purpose
• People categorize objects in terms of the roles they play
within intuitive theories about how the world operates.
• Roles are defined by what they can do and by
what someone, somewhere, makes them to do at some time.
2007.04.26-ROOTS-Architecture #2
© Trygve Reenskaug 2007
2016.05.29
Slide 11
Class and Role – 2
The Trumpeter
Händel: Messiah, Hallelujah choir
Note: PowerPoint sound doesn’t work over the internet?!
One Role - Two Classes
2007.04.26-ROOTS-Architecture #2
© Trygve Reenskaug 2007
2016.05.29
Slide 12
Role Playing in the Theatre
Henrik Ibsen: Peer Gynt
The Royal Hall of the
King of the Dovre-Trolls.
THE OLD MAN OF THE DOVRE
sits on the throne, crowned, and with
his sceptre in his hand.
His CHILDREN and NEAREST
RELATIONS are ranged on both
sides.
PEER GYNT stands before him.
Violent commotion in the hall.
---------------(THE GREEN-CLAD ONE)
http://norsk.kameraklubb.net/coppermine/displayimage/album=167/pos=6.html
2007.04.26-ROOTS-Architecture #2
© Trygve Reenskaug 2007
2016.05.29
Slide 13
frontloading – 1
UML Diagrams
COLLABORATION
frontpreds [*]
frontloader [1]
Critical Questions:
1. What are the roles?
2. How are they interconnected?
3.
3. How do they interact?
INTERACTION
frontloader [1] frontpreds [*]
frontload()
earlyFinish()
2007.04.26-ROOTS-Architecture #2
© Trygve Reenskaug 2007
2016.05.29
Slide 14
frontloading-2
Algorithm
frontload (Integer startWeek) {
FrontIntf frontloader = ??;
Set<FrontpredIntf> frontpreds = ??;
Integer earlyStart = startWeek;
for (FrontpredIntf pred : frontpreds) {
earlyStart = Math.max(earlyStart, pred.earlyFinish() + 1);
}
frontloader.setEarlyStart(earlyStart);
}
public void
2007.04.26-ROOTS-Architecture #2
© Trygve Reenskaug 2007
2016.05.29
Slide 15
What it still is All About
mental
model
use
cases
2007.04.26-ROOTS-Architecture #2
data
Model
GUI
operations
© Trygve Reenskaug 2007
2016.05.29
Slide 17
Data Model
Conceptual Schema
actA
actC
actD
Model
actB
activities
dependencies
*
*
Activity
name
earlyStart
earlyFinish
duration
color
2007.04.26-ROOTS-Architecture #2
Dependency
predecessor
successor
© Trygve Reenskaug 2007
2016.05.29
Slide 18
Data Model
Java Domain Classes
class Model {
public Set<Activity> activities = new HashSet<Activity>();
public Set<Dependency> dependencies =
public
new HashSet<Dependency>();
…}
public class
Activity implements FrontpredIntf, FrontIntf {
private Integer earlyStart, earlyFinish, duration;
private String name; …}
class Dependency {
private Activity predecessor, successor;
public
…}
2007.04.26-ROOTS-Architecture #2
© Trygve Reenskaug 2007
2016.05.29
Slide 19
Roles and Objects
Bridging the gap with queries
Interaction Algorithm
frontloader [1]
frontpreds [*]
Data Objects
mental
earlyFinish()
model
frontload()
actA
actC
data
actD
Collaboration
use
cases
frontloader [1]
actB
GUI
frontpreds [*]
Query
Model
operations
define frontloader as
select act
define frontpreds as
from activities act
select dep.predecessor
where act.earlyStart == nil and (
from dependencies dep
for all pred in predecessors(act):
where dep.successor = frontloader
pred.earlyStart != nil
) someInstance
2007.04.26-ROOTS-Architecture #2
© Trygve Reenskaug 2007
2016.05.29
Slide 20
frontloading-3
Algorithm
public void frontload
(Integer startWeek) {
FrontIntf
frontloader
= ??; = new FrontCollab();
FrontCollab
frontCollab
FrontIntf frontloader
= frontCollab.frontloader;
Set<FrontpredIntf>
frontpreds
= ??;
Set<FrontpredIntf> frontpreds = frontCollab.frontpreds;
earlyStart = startWeek;
for (FrontpredIntf pred : frontpreds) {
earlyStart = Math.max(earlyStart, pred.earlyFinish() + 1);
}
frontloader.setEarlyStart(earlyStart);
}
Integer
2007.04.26-ROOTS-Architecture #2
© Trygve Reenskaug 2007
2016.05.29
Slide 21
FrontCollab
External Data View
FrontCollab {
public FrontIntf frontloader;
public FrontpredIntf frontpreds;
public FrontCollab () {
frontloader = selectFrontloader();
frontpreds = predecessorsOf(frontloader);
public class
}
}
2007.04.26-ROOTS-Architecture #2
© Trygve Reenskaug 2007
2016.05.29
Slide 22
Select domain object to
frontloader role by Java Query
private FrontIntf selectFrontloader() {
for (Activity
act : model.allActivities()) {
if (act.earlyStart() == null) {
Set<FrontpredIntf> predSet = predecessorsOf(act);
if (areAllDone(predSet)) {
frontloader = act;
return (frontloader);
}
}
}
return
null;
2007.04.26-ROOTS-Architecture #2
© Trygve Reenskaug 2007
2016.05.29
Slide 23
Select domain objects to
frontpreds role by Java Query
public FrontpredIntf predecessorsOf(FrontIntf
act) {
Set<FrontpredIntf> preds = new HashSet<FrontpredIntf>();
for (Dependency assoc : model.dependencies() ) {
if (assoc.successor() == act) {
preds.add(assoc.predecessor());
}
}
return preds;
}
2007.04.26-ROOTS-Architecture #2
© Trygve Reenskaug 2007
2016.05.29
Slide 24
Conclusion – 1 of 2: User Needs
Balance Thinking and Doing
User needs are in two dimensions;
they should be supported in harmony:
thinking:
→mental model → data model → objects
doing:
→ use case → collaboration → role → query → objects
2007.04.26-ROOTS-Architecture #2
© Trygve Reenskaug 2007
2016.05.29
Slide 25
Conclusion – 2 of 2: Architecture
Balance State and Behavior
Mental Model
Use Cases
Algorithm
Conceptual
schema
role interaction
realize
reference roles
Collaboration
Class
attributes
roles and links
instantiate
select objects
behavior
2007.04.26-ROOTS-Architecture #2
Data Objects
© Trygve Reenskaug 2007
state
2016.05.29
Slide 26
That’s all, thank you
Questions?
PowerPoint and Java code at
folk.uio.no/trygver/2007/roots07.zip
2007.04.26-ROOTS-Architecture #2
© Trygve Reenskaug 2007
2016.05.29
Slide 27
More reading
http://www.ifi.uio.no/~trygver
mailto: trygver ‘at’ ifi.uio.no
dca-demo example code:
http://heim.ifi.uio.no/~trygver/2006/09-JavaZone/BabyProject-2/
Reenskaug, T.: Original MVC notes from Xerox PARC
http://folk.uio.no/trygver/2007/MVC_Originals.pdf
Reenskaug, T,: The BabyUML discipline of programming
(where A Program = Data + Communication + Algorithms).
SoSym 5,1 (April 2006). DOI: 10.1007/s10270-006-0008-x.
http://heim.ifi.uio.no/~trygver/2006/SoSyM/trygveDiscipline.pdf
Reenskaug, T.: Programming with Roles and Classes; the BabyUML Approach
To be published by Nova publishers as a chapter in a book on Computer Software Engineering Research
[WEB PAGE] http://folk.uio.no/trygver/2007/babyUML.pdf (.PDF))
Unified Modeling Language: Superstructure. Version 2.1.
Object Management Group (OMG) document ptc/06-04-02. http://www.omg.org
Arisholm, E.; Sjøberg, D.: A Controlled Experiment with Professionals to Evaluate the Effect of a Delegated versus
Centralized Control …,
Simula Research Laboratory Technical Report 2003-6
http://www.simula.no/publication_one.php?publication_id=601
Reenskaug, T; Wold, P.;, Lehne, O. A.: Working With Objects.
This book is out of print. An early .pdf version kan be downloaded free from
http://folk.uio.no/trygver/1996/book/book11d.pdf
Wirfs-Brock, R.; McKean, A.; Object Design. Roles, Responsibilities, and Collaborations.
ISBN 0-201-37943-0; Addison-Wesley; Boston, MA, 2003.
Andersen, E. P.; Conceptual Modeling of Objects. A Role Modeling Approach.
D.Scient thesis, November 1997, University of Oslo.
[web page] http://heim.ifi.uio.no/~trygver/1997/ EgilAndersen/ConceptualModelingOO.pdf
Pinker, S.; How the Mind Works; ISBN 0-393-04535-8; Norton; New York, NY, 1997.
2007.04.26-ROOTS-Architecture #2
© Trygve Reenskaug 2007
2016.05.29
Slide 28
Download