Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using Diagrams to Represent Program Structure OMT and UML Some pictures and material are from “Design Patterns” by Gamma et al.

Similar presentations


Presentation on theme: "Using Diagrams to Represent Program Structure OMT and UML Some pictures and material are from “Design Patterns” by Gamma et al."— Presentation transcript:

1 Using Diagrams to Represent Program Structure OMT and UML Some pictures and material are from “Design Patterns” by Gamma et al

2 Outline l why diagrams l diagram types l class diagram elements n class n aggregation n inheritance n instantiation l class diagram examples l object diagram l use case diagram l interaction diagram 2

3 Why Diagrams l diagrams is a way to capture the essential aspects of the program n have an overview of the whole program n see the important relationships between elements of program n get the picture of the program before it is coded l standardized as part of n object modeling technique (OMT) – Rumbaugh, Blaha, et al 1991 n universal modeling language (UML) – Rational Rose Inc. and other companies l used in program planning, development and documentation l language independent (not necessarily C++) 3

4 Diagram Types l structure diagram – emphasizes what constructs must be present in the modeled system n class diagram – the system classes, attributes, their relationships n object diagram – a view of the modeled system at a specific execution instance l behavior diagram – emphasizes what actions must happen in the system n use-case diagram – system functionality in terms of interaction with outside actors n interaction diagram – flow of control and data among constructs 4

5 Classes l operations – member functions/methods l instance variables – member variables/attributes class Example{ public: void showchar(); string getstring(); private: char c; string str; }; class BankAccount{ public: void deposit(dollars amount); void withdrawal(dollars amount); private: string owner; dollars balance; }; Example showchar(): void getstring(): string c: char str: string ClassName oper2(): returnType oper1(parName: parType): rType instVar1: Type instVar2: Type 5

6 Aggregation l if class contains instances (objects) of other classes the class aggregates them l if class aggregates more than one instance of the same class it is shown diagramatically l multiplicity - shows how many instances of objects on each side 6

7 Inheritance, Reference and Instantiation Class inheritance l class contains a reference to another l object creation (class instantiation) is done by a method of another class Additional comments 7

8 Visibility - private member + public member 8

9 Example Class Diagram 1 9

10 Example Class Diagram 2 10

11 Example Class Diagram 3 l blah 11

12 Object Diagram l shows objects and references as the program is executed l what would be a class and an object diagram for an object with dynamically allocated members? 12

13 Use Case Diagrams l written description of the system’s behavior regarding tasks or requirements l captures interactions between actors (outside entities) and the system through use cases use case actor 13

14 Interaction (Sequence) Diagram l shows order in which requests (methods) between objects are executed - scenario, typically within a single use case n boxes – processes (function invocation) in each object n lines – messages (interaction) between objects n lifeline – vertical dashed line represents objects’ existence 14

15 Interaction Diagram Examples 15

16 Interaction Diagram Examples 2 16

17 Questions on Diagrams l What is the purpose for the use of diagrams l What is the difference between structure and behavior diagrams? l What types of structure diagrams we have studied? Behavior diagrams? l How is class denoted on a structure diagram? l What is aggregator/agregatee? How is their relationship denoted? l What is multiplicity and how is it denoted? l What is visibility and hwo is it denoted? l How are objects denoted on an a structure diagram? l What diagram uses use cases, actors? What is system boundary? l What do boxes and lines and crosses represent in a flow diagram? 17

18 Battleship Class and Object Diagrams 18

19 Battleship Use Case and Interaction Diagrams 19


Download ppt "Using Diagrams to Represent Program Structure OMT and UML Some pictures and material are from “Design Patterns” by Gamma et al."

Similar presentations


Ads by Google