Soft Engg 4

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Soft Engg 4 as PDF for free.

More details

  • Words: 1,800
  • Pages: 57
Adaptive Object-Oriented Software Development The Demeter Method

10/1/98

AOOP / Demeter

1

Introduction • Software engineering • Programming languages • Hands-on, practical, useful

10/1/98

AOOP / Demeter

2

Summary of Course • How to design and implement flexible object-oriented software using the principles of adaptiveness. • How to design and implement flexible 100% pure Java software

10/1/98

AOOP / Demeter

3

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.

10/1/98

AOOP / Demeter

4

Agenda for Adaptive Object-Oriented Software/Demeter Demeter/Java Java Java environment UML XML requirements domain analysis design implementation

10/1/98

Adaptive Programming Aspect-Oriented Progr. principles principles heuristics heuristics patterns patterns idioms idioms theorems theorems algorithms algorithms Demeter Method iterative development spiral model AOOP / Demeter

strategy graphs class graphs object graphs state graphs

use cases interfaces traversals visitors packages 5

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 10/1/98

AOOP / Demeter

6

Agenda • UML interaction diagrams – sequence diagrams – collaboration diagrams – improving interaction diagrams to make them specification languages

10/1/98

AOOP / Demeter

7

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/1/98

AOOP / Demeter

8

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. 10/1/98

AOOP / Demeter

9

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

10/1/98

AOOP / Demeter

10

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

10/1/98

AOOP / Demeter

11

Cross-cutting of components and aspects better program ordinary program

structure-shy functionality

Components

Aspect 1 structure

Aspect 2 synchronization

10/1/98

AOOP / Demeter

12

Aspect-Oriented Programming components and aspect descriptions High-level view, implementation may be different Source Code (tangled code)

weaver (compiletime)

10/1/98

AOOP / Demeter

13

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.

10/1/98

AOOP / Demeter

14

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 10/1/98

AOOP / Demeter

15

Vocabulary • • • • •

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

10/1/98

AOOP / Demeter

16

Vocabulary • Traversals, visitors • Strategy graphs, path set

10/1/98

AOOP / Demeter

17

Overview this lecture • • • • • •

Basic UML class diagrams Traversals/Collaborating classes Traversal strategy graphs Adaptive programming Tools for adaptive programming Demeter/Java and AP/Studio

10/1/98

AOOP / Demeter

18

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

10/1/98

AOOP / Demeter

19

UML Class Diagram busStops BusRoute

BusStopList

buses

0..* BusStop

BusList 0..*

waiting passengers

Bus

PersonList Person

10/1/98

AOOP / Demeter

0..* 20

2: Traversals / Collaborating classes • To process objects we need to traverse them • Traversal can be specified by a group of collaborating classes

10/1/98

AOOP / Demeter

21

Collaborating Classes use connectivity in class graph to define them succinctly using strategy graphs

from Company to Employee 10/1/98

AOOP / Demeter

from Customer to Agent 22

Collaborating Classes find all persons waiting at any bus stop on a bus route busStops BusRoute buses BusList 0..*

BusStopList OO solution: one method for each red class

BusStop waiting

passengers

Bus

PersonList Person

10/1/98

0..*

AOOP / Demeter

0..* 23

3: Traversal Strategy Graphs • Want to define traversals succinctly • Use graph to express abstraction of class diagram • Express traversal intent: useful for documentation of object-oriented programs

10/1/98

AOOP / Demeter

24

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 0..*

waiting passengers

Bus

PersonList Person

10/1/98

AOOP / Demeter

0..* 25

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 0..*

waiting passengers

Bus

PersonList Person

10/1/98

AOOP / Demeter

0..* 26

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 0..*

waiting passengers

Bus

PersonList Person

10/1/98

AOOP / Demeter

0..* 27

find all persons waiting at any bus stop on a bus route

Robustness of Strategy from BusRoute bypassing Bus to Person BusRoute buses BusList 0..*

villages VillageList 0..* Village

busStops

0..*

BusStop waiting

passengers

Bus

PersonList Person

10/1/98

BusStopList

AOOP / Demeter

0..* 28

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

10/1/98

AOOP / Demeter

29

find all persons waiting at any bus stop on a bus route

Even better: interface class graph from BusRoute through BusStop to Person busStops

BusStop

BusRoute 0..*

waiting buses

0..* Bus

passengers

0..*

Person

0..* 10/1/98

AOOP / Demeter

30

Map interface class graph to application class graph from BusRoute through BusStop to Person BusRoute buses BusList 0..*

villages VillageList 0..* Village

10/1/98

busStops

0..*

BusStop waiting

passengers

Bus edge -> path

BusStopList

PersonList Person AOOP / Demeter

0..* 31

Map interface class graph to application class graph from BusRoute through BusStop to Person BusRoute

villages

BusStopList

VillageList 0..*

busStops BusStop

Village busStops BusRoute edge -> path 10/1/98

0..*

BusStop

0..* AOOP / Demeter

32

Benefits of interface class graph • Shields program from details of application class graph • Makes program more robust and simpler

10/1/98

AOOP / Demeter

33

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

10/1/98

AOOP / Demeter

34

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

10/1/98

AOOP / Demeter

35

Writing Adaptive Programs with Strategies strategy: from BusRoute through BusStop to Person BusRoute { traversal waitingPersons(PersonVisitor) { through BusStop to Person; } // from is implicit int printWaitingPersons() // traversal/visitor weaving instr. = waitingPersons(PrintPersonVisitor); PrintPersonVisitor { before Person (@ … @) … } PersonVisitor {init (@ r = 0; @) … } Extension of Java: keywords: traversal init through bypassing to before after etc. 10/1/98

AOOP / Demeter

36

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 10/1/98

AOOP / Demeter

37

Programming in Large Families Two adaptive programs A1 Class Graphs A2

A1 family Object-Oriented Programs A2 family 10/1/98

AOOP / Demeter

38

Adaptive Programming

Strategy Diagrams are use-case based abstractions of

Class Diagrams define family of

Object Diagrams 10/1/98

AOOP / Demeter

39

Adaptive Programming

Strategy Diagrams define traversals of

Object Diagrams 10/1/98

AOOP / Demeter

40

Adaptive Programming

Strategy Diagrams guide and inform

Visitors 10/1/98

AOOP / Demeter

41

Strategy Diagrams 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 10/1/98

AOOP / Demeter

42

Strategy Diagrams bypassing edges incident with Bus BusRoute

Person

Edges: negative information: Delete edges from class diagram. from BusRoute bypassing Bus to Person 10/1/98

AOOP / Demeter

43

5: Tools for Adaptive Programming • free and commercial tools available

10/1/98

AOOP / Demeter

44

Free Tools on WWW • • • • • • •

Demeter/C++ Demeter/Java Demeter/StKlos Dem/Perl5 last four developed outside our group Dem/C++ Dem/CLOS Demeter/Object Pascal

10/1/98

AOOP / Demeter

45

Commercial Tools available on WWW StructureBuilder from Tendril Software Inc. next release will have support for traversals www.tendril.com

10/1/98

AOOP / Demeter

46

Benefits of Demeter • 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. 10/1/98

AOOP / Demeter

47

Demeter/Java •class diagrams •functionality •strategies •visitors •etc.

www.ccs.neu.edu/research/demeter Executable Java code for your favorite commercial Java Software Development Environment

weaver

10/1/98

AOOP / Demeter

48

Demeter/Java in Demeter/Java structure (*.cd) class diagrams structure-shy communication (*.ridl) distribution

compiler/ weaver

synchronization (*.cool) multi threading 10/1/98

AOOP / Demeter

focus of this lecture structure-shy behavior (*.beh) strategies and visitors structure-shy object description (*.input, at runtime) 49

Cross-cutting in Demeter/Java generated Java program

Demeter/Java program structure-shy functionality

structure

replicated!

synchronization 10/1/98

AOOP / Demeter

50

AP Studio •visual development of traversal strategies relative to class diagram •visual feedback about collaborating classes •visual development of annotated UML class diagrams

10/1/98

AOOP / Demeter

51

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

10/1/98

AOOP / Demeter

52

Meeting the Needs • Demeter/Java – Easier evolution of class diagrams (with strategy diagrams) – Easier evolution of behavior (with visitors) – Easier evolution of objects (with sentences)

10/1/98

AOOP / Demeter

53

Real Life

• Used in several commercial projects • Implemented by several independent developers • Used in several courses, both academic and commercial 10/1/98

AOOP / Demeter

54

Summary • What has been learned: Simple UML class diagrams, strategies and adaptive programs • How can you apply: – Demeter/Java takes adaptive programs as input – Document object-oriented programs with strategies – Design in terms of traversals and visitors 10/1/98

AOOP / Demeter

55

Where to get more information • Adaptive Programming book • UML Distilled • Demeter/Java home page • Course home page: www.ccs.neu.edu/research/demeter/ course/f98 10/1/98

AOOP / Demeter

56

Feedback • Request feedback of training session

10/1/98

AOOP / Demeter

57

Related Documents

Soft Engg 4
November 2019 7
Soft Engg 1
November 2019 4
Soft Engg 2
November 2019 5
Soft Engg 3
November 2019 4
Automobile Engg-unit-4
April 2020 4
Engg
October 2019 38