Java UML Development Environment UML DIAGRAMMING WITH ASTAH

  • Slides: 39
Download presentation
Java UML Development Environment UML DIAGRAMMING WITH ASTAH* Using Astah March 2, 2021 1

Java UML Development Environment UML DIAGRAMMING WITH ASTAH* Using Astah March 2, 2021 1

Astah – First Opened Using Astah March 2, 2021 2

Astah – First Opened Using Astah March 2, 2021 2

Create a New Project Using Astah March 2, 2021 3

Create a New Project Using Astah March 2, 2021 3

Add a Diagram Choose Class Diagram Using Astah March 2, 2021 4

Add a Diagram Choose Class Diagram Using Astah March 2, 2021 4

New Class Diagram Using Astah March 2, 2021 5

New Class Diagram Using Astah March 2, 2021 5

Give Diagram a Name New Name Type new name here Using Astah March 2,

Give Diagram a Name New Name Type new name here Using Astah March 2, 2021 6

Add a Class to the Diagram New class diagram added. Give it an appropriate

Add a Class to the Diagram New class diagram added. Give it an appropriate name. Click this button to add a class New class Then click here to place it One may also double-click in this area to add a class Using Astah March 2, 2021 7

Add Attributes Click to work with attributes Using Astah March 2, 2021 8

Add Attributes Click to work with attributes Using Astah March 2, 2021 8

Add New Attribute Click Add to add an attribute Using Astah Fill in the

Add New Attribute Click Add to add an attribute Using Astah Fill in the Name, Type, and Visibility of the Attribute March 2, 2021 9

New Attribute Using Astah If the desired type is not in this list, just

New Attribute Using Astah If the desired type is not in this list, just type it here. March 2, 2021 10

Editing Attribute To edit the selected attribute’s features Change these characteristics as needed Using

Editing Attribute To edit the selected attribute’s features Change these characteristics as needed Using Astah March 2, 2021 11

Add Methods to the Class Methods are called Operations in Astah Add, Edit, Delete,

Add Methods to the Class Methods are called Operations in Astah Add, Edit, Delete, or Rearrange Methods as Desired Using Astah March 2, 2021 12

Adding and Editing Parameters To add or edit parameters Using Astah March 2, 2021

Adding and Editing Parameters To add or edit parameters Using Astah March 2, 2021 13

After adding the methods Using Astah March 2, 2021 14

After adding the methods Using Astah March 2, 2021 14

Alternatively, … One may add attributes and methods in the drawing area by clicking

Alternatively, … One may add attributes and methods in the drawing area by clicking on one of the glyphs displayed when hovering over the class Click this glyph to add an attribute Click this glyph to add a method to the class diagram Using Astah March 2, 2021 15

Add a second class Add a class in same way as first Using Astah

Add a second class Add a class in same way as first Using Astah After renaming new class and adding the main method March 2, 2021 16

Showing Dependency Relationship Use this button to draw a dependency relationship – also called

Showing Dependency Relationship Use this button to draw a dependency relationship – also called instantiation relationship Using Astah March 2, 2021 17

Showing Dependency Relationship Driver and Drag to Circle Result shows that Circle. Driver creates

Showing Dependency Relationship Driver and Drag to Circle Result shows that Circle. Driver creates and uses one or more Circle objects Using Astah March 2, 2021 18

Labeling the Dependency Line is now labeled Click on the Dependency Line to Select

Labeling the Dependency Line is now labeled Click on the Dependency Line to Select it. Then choose the Stereotype tab and type the label you want Using Astah March 2, 2021 19

Resulting Diagram May print the diagram Save the diagram – extension will be. asta

Resulting Diagram May print the diagram Save the diagram – extension will be. asta Using Astah March 2, 2021 20

Class Diagram Background Color Change background color for a selected class diagram by clicking

Class Diagram Background Color Change background color for a selected class diagram by clicking this button and then choosing the desired color Using Astah March 2, 2021 21

Zooming Zoomed In Fit in Window Zoom In Zoom Out Using Astah March 2,

Zooming Zoomed In Fit in Window Zoom In Zoom Out Using Astah March 2, 2021 22

Adjusting Alignment and Spacing Using Astah March 2, 2021 23

Adjusting Alignment and Spacing Using Astah March 2, 2021 23

Class Relationships and UML Connectors Instantiation, Aggregation, and Composition Using Astah March 2, 2021

Class Relationships and UML Connectors Instantiation, Aggregation, and Composition Using Astah March 2, 2021 24

Class Relationships An object of one class may use an object of another class

Class Relationships An object of one class may use an object of another class to do some part of its work A Student object may use a Computer object to complete some Assignment objects A Hand object has 5 Finger objects A Ship object has one or more Propeller objects A Movie. Collection may consist of many Movie objects A Doctor object has Patient objects A Human. Body has a Head A Mechanic may use a Wrench object to loosen a Nut Using Astah March 2, 2021 25

Several Types of Relationships Instantiation – a method of an object may instantiate and

Several Types of Relationships Instantiation – a method of an object may instantiate and use an object of another class to do a specific task but the object being used is not a fundamental part of the object using it A Carpenter uses a Nail to fasten 2 boards together A Seamstress uses a Needle and Thread A Dog gnaws on a Bone Typically, a method of one class (say A) instantiates and uses an object of another class (say B) but the object of B is not a part (attribute) attribute of A Using Astah March 2, 2021 26

Implementing the Instantiation Relationship Typically, this relationship is implemented in Java code with a

Implementing the Instantiation Relationship Typically, this relationship is implemented in Java code with a client method in the user class, say class A, instantiating an object of the other class, say class B, and then calling one or more methods of B on that object. In UML: Instantiates and Uses Connector Class Relationships March 2, 2021 27

Sample Code Skeleton A method in class Carpenter instantiates an object of class Hammer

Sample Code Skeleton A method in class Carpenter instantiates an object of class Hammer and then uses it. Instantiation/Uses can also be implemented by passing an object of class Hammer to a method of class Carpenter and using it. Class Relationships March 2, 2021 28

Has-A Relationships If an object of one class (say A) has a component (attribute)

Has-A Relationships If an object of one class (say A) has a component (attribute) attribute that is an object of another class (say B), B) we say Class A has a “Has-A” Has-A relationship with Class B. Also called a Part-Whole Relationship A Human. Body has-a Head A Student has-a Computer A Deck. Of. Cards has-a collection of Card objects A Car has-a Motor A Class. Room has-a set of Chair objects A Student has-a Advisor The key point is that the object of B is an attribute of A. Using Astah March 2, 2021 29

Two Types of Has-A Relationships In some Has-A relationships, the relationship is essential and

Two Types of Has-A Relationships In some Has-A relationships, the relationship is essential and the constructor of one class instantiates an object of the other class A Hand has Fingers A Person has a Head A Car has a Motor The Person is not a Person without its Head and the Car is not a complete Car without its Motor This type of Has-a (Part-Whole) relationship is called Composition Using Astah March 2, 2021 30

Composition This type of arrow indicates that the roof is an integral component of

Composition This type of arrow indicates that the roof is an integral component of the house Indicates a House object has exactly one Roof object, named roof One class is partially or fully composed of objects of other classes In the diagram, class House has (or contains) one object roof of type Roof The class acting as the whole (House) maintains a reference (or references) to an object(s) of the class that is acting as the part (Roof) The difference between this and aggregation is that the part is instantiated when the whole is instantiated. The house and the roof come into existence together (in the constructor for the House) Class Relationships March 2, 2021 31

Composition in UML Select the Composition Arrow in Astah* and Drag FROM the whole

Composition in UML Select the Composition Arrow in Astah* and Drag FROM the whole (House) TO the part (Roof) Select this symbol Drag it FROM House TO Roof … … to get this Class Relationships March 2, 2021 32

Composition Because the Roof/House cannot exist without the other, the House constructor creates its

Composition Because the Roof/House cannot exist without the other, the House constructor creates its own Roof – and the Roof object exists as long as the House object does Class Relationships The “part” is always created when the “whole” is created March 2, 2021 33

Aggregation is a type of a Has-a relationship in which one object Has-a object

Aggregation is a type of a Has-a relationship in which one object Has-a object of another class as an attribute, but that object is not essential to the existence of the other, and it is not instantiated by the constructor of the other A Student is still a Student without a Computer A Class. Room is still a Class. Room even if one removes its Chairs A Person is still a Person even if he/she loses his/her Coat Using Astah March 2, 2021 34

Aggregation In the aggregate relationship, one class aggregates objects of the other class In

Aggregation In the aggregate relationship, one class aggregates objects of the other class In the diagram, class Room has (or contains) zero or one objects of type Chair The class Room, acting as the whole, maintains a reference (or references) to an object(s) of the class Chair that act as the part There are usually one or more methods (that may or may not ever be invoked) that instantiate one or more instances of the part Reference name This type arrow indicates the aggregation relationship Class Relationships Between 0 and 1 instances of a Chair March 2, 2021 35

Aggregation in UML In Astah*, the aggregation relationship is indicated as shown here: Select

Aggregation in UML In Astah*, the aggregation relationship is indicated as shown here: Select the Aggregation Symbol Use this dropdown … Tooltip helps one select the proper symbol … to get this list Class Relationships March 2, 2021 36

Aggregation in astah* Drag the selected arrow FROM the “whole” (Room) TO the “part”

Aggregation in astah* Drag the selected arrow FROM the “whole” (Room) TO the “part” (Chair) The PART The WHOLE Arrow is the result of dragging FROM the Room class TO the Chair class Class Relationships March 2, 2021 37

Aggregation: code skeleton The Room has an attribute reference to a Chair object Room

Aggregation: code skeleton The Room has an attribute reference to a Chair object Room instantiates a reference to an object of type Chair – initially null Some method in Room associates the Room object with an actual Chair with the reference named chair Note that the Room object exists (and is initialized by the Room constructor – not shown) and the Chair object that is passed to the set. Chair method exists separately. The Chair becomes a real part of this Room only when this method is invoked Class Relationships March 2, 2021 38

Enums in UML - Example Use this connector to an enumerated data type Using

Enums in UML - Example Use this connector to an enumerated data type Using Astah March 2, 2021 39