Title: Software Development
1Software Development
- CSU 670
- Karl Lieberherr
- https//lists.ccs.neu.edu/bin/listinfo/
2Cross-cutting of concerns
better program
ordinary program
structure-shy functionality
Chapter 1
structure
Chapter 2
synchronization
Chapter 3
Woven meaning of book
3Modularization of crosscutting concerns
Instead of writing this
4UML Class Diagram
busStops
BusRoute
BusStopList
buses
0..
BusStop
BusList
waiting
0..
passengers
Bus
PersonList
Person
0..
5Collaborating Classes
use connectivity in class graph to define them
succinctly using strategy graphs
from Customer to Agent
from Company to Employee
6What's the problem? TANGLING
OOAD
collaborations
Collab-1
requirements use-cases
C1
C4
C2
C3
C5
Collab-4
Collab-2
Collab-3
C1
C4
C2
C3
Implementation
C5
classes
7Problems with Object Decomposition
During implementation separate higher-level functi
ons are mixed together
During maintenance/evolution individual
collaborations need to be factored out of
the tangled code
8Collaborating 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..
9TPP section Decoupling and the Law of Demeter
- Write shy code
- A shy person does not interact with too many
people. - A shy method does not interact with too many
classes/objects.
10Traversal 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..
11Traversal 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..
12Traversal 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..
13Robustness 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..
14TPP Tip 53 Abstractions Live Longer than Details
- Is in the Requirements Pit section
- Also applies to code dont overspecify!
15Writing Adaptive Programs with Strategies
(DJpure Java)
String WPSfrom BusRoute through BusStop to
Person
class BusRoute int countPersons(ClassGraph
cg) String WPSfrom BusRoute through
BusStop to Person Integer result
(Integer) cg.traverse(this, WPS, 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()
16Writing Adaptive Programs with Strategies
(DJpure Java)
// Prepare the class graph ClassGraph classGraph
new ClassGraph() int r aBusRoute.countPerso
ns(classGraph)
17TPP section The Evils of Duplication
- Tip 11 DRY Dont Repeat Yourself
- Imposed duplication without tool support
18Cross-cutting in DemeterJ
generated Java program
DemeterJ program
structure-shy functionality
structure
replicated!
synchronization
19Back to COM 1350
- A context-free grammar is a 4-tuple (V,Sigma,R,S)
- V Variables (or non terminals)
- Sigma terminals
- R rules
- S start variable