Software Design and Development - PowerPoint PPT Presentation

Loading...

PPT – Software Design and Development PowerPoint presentation | free to download - id: 1ba8b0-ZDc1Z



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

Software Design and Development

Description:

Textual representation of class graphs ... Class graphs in textual form (construction, alternation) object graphs (graphical and textual form) object graphs ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 96
Provided by: karllie
Learn more at: http://www.ccs.neu.edu
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: Software Design and Development


1
Software Design and Development
  • COM 1205

2
Adaptive Object-Oriented Software Development
  • COM 3360
  • and NTU class

www.ccs.neu.edu/research/demeter/course/f00/f00.ht
ml
3
Introduction
  • Software engineering, modeling, design, software
    architecture
  • Programming languages
  • Hands-on, practical, useful

4
Summary of Course
  • How to design and implement flexible
    object-oriented software using the principles of
    adaptiveness in combination with UML and Java.
    Learning principles behind XML.
  • How to design and implement flexible 100 pure
    Java software.

5
Who is in Attendance?
  • Software developers who have some experience with
    object-oriented programming.
  • Should know concepts of OOP, like classes,
    methods, and late binding.

6
Agenda
Adaptive Programming Aspect-Oriented Progr.
DemeterJ Java and DJ Java environment UML XML
strategy graphs class graphs object graphs state
graphs
principles heuristics patterns idioms theorems alg
orithms
requirements domain analysis design implementation
use cases interfaces traversals visitors packages
Demeter Method iterative development spiral
model Extreme Programming
7
Agenda
  • UML class diagrams. Perspective analysis,
    design, implementation
  • Class graphs as special cases of UML class
    diagrams
  • Textual representation of class graphs
  • Default implementation of UML class diagrams as
    class graphs

8
Agenda
  • UML interaction diagrams
  • sequence diagrams
  • collaboration diagrams
  • improving interaction diagrams to make them
    specification languages
  • XML data type definitions and documents

9
Agenda
  • Class graphs in textual form (construction,
    alternation)
  • object graphs (graphical and textual form)
  • object graphs defined by class graphs
  • add repetition classes and optional parts
  • translating class graphs to Java

10
Agenda
  • annotating class graph with syntax class
    dictionary
  • printing objects and language defined by class
    dictionary
  • grammars, parsing, ambiguous grammars,
    undecidable problem
  • LL(1) grammars, robustness of sentences
  • etc.

11
Overview
  • good separation of concerns is the goal
  • concerns should be cleanly localized
  • programs should look like designs

12
Adaptive Programming
  • Programs adapt to interesting context changes
  • Structure-shy behavior
  • Succinct representation of traversals
  • Programming in terms of graph constraints

13
Cross-cutting of components and aspects
better program
ordinary program
structure-shy functionality
Components
structure
Aspect 1
synchronization
Aspect 2
14
Aspect-Oriented Programming
components and aspect descriptions
High-level view, implementation may be different
Source Code (tangled code)
weaver (compile- time)
15
Examples of Aspects
  • Synchronization of methods across classes
  • Remote invocation (using Java RMI)
  • Quality of Service (QoS)
  • Failure handling
  • External use (e.g., being a Java bean)
  • Replication, Migration
  • etc.

16
Connections
  • explain adaptive programming in terms of
    patterns
  • Aspect-Oriented Programming (AOP) is a
    generalization of Adaptive Programming (AP)
  • correspondence
  • adaptive program object-oriented program
    sentence object graph

17
Vocabulary
  • Graph, nodes, edges, labels
  • Class graph, construction, alternation
  • Object graph, satisfying class graph
  • UML class diagram
  • Grammar, printing, parsing

18
Vocabulary
  • Traversals, visitors
  • Strategy graphs, path set

19
Overview this lecture
  • Basic UML class diagrams
  • Traversals/Collaborating classes
  • Traversal strategy graphs
  • Adaptive programming
  • Tools for adaptive programming
  • DemeterJ and AP/Studio

20
1 Basic UML class diagrams
  • Graph with nodes and directed edges and labels
    for nodes and edges
  • Nodes classes, edges relationships
  • labels class kind, edge kind, cardinality

21
UML Class Diagram
busStops
BusRoute
BusStopList
buses
0..
BusStop
BusList
waiting
0..
passengers
Bus
PersonList
Person
0..
22
2 Traversals / Collaborating classes
  • To process objects we need to traverse them
  • Traversal can be specified by a group of
    collaborating classes

23
Collaborating Classes
use connectivity in class graph to define them
succinctly using strategy graphs
from Customer to Agent
from Company to Employee
24
What's the problem? TANGLING
OOAD
Collab-1
C1
C4
C2
C3
C5
Collab-4
Collab-2
Collab-3
C1
C4
C2
C3
Implementation
C5
25
Collaborating Classes
find all persons waiting at any bus stop on a bus
route
busStops
BusRoute
BusStopList
OO solution one method for each red class
buses
0..
BusStop
BusList
waiting
0..
passengers
Bus
PersonList
Person
0..
26
3 Traversal Strategy Graphs
  • Want to define traversals succinctly
  • Use strategy graphs to express abstraction of
    class diagram
  • Express traversal intent useful for
    documentation of object-oriented programs

27
Traversal Strategy
find all persons waiting at any bus stop on a bus
route
first try from BusRoute to Person
busStops
BusRoute
BusStopList
buses
0..
BusStop
BusList
waiting
0..
passengers
Bus
PersonList
Person
0..
28
Traversal Strategy
find all persons waiting at any bus stop on a bus
route
from BusRoute through BusStop to Person
busStops
BusRoute
BusStopList
buses
0..
BusStop
BusList
waiting
0..
passengers
Bus
PersonList
Person
0..
29
Traversal Strategy
find all persons waiting at any bus stop on a bus
route
Altern. from BusRoute bypassing Bus to Person
busStops
BusRoute
BusStopList
buses
0..
BusStop
BusList
waiting
0..
passengers
Bus
PersonList
Person
0..
30
Robustness of Strategy
find all persons waiting at any bus stop on a bus
route
from BusRoute through BusStop to Person
villages
BusRoute
BusStopList
busses
VillageList
busStops
0..
0..
BusStop
BusList
Village
waiting
0..
passengers
Bus
PersonList
Person
0..
31
Filter out noise in class diagram
  • only three out of seven classes
  • are mentioned in traversal
  • strategy!

from BusRoute through BusStop to Person
replaces traversal methods for the classes
BusRoute VillageList Village BusStopList
BusStop PersonList Person
32
Why Traversal Strategies?
  • Law of Demeter a method should talk only to its
  • friends
  • arguments and part objects (computed or
    stored)
  • and newly created objects
  • Dilemma
  • Small method problem of OO (if followed) or
  • Unmaintainable code (if not followed)
  • Traversal strategies are the solution to this
    dilemma

33
4 Adaptive Programming
  • How can we use strategies to program?
  • Need to do useful work besides traversing
    visitors
  • Incremental behavior composition using visitors

34
Writing Adaptive Programs with Strategies
(DJpure Java)
String WPStrategyfrom BusRoute through BusStop
to Person
class BusRoute int countPersons(TraversalGraph
WP) Integer result (Integer)
WP.traverse(this, new Visitor() int r
public void before(Person host) r
public void start() r 0 public
Object getReturnValue() return new
Integer ( r) ) return
result.intValue()
35
Writing Adaptive Programs with Strategies
(DJpure Java)
String WPStrategyfrom BusRoute through BusStop
to Person
// Prepare the traversal for the current class
graph ClassGraph classGraph new
ClassGraph() TraversalGraph WPTraversal new
TraversalGraph (WPStrategy, classGraph) int
r aBusRoute.countPersons(WPTraversal)
36
Writing Adaptive Programs with Strategies
(DJpure Java)
class Utility static int
countPersons(ObjectGraphSlice countSlice)
Integer result (Integer)
countSlice.traverse(new Visitor() int r
public void before(Person host) r
public void start() r 0 public
Object getReturnValue() return new
Integer ( r) ) return
result.intValue()
37
Writing Adaptive Programs with Strategies
(DJpure Java)
String WPStrategyfrom BusRoute through BusStop
to Person
// Prepare the slice for the current class
graph ClassGraph classGraph new
ClassGraph() ObjectGraph objectGraph new
ObjectGraph(aBusRoute) ObjectGraphSlice
whatToCount new ObjectGraphSlice(objectGraph,
WPStrategy) int r Utility.countPersons(whatT
oCount)
38
Writing Adaptive Programs with Strategies
(DemeterJ)
strategy from BusRoute through BusStop to Person
BusRoute traversal waitingPersons(PersonVis
itor) through BusStop to Person //
from is implicit int printCountWaitingPersons(
) // traversal/visitor weaving
waitingPersons(PrintPersonVisitor) PrintPersonVis
itor before Person
PersonVisitor init r 0
Extension of Java keywords traversal
init through bypassing to before after etc.
39
Taxi driver analogy
  • Streets and intersections correspond to class
    graph
  • Traversal strategy determines how the taxi will
    navigate through the streets
  • You can take pictures before and after
    intersections
  • You can veto sub traversals

40
Programming in Large Families
Two adaptive programs
A1
Class Graphs
A2
A1 family
Object-Oriented Programs
A2 family
41
Adaptive Programming
Strategy
Bold names refer to DJ classes.
is use-case based abstraction of
ClassGraph
defines family of
ObjectGraph
42
Adaptive Programming
Strategy
defines traversals of
ObjectGraph
43
Adaptive Programming
Strategy
guides and informs
Visitor
44
Strategies
BusRoute BusStop Person
  • Nodes positive information Mark corner stones
    in class graph Overall topology
  • of collaborating classes. 3 nodes
  • from BusRoute
  • through BusStop
  • to Person

45
Strategies
bypassing edges incident with Bus
BusRoute
Person
Edges negative information Delete edges from
class graph.
from BusRoute bypassing Bus to Person
46
5 Tools for Adaptive Programming
  • free and commercial tools available

47
Free Tools on WWW
  • DJ and AP Library
  • Demeter/C
  • DemeterJ
  • Demeter/StKlos
  • Dem/Perl5
  • Dem/C
  • Dem/CLOS
  • Demeter/Object Pascal

last four developed outside our group
48
Commercial Tools available on WWW
StructureBuilder from Tendril Software Inc.
(bought by WebGain) has support for DJ style
actions
www.webgain.com
49
Benefits of Adaptive Programming
  • robustness to changes
  • shorter programs
  • design matches program
  • more understandable code
  • partially automated evolution
  • keep all benefits of OO technology
  • improved productivity

Applicable to design and documentation of your
current systems.
50
DemeterJ
www.ccs.neu.edu/research/demeter
  • class diagrams
  • functionality
  • strategies
  • visitors
  • etc.

Executable Java code for your favorite commercial
Java Software Development Environment
weaver
51
DemeterJ in DemeterJ
structure (.cd) class diagrams
focus of this lecture
compiler/ weaver
structure-shy behavior (.beh) strategies
and visitors
structure-shy communication (.ridl) distribution
structure-shy object description (.input, at
runtime)
synchronization (.cool) multi threading
52
Cross-cutting in DemeterJ
generated Java program
DemeterJ program
structure-shy functionality
structure
replicated!
synchronization
53
AP Studio
  • visual development of traversal strategies
    relative
  • to class diagram
  • visual feedback about collaborating classes
  • visual development of annotated UML class diagrams

54
Strengths of DemeterJ
  • Theory
  • Novel algorithms for strategies
  • Formal semantics
  • correctness theorems
  • Practice
  • Extensive feedback (8 years)
  • Reflective implementation

55
Meeting the Needs
  • DemeterJ
  • Easier evolution of class diagrams (with strategy
    diagrams)
  • Easier evolution of behavior (with visitors)
  • Easier evolution of objects (with sentences)

56
Real Life
  • Used in several commercial projects
  • Implemented by several independent developers
  • Used in several courses, both academic and
    commercial

57
Summary
  • What has been learned Simple UML class diagrams,
    strategies and adaptive programs
  • How can you apply
  • DemeterJ takes adaptive programs as input
  • Document object-oriented programs with strategies
  • Design in terms of traversals and visitors

58
Where to get more information
  • Adaptive Programming book
  • DJ home page
  • UML Distilled
  • DemeterJ home page
  • Course home page
  • www.ccs.neu.edu/research/demeter/

59
Feedback
  • Request feedback of training session

60
A Short Introduction to Adaptive Programming for
Java Programmers
  • Karl Lieberherr
  • Doug Orleans

61
Concepts needed (DJ classes)
  • ClassGraph
  • Strategy
  • TraversalGraph
  • ObjectGraph
  • ObjectGraphSlice
  • Visitor

62
Adaptive Programming
Strategy
Bold names refer to DJ classes.
is use-case based abstraction of
ClassGraph
defines family of
ObjectGraph
63
Adaptive Programming
Strategy
defines traversals of
ObjectGraph
results in
ObjectGraphSlice
64
Adaptive Programming
Strategy
guides and informs
Visitor
65
Collaborating Classes
find all persons waiting at any bus stop on a bus
route
busStops
BusRoute
BusStopList
OO solution one method for each red class
buses
0..
BusStop
BusList
waiting
0..
passengers
Bus
PersonList
Person
0..
66
Traversal Strategy
find all persons waiting at any bus stop on a bus
route
from BusRoute through BusStop to Person
busStops
BusRoute
BusStopList
buses
0..
BusStop
BusList
waiting
0..
passengers
Bus
PersonList
Person
0..
67
Traversal Strategy
find all persons waiting at any bus stop on a bus
route
from BusRoute through BusStop to Person
busStops
BusRoute
BusStopList
buses
0..
BusStop
BusList
waiting
0..
passengers
Bus
PersonList
Person
0..
68
Robustness of Strategy
find all persons waiting at any bus stop on a bus
route
from BusRoute through BusStop to Person
villages
BusRoute
BusStopList
buses
VillageList
busStops
0..
0..
BusStop
BusList
Village
waiting
0..
passengers
Bus
PersonList
Person
0..
69
Writing Adaptive Programs with Strategies
(DJpure Java)
String WPStrategyfrom BusRoute through BusStop
to Person
class BusRoute int countPersons(TraversalGraph
WP) Integer result (Integer)
WP.traverse(this, new Visitor() int r
public void before(Person host) r
public void start() r 0 public
Object getReturnValue() return new
Integer ( r) ) return
result.intValue()
70
Writing Adaptive Programs with Strategies
(DJpure Java)
String WPStrategyfrom BusRoute through BusStop
to Person
// Prepare the traversal for the current class
graph ClassGraph classGraph new
ClassGraph() TraversalGraph WPTraversal new
TraversalGraph (WPStrategy, classGraph) int
r aBusRoute.countPersons(WPTraversal)
71
Writing Adaptive Programs with Strategies
(DJpure Java)
String WPStrategyfrom BusRoute through BusStop
to Person
class BusRoute int countPersons(TraversalGraph
WP) Integer result (Integer)
WP.traverse(this, new Visitor()...)
return result.intValue()
ObjectGraph objectGraph new
ObjectGraph(this, classGraph) ObjectGraphSlice
objectGraphSlice new ObjectGraphSlice(objectG
raph, WP) objectGraphSlice.traverse(visitor)
WP.traverse(this,visitor) ltgt
72
ObjectGraph
BusRoute ( ltbusStopsgt BusStopList
BusStop( ltwaitinggt PersonList
Person() Person()) ltbusesgt BusList
Bus( ltpassengersgt PersonList
Person() Person()))
73
TraversalGraph
find all persons waiting at any bus stop on a bus
route
from BusRoute through BusStop to Person
busStops
BusRoute
BusStopList
buses
0..
BusStop
BusList
waiting
0..
passengers
Bus
PersonList
Person
0..
74
ObjectGraphSlice
BusRoute ( ltbusStopsgt BusStopList
BusStop( ltwaitinggt PersonList
Person() Person()) ltbusesgt BusList
Bus( ltpassengersgt PersonList
Person() Person()))
75
Example Short-cut
strategy A -gt B B -gt C
class graph
strategy
A
B
C
A
A
x
traversal graph ???
c
0..1
b
x
c
B
X
0..1
x
b
c
B
X
x
c
C
C
76
Short-cut
strategy A -gt B B -gt C
Object graph
Traversal graph
A( ltxgt X( ltbgt B( ltxgt X( ltcgt
C())) ltcgt C()) ltcgt C())
A
start set
x
0..1
b
b
X
X
B
x
x
c
b
B
finish set
C
77
Short-cut
  • ObjectGraphSlice
  • static view
  • ObjectGraph, TraversalGraph, start nodes, finish
    nodes
  • dynamic view
  • when traverse method gets called
  • traversal history node sequence of nodes in
    object graph
  • subgraph of object graph (but only part of the
    story)
  • visualize it by a movie of traverse

78
Short-cut
strategy A -gt B B -gt C
Object graph
Traversal graph
A( ltxgt X( ltbgt B( ltxgt X( ltcgt
C())) ltcgt C()) ltcgt C())
A
start set
x
0..1
b
b
X
X
B
x
x
c
b
B
finish set
C
Used for token set and currently active object
79
Short-cut
strategy A -gt B B -gt C
Object graph
Traversal graph
A( ltxgt X( ltbgt B( ltxgt X( ltcgt
C())) ltcgt C()) ltcgt C())
A
start set
x
0..1
b
b
X
X
B
x
x
c
b
B
finish set
C
Used for token set and currently active object
80
Short-cut
strategy A -gt B B -gt C
Object graph
Traversal graph
A( ltxgt X( ltbgt B( ltxgt X( ltcgt
C())) ltcgt C()) ltcgt C())
A
start set
x
0..1
b
b
X
X
B
x
x
c
b
B
finish set
C
Used for token set and currently active object
81
Short-cut
strategy A -gt B B -gt C
Object graph
Traversal graph
A( ltxgt X( ltbgt B( ltxgt X( ltcgt
C())) ltcgt C()) ltcgt C())
A
start set
x
0..1
b
b
X
X
B
x
x
c
b
B
finish set
C
Used for token set and currently active object
82
Short-cut
strategy A -gt B B -gt C
Object graph
Traversal graph
A( ltxgt X( ltbgt B( ltxgt X( ltcgt
C())) ltcgt C()) ltcgt C())
A
start set
x
0..1
b
b
X
X
B
x
x
c
b
B
finish set
C
Used for token set and currently active object
83
Short-cut
strategy A -gt B B -gt C
Object graph
Traversal graph
A( ltxgt X( ltbgt B( ltxgt X( ltcgt
C())) ltcgt C()) ltcgt C())
A
start set
x
0..1
b
b
X
X
B
x
x
c
b
B
finish set
C
Used for token set and currently active object
After going back to X
84
ObjectGraphSlice
strategy A -gt B B -gt C
A( ltxgt X( ltbgt B( ltxgt X( ltcgt
C())) ltcgt C()) ltcgt C())
85
Strategy definition embedded, positive strategies
  • Given a graph G, a strategy graph S of G is any
    connected subgraph of the transitive closure of
    G.
  • The transitive closure of G(V,E) is the graph
    G(V,E), where E(v,w) there is a path from
    vertex v to vertex w in G.

86
S is a strategy for G
Ft
F
D
D
E
E
B
B
C
C
S
G
A s
A
87
Key concepts
Strategy graph and base graph are directed graphs
  • Strategy graph S with source s and target t of a
    base graph G. Nodes(S) subset Nodes(G) (Embedded
    strategy graph).
  • A path p is an expansion of path p if p can be
    obtained by deleting some elements from p.
  • S defines path set in G as follows
    PathSetst(G,S) is the set of all s-t paths in G
    that are expansions of any s-t path in S.

88
Combining DJ and DemeterJ
  • DJ is a 100 Java solution for adaptive
    programming.
  • DemeterJ has
  • XML style data binding facilities code
    generation from schema (class dictionary).
  • Its own adaptive programming language.
  • We attempt an optimal integration giving us the
    strong advantages of both and only few small
    disadvantages.

89
Optimal DJ and DemeterJ Integration
  • Take all of DJ
  • Take all of DemeterJ class dictionary notation
  • Take a very tiny bit of DemeterJ adaptive
    programming language (basically only part that
    allows us to weave methods).

90
Combining DJ and DemeterJ
  • Pros (advantages)
  • Java class generation from class dictionary
    (getters, setters, constructors).
  • Parser generation.
  • Better packaging of Java code into different
    files.
  • MUCH MORE POWERFUL.
  • Cons (disadvantages)
  • No longer pure Java solution.
  • need to learn Demeter notation for class
    dictionaries (similar to XML DTD notation).
  • need to learn how to call DemeterJ and how to use
    project files.

91
Combining DJ and DemeterJ
  • What do we have to learn about DemeterJ?
  • Class dictionaries .cd files
  • Behavior files .beh files. Very SIMPLE!
  • A defines methods of class A
  • Project files .prj
  • list behavior files .beh that you are using
  • Commands
  • demjava new, demjava test,
  • demjava clean

92
Combining DJ and DemeterJ
  • What you might forget in class dictionaries that
    are used with DJ
  • import edu.neu.ccs.demeter.dj.
  • visitors need to inherit from Visitor
  • parts of visitors need to be defined in class
    dictionary

93
Combining DJ and DemeterJ
  • Structuring your files
  • put reusable visitors into separate behavior
    files.
  • put each new behavior into a separate behavior
    file. Visitors that are not planned for reuse
    should also go into same behavior file. Update
    the class dictionary with required structural
    information for behavior to work.
  • List all .beh files in .prj file.

94
Using DJ
  • traverse() returns the visitor 0 return value.
    Make sure the casting is done right, otherwise
    you get a run-time error. If public Object
    getReturnValue() returns an Integer and
    traverse() casts it to a Real casting error at
    run-time.
  • Make sure all entries of Visitor array are
    non-null.

95
Interfaces
interface PointI void move(int dx, int
dy) interface RealPointI extends PointI
void move(float dx, float dy) void move(double
dx, double dy) class MyPoint implements
RealPointI void move(int dx, int dy)
void move(float dx, float dy) void
move(double dx, double dy)
About PowerShow.com