Presentation is loading. Please wait.

Presentation is loading. Please wait.

Software Design and Development

Similar presentations


Presentation on theme: "Software Design and Development"— Presentation transcript:

1 Software Design and Development
COM 1205 First lecture, first class Sep25. 11/27/2018 COM 1205/1

2 Introduction Software engineering, modeling, design, software architecture Programming languages Hands-on, practical, useful What the course is about 11/27/2018 COM 1205/1

3 Summary of Course How to design and implement flexible object-oriented software using the principles of adaptiveness and separation of concerns in combination with UML and Java. Learning principles behind XML. How to design and implement flexible 100% pure Java software minimizing scattering and tangling of crosscutting behavioral concerns. What audience will learn 11/27/2018 COM 1205/1

4 Who is in Attendance? Software developers who have experience with object-oriented programming. Should know concepts of OOP, like classes, methods, and late binding. 11/27/2018 COM 1205/1

5 Academic Integrity Tension Learning from your peers: is valuable
for technical help; “this program does not run properly and I have tried for two hours to figure out why; can I explain my program to you?” for discussing ways to think about the concepts for project work if you work in a team of two for getting a concept explained for sharing frustrations Independent scholarship 11/27/2018 COM 1205/1

6 Academic Integrity Independent scholarship
required for writing the homework solutions required for exams 11/27/2018 COM 1205/1

7 Important Rules Learn when to go inside and solve the problems yourself. Learn when it is appropriate to use help from a peer. 11/27/2018 COM 1205/1

8 Aspect-Oriented Progr. Adaptive Programming DemeterJ Java and DJ
Featured in MIT Technology Magazine 2001 as a Top Ten Technology Agenda Aspect-Oriented Progr. Adaptive Programming DemeterJ Java and DJ Java environment UML XML strategy graphs class graphs object graphs state graphs principles heuristics patterns idioms theorems algorithms requirements domain analysis design implementation use cases interfaces traversals visitors packages Demeter Method iterative development spiral model Extreme Programming 11/27/2018 COM 1205/1

9 Aspect-Oriented Software Development (AOSD)
Observation: many concerns of the designer/programmer are scattered across many classes or methods and tangled with code of other concerns. A concern is called crosscutting, if its ad-hoc implementation is scattered. AOSD is about cleanly modularizing crosscutting concerns. A modularized crosscutting concern is called an aspect. Reduces scattering and tangling. 11/27/2018 COM 1205/1

10 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 topics covered and time allotted to each 11/27/2018 COM 1205/1

11 Agenda UML interaction diagrams
sequence diagrams collaboration diagrams improving interaction diagrams to make them specification languages XML data type definitions and documents 11/27/2018 COM 1205/1

12 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 topics covered and time allotted to each 11/27/2018 COM 1205/1

13 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. topics covered and time allotted to each 11/27/2018 COM 1205/1

14 Overview good separation of concerns is the goal
concerns should be cleanly localized programs should look like designs Big picture 11/27/2018 COM 1205/1

15 Adaptive Programming Programs adapt to interesting context changes
Structure-shy behavior Succinct representation of traversals Programming in terms of graph constraints 11/27/2018 COM 1205/1

16 Cross-cutting of concerns
better program ordinary program structure-shy functionality Components structure Aspect 1 avoid tangled programs AOP synchronization Aspect 2 11/27/2018 COM 1205/1

17 crosscutting concerns
public class Shape implements ShapeI { protected AdjustableLocation loc; protected AdjustableDimension dim; public Shape() { loc = new AdjustableLocation(0, 0); dim = new AdjustableDimension(0, 0); } double get_x() throws RemoteException { return loc.x(); } void set_x(int x) throws RemoteException { loc.set_x(); } double get_y() throws RemoteException { return loc.y(); } void set_y(int y) throws RemoteException { loc.set_y(); } double get_width() throws RemoteException { return dim.width(); } void set_width(int w) throws RemoteException { dim.set_w(); } double get_height() throws RemoteException { return dim.height(); } void set_height(int h) throws RemoteException { dim.set_h(); } void adjustLocation() throws RemoteException { loc.adjust(); void adjustDimensions() throws RemoteException { dim.adjust(); class AdjustableLocation { protected double x_, y_; public AdjustableLocation(double x, double y) { x_ = x; y_ = y; synchronized double get_x() { return x_; } synchronized void set_x(int x) {x_ = x;} synchronized double get_y() { return y_; } synchronized void set_y(int y) {y_ = y;} synchronized void adjust() { x_ = longCalculation1(); y_ = longCalculation2(); class AdjustableDimension { protected double width_=0.0, height_=0.0; public AdjustableDimension(double h, double w) { height_ = h; width_ = w; synchronized double get_width() { return width_; } synchronized void set_w(int w) {width_ = w;} synchronized double get_height() { return height_; } synchronized void set_h(int h) {height_ = h;} width_ = longCalculation3(); height_ = longCalculation4(); interface ShapeI extends Remote { double get_x() throws RemoteException ; void set_x(int x) throws RemoteException ; double get_y() throws RemoteException ; void set_y(int y) throws RemoteException ; double get_width() throws RemoteException ; void set_width(int w) throws RemoteException ; double get_height() throws RemoteException ; void set_height(int h) throws RemoteException ; void adjustLocation() throws RemoteException ; void adjustDimensions() throws RemoteException ; Modularization of crosscutting concerns public class Shape { protected double x_= 0.0, y_= 0.0; protected double width_=0.0, height_=0.0; double get_x() { return x_(); } void set_x(int x) { x_ = x; } double get_y() { return y_(); } void set_y(int y) { y_ = y; } double get_width(){ return width_(); } void set_width(int w) { width_ = w; } double get_height(){ return height_(); } void set_height(int h) { height_ = h; } void adjustLocation() { x_ = longCalculation1(); y_ = longCalculation2(); } void adjustDimensions() { width_ = longCalculation3(); height_ = longCalculation4(); coordinator Shape { selfex adjustLocation, adjustDimensions; mutex {adjustLocation, get_x, set_x, get_y, set_y}; mutex {adjustDimensions, get_width, get_height, set_width, set_height}; portal Shape { double get_x() {} ; void set_x(int x) {}; double get_y() {}; void set_y(int y) {}; double get_width() {}; void set_width(int w) {}; double get_height() {}; void set_height(int h) {}; void adjustLocation() {}; void adjustDimensions() {}; Write this Instead of writing this 11/27/2018 COM 1205/1

18 Aspect-Oriented Programming
components and aspect descriptions High-level view, implementation may be different From Gregor: maybe source code should say: intermediate source code add: picture of a preprocessor style implementation of an AOP system not all AOP systems will be preprocessor like. It is reasonable to expect that in the future the better ones won’t be this is a picture of what AOP is equivalent to, not necessarily how it works. general AOP Source Code (tangled code) weaver (compile- time) 11/27/2018 COM 1205/1

19 Examples of Aspects Collaborations, use cases
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 11/27/2018 COM 1205/1

20 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 explain how individual topics fit together 11/27/2018 COM 1205/1

21 Vocabulary Graph, nodes, edges, labels
Class graph, construction, alternation Object graph, satisfying class graph UML class diagram Grammar, printing, parsing Define terms, glossary 11/27/2018 COM 1205/1

22 Vocabulary Traversals, visitors Strategy graphs, path set 11/27/2018
Define terms, glossary 11/27/2018 COM 1205/1

23 Overview this lecture Basic UML class diagrams
Traversals/Collaborating classes Traversal strategy graphs Adaptive programming Tools for adaptive programming DemeterJ and AP/Studio 11/27/2018 COM 1205/1

24 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 explain details give an example exercise to re-enforce learning 11/27/2018 COM 1205/1

25 UML Class Diagram busStops BusRoute BusStopList buses 0..* BusStop
BusList Example for developing strategies and writing adaptive programs waiting 0..* passengers Bus PersonList Person 0..* 11/27/2018 COM 1205/1

26 2: Traversals / Collaborating classes
To process objects we need to traverse them Traversal can be specified by a group of collaborating classes 11/27/2018 COM 1205/1

27 Collaborating Classes
use connectivity in class graph to define them succinctly using strategy graphs separating structure from behavior teasing out the structure aspect from Customer to Agent from Company to Employee 11/27/2018 COM 1205/1

28 What's the problem? TANGLING
OOAD Z customer service center teller service self-service Collab-1 C1 C4 C2 C3 C5 Collab-4 Collab-2 Collab-3 Object-oriented languages do not provide adequate constructs to capture collaborations between several classes. Has been recognized in different forms in the object-oriented community: OO accommodates the addition of new variants of data types better than procedural programming but, the opposite is true when new operations on existing data types are needed visitor pattern: the matter of concern -- definition of new operations on an existing object structure (aggregation is involved besides inheritance) several works complain the lack of constructs for expressing collaboration-based designs C1 C4 C2 C3 Implementation C5 Collaboration -- a distinct (relatively independent aspect of an application that involves several participants, or roles roles played by application classes each class may play different roles in different collaborations each role embodies a separate aspect of the overall class behavior 11/27/2018 COM 1205/1 Collaboration-based design s Require to view oo applications in two different ways: (a) in terms of participants or types involved (b) in terms of the tasks or concerns of the design

29 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..* 11/27/2018 COM 1205/1

30 TPP 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. 11/27/2018 COM 1205/1

31 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 11/27/2018 COM 1205/1

32 find all persons waiting at any bus stop on a bus route
Traversal Strategy first try: from BusRoute to Person busStops BusRoute BusStopList buses 0..* BusStop BusList waiting 0..* passengers Bus PersonList Person 0..* 11/27/2018 COM 1205/1

33 find all persons waiting at any bus stop on a bus route
Traversal Strategy from BusRoute through BusStop to Person busStops BusRoute BusStopList buses 0..* BusStop BusList waiting 0..* passengers Bus PersonList Person 0..* 11/27/2018 COM 1205/1

34 find all persons waiting at any bus stop on a bus route
Traversal Strategy Altern.: from BusRoute bypassing Bus to Person busStops BusRoute BusStopList buses 0..* BusStop BusList waiting 0..* passengers Bus PersonList Person 0..* 11/27/2018 COM 1205/1

35 Robustness of Strategy
find all persons waiting at any bus stop on a bus route Robustness of Strategy from BusRoute through BusStop to Person villages BusRoute BusStopList busses VillageList busStops 0..* 0..* BusStop BusList Village waiting 0..* passengers Bus PersonList Person 0..* 11/27/2018 COM 1205/1

36 Filter out noise in class diagram
only three out of seven classes are mentioned in traversal strategy! from BusRoute through BusStop to Person explain why strategy better replaces traversal methods for the classes BusRoute VillageList Village BusStopList BusStop PersonList Person 11/27/2018 COM 1205/1

37 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 problem solved by traversal strategies 11/27/2018 COM 1205/1

38 TPP: Tip 53: Abstractions Live Longer than Details
Is in the Requirements Pit section Also applies to code: don’t overspecify! 11/27/2018 COM 1205/1

39 4: Adaptive Programming
How can we use strategies to program? Need to do useful work besides traversing: visitors Incremental behavior composition using visitors 11/27/2018 COM 1205/1

40 Styles of Adaptive Programming
Traditional: parameterize by class graph; strategy is part of adaptive program Traditional optimized: parameterize by class graph and strategy graph; reuse pair of class graph and strategy graph. 11/27/2018 COM 1205/1

41 Writing Adaptive Programs with Strategies (DJ=pure Java)
String WPS=“from BusRoute through BusStop to Person” class BusRoute { int countPersons(ClassGraph cg) { String WPS=“from 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();} } can we really program with strategies? Here is how. 11/27/2018 COM 1205/1

42 Writing Adaptive Programs with Strategies (DJ=pure Java)
// Prepare the class graph ClassGraph classGraph = new ClassGraph(); int r = aBusRoute.countPersons(classGraph); can we really program with strategies? Here is how. 11/27/2018 COM 1205/1

43 TPP section: The Evils of Duplication
Tip 11: DRY – Don’t Repeat Yourself Imposed duplication without tool support 11/27/2018 COM 1205/1

44 Goal of DJ Focus on crosscutting traversal-related concerns: involve a group of collaborating objects which are manipulated to implement a behavior. Provide a Java library to cleanly encapsulate crosscutting traversal-related concerns whose ad hoc implementation would be scattered across many classes. 11/27/2018 COM 1205/1

45 Solves Open Problem in AOP for Behavioral Aspects in Java
The ClassGraph-Aspect-Freezing problem When we have n behavioral aspects and the class graph changes, we potentially need to update all n aspects. DJ allows us to loosely couple behavioral aspects to the class graph. And this is all done in Java using REFLECTION. 11/27/2018 COM 1205/1

46 Writing Adaptive Programs with Strategies (DJ=pure Java)
String WPStrategy=“from 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();} } can we really program with strategies? Here is how. 11/27/2018 COM 1205/1

47 Writing Adaptive Programs with Strategies (DJ=pure Java)
String WPStrategy=“from 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); can we really program with strategies? Here is how. 11/27/2018 COM 1205/1

48 Writing Adaptive Programs with Strategies (DJ=pure 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(); } can we really program with strategies? Here is how. 11/27/2018 COM 1205/1

49 Writing Adaptive Programs with Strategies (DJ=pure Java)
String WPStrategy=“from BusRoute through BusStop to Person” // Prepare the slice for the current class graph ClassGraph classGraph = new ClassGraph(); ObjectGraph objectGraph = new ObjectGraph(aBusRoute, classGraph); ObjectGraphSlice whatToCount = new ObjectGraphSlice(objectGraph, WPStrategy); int r = Utility.countPersons(whatToCount); can we really program with strategies? Here is how. 11/27/2018 COM 1205/1

50 Writing Adaptive Programs with Strategies (DemeterJ)
strategy: from BusRoute through BusStop to Person BusRoute { int printCountWaitingPersons() // traversal/visitor weaving through BusStop to Person (PrintPersonVisitor); } PrintPersonVisitor { before Person {{ … }} … } PersonVisitor {init {{ r = 0; }} … } can we really program with strategies? Here is how. THIS IS NOT JAVA Extension of Java: keywords: init through bypassing to before after etc. 11/27/2018 COM 1205/1

51 Writing Adaptive Programs with Strategies (DemeterJ)
strategy: from BusRoute through BusStop to Person BusRoute { traversal waitingPersons(PersonVisitor) { through BusStop to Person; } // from is implicit int printCountWaitingPersons() // traversal/visitor weaving = waitingPersons(PrintPersonVisitor);} PrintPersonVisitor { before Person {{ … }} … } PersonVisitor {init {{ r = 0; }} … } THIS IS NOT JAVA can we really program with strategies? Here is how. Extension of Java: keywords: traversal init through bypassing to before after etc. 11/27/2018 COM 1205/1

52 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 11/27/2018 COM 1205/1

53 Programming in Large Families
Two adaptive programs A1 Class Graphs A2 adaptive programming is programming in LARGE families A1 family Object-Oriented Programs A2 family 11/27/2018 COM 1205/1

54 Strategy ClassGraph ObjectGraph Adaptive Programming is use-case based
Bold names refer to DJ classes. is use-case based abstraction of ClassGraph New: abstractions of class diagrams notice affinity to design patterns: some of them also talk about families of class structures explain strategies defines family of ObjectGraph 11/27/2018 COM 1205/1

55 Strategy ObjectGraph Adaptive Programming defines traversals of
explain strategies ObjectGraph 11/27/2018 COM 1205/1

56 Strategy Visitor Adaptive Programming guides and informs 11/27/2018
explain strategies Visitor 11/27/2018 COM 1205/1

57 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 explain strategies 11/27/2018 COM 1205/1

58 Strategies Edges: negative information: Delete edges from class graph.
bypassing edges incident with Bus BusRoute Person Edges: negative information: Delete edges from class graph. explain strategies from BusRoute bypassing Bus to Person 11/27/2018 COM 1205/1

59 5: Tools for Adaptive Programming
free and commercial tools available 11/27/2018 COM 1205/1

60 Free Tools on WWW DJ and AP Library Demeter/C++ DemeterJ
Demeter/StKlos Dem/Perl5 Dem/C++ Dem/CLOS Demeter/Object Pascal this technology is catching on last four developed outside our group 11/27/2018 COM 1205/1

61 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 ideas can be used without tools Applicable to design and documentation of your current systems. 11/27/2018 COM 1205/1

62 DemeterJ www.ccs.neu.edu/research/demeter class diagrams functionality
strategies visitors etc. Executable Java code for your favorite commercial Java Software Development Environment more details on Demeter/Java weaver 11/27/2018 COM 1205/1

63 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 more details on Demeter components and aspects structure-shy object description (*.input, at runtime) synchronization (*.cool) multi threading 11/27/2018 COM 1205/1

64 Cross-cutting in DemeterJ
generated Java program DemeterJ program structure-shy functionality structure replicated! aspect descriptions are not just copied into programs, they may be replicated several times. synchronization 11/27/2018 COM 1205/1

65 AP Studio visual development of traversal strategies relative
to class diagram visual feedback about collaborating classes visual development of annotated UML class diagrams drawing class diagrams and visualizing strategies has not been used much 11/27/2018 COM 1205/1

66 Strengths of DemeterJ Theory Novel algorithms for strategies
Formal semantics Correctness theorems Practice Extensive feedback (8 years) Reflective implementation 11/27/2018 COM 1205/1

67 Meeting the Needs DemeterJ
Easier evolution of class diagrams (with strategy diagrams) Easier evolution of behavior (with visitors) Easier evolution of objects (with sentences) Better separation of crosscutting traversal-related concerns 11/27/2018 COM 1205/1

68 Real Life Used in several commercial projects
Implemented by several independent developers Used in several courses, both academic and commercial 11/27/2018 COM 1205/1

69 Summary What has been learned: Simple UML class diagrams, strategies and adaptive programs How can you apply: DemeterJ takes adaptive programs as input Document and implement object-oriented programs with strategies using DJ in Java Design in terms of traversals and visitors state what has been learned define ways to apply training 11/27/2018 COM 1205/1

70 Where to get more information
Adaptive Programming book DJ home page DemeterJ home page Demeter home page: 11/27/2018 COM 1205/1

71 Feedback Request feedback of training session 11/27/2018 COM 1205/1


Download ppt "Software Design and Development"

Similar presentations


Ads by Google