Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to UML Part 2.

Similar presentations


Presentation on theme: "Introduction to UML Part 2."— Presentation transcript:

1 Introduction to UML Part 2

2 Building blocks of the UML
As part of a model you have: 1 modeling elements 2 relationships between the modeling elements 3 diagrams that group and visualize the modeling elements and the relations between them. E.g. class diagram: Company Department Office * 1 1..* LocatedAt

3 1 Modeling elements You have modeling elements for:
1.1 Structural things 1.2 Behavioral things 1.3 Grouping things 1.4 Annotational things

4 1.1 Structural elements Identified with nouns, e.g. Person; Typically representing static parts of the model. In UML you will find 7 different types of structual elements: 1.1.1 Class 1.1.2 Interface 1.1.3 Active class 1.1.4 Colloboration 1.1.5 Component 1.1.6 Node 1.1.7 Use Case

5 1.1.1 Class: Describes a Set of Objects
class name attributes operations visibility operation signature Rose: The icons , and can be used instead of +, # and - Rational Rose 2000 Point - x : int - y : int + getX() : int + setX(aX : int) : void + getY() : int + setY(aY : int) : void

6 Encapsulation - Also Called Data Hiding
Encapsulation: hiding the the implementation of the data from users of the object. Users are typically objects of other classes. The users don’t see if the data is stored in fields, calculated or if they are retrieved from a database, they only call a method. Encapsulation is achieve by never letting objects directly access fields. Fields should only be accessed through the object’s methods. Making the fields private (or protected) ensures encapsulation. If you want objects of different types to access the fields, then make public methods (or package accessibility) for this purpose.

7 Operation Versus Method (C++ member function)
A method is an implementation of an operation. A method specifies the algorithm or procedure that produces the results of an operation.

8 1.1.2 Interface: A Named Set of Operations That Describes Some Behavior (No Implementation)
stereotype interface name ISortable operation compartment interface - iconic form interface - expanded form

9 An Interface Can Be Seen As a Protocol
An interface is an agreement on behavior. A class which implements an interface agrees on supporting the specified behavior. An interface can also be seen as a definition of a role, classes which implements the role are able to play that role. Example: The auto-pilot of an airplane can act as a pilot the same is true about some humans. The auto-pilot and the human is quit different types of objects, but they can both play the same role. Many different types of objects can implement the interface, so the interface is not the same as a “class to subclass from”. Interface, HiA by J.P.Nytun 2 2

10 1.1.3 Active Class Snake pos:Point move() bite() Active class: describes objects that owns their own thread; The behavior of this objects can be concurrent with others

11 1.1.4 Colloboration Listener
Colloboration: describes a colloboration between roles to achieve a particular goal. A collaboration can represent an implementation of a use case or a particular pattern. Listener

12 1.1.5 Component calculate.class
Component: a physical part of the system which implements a set of interfaces.

13 Different types of Components (in UML)
Deployment Components: this components can be assembled to form a complete executable system. Example: A complete executable application, a dynamic library (DLL), a JavaBean, a COM+ object. Work Product Components: this components are the basis for making the deployment components. They are not a part of the executable system, but results from the development process. Example: Source code. Execution Components: this components are created by an executing system. Example: a JavaBean created during runtime.

14 Web Example Menu.html ------ ------ Menu --- Menu.java Menu.jpg
Working product component Deployment component Menu.html --- Menu Menu.java Could be an execution component, e.g. Produced by a servelet Deployment component Menu.jpg

15 1.1.6 Node Node: a physical element that represent a computational resource (e.g. processor and memory). videoServer

16 1.1.7 Use Case Register for exam
Use case: describes a sequence of actions that yields an observable result for an actor. With use cases you can structure the behavioral things in a model. Register for exam

17 Extensibility Mechanisms
«container» EventQueue {version 2.1} tagged value add(e:event) remove(n:int) «query» length():int «helper function» reorder() {add runs in O(1) time} stereotype constraint

18 1.2 Behavioral Elements Describing the dynamically parts of the model. Behavioral elements are identified with the help of verbs. 1.2.1 Interaction 1.2.2 State

19 1.2.1 Interaction Interaction: A behavior that comprises a set of messages sent between a set of objects to archive a special purpose, like in a sequence diagram.

20 1.2.2 State Machine State machine: A description of the different
states an object can go through in response to events. Events generated by the object is also shown. An activity diagram is a special case of a state diagram.

21 1.3 Grouping Elements You can group elements with the help of packages. [1]: ”A package may own other elements, including classes, ..., diagrams, and even other packages.” You can use packages to orginaze your classes (interfaces,..) and your diagrams. java applet +Applet

22 1.4 Annotational Elements
You can add comments to a diagram with the help of notes. A comment

23 2 Relations You have 4 different relationships: 2.1 Dependency
2.2 Association 2.3 Generalitation 2.4 Realization

24 2.1 Dependency: A relationship between to modeling elements, indicate that a change in the destination may effect the source. Company add(e : employee) Employee The method add has an employee as argument, so Company-class (source) is dependent of the Employee-class (destination).

25 2.2 Association: This relationship indicate that there is a connection from one type of objects to another type. An important type of association is aggregation which indicates that one object contains objects of a given type. Company association name composition or strong aggregation 1 1..* 1..* LocatedAt Department Office multiplicity * * ordinary association

26 A bird is a specialization
2.3 Generalization: A relationship between a more general element and a more specific one. For example: a bird is also an animal. Animal Bird A bird is a specialization of an animal.

27 The class Snake implements
2.4 Realization: UML: ”A semantic relationships between classifiers, in which one classifiers specifies a contract that another classifier guarantees to carry out”. ”interface” Movable move(x,y) Snake move(x,y) The class Snake implements the interface Movable.

28 3 Diagrams A diagram is typically a view of a part of the model, showing modeling elements and some of the relationships between them. A diagram do not have to be complete, some elements may be missing or presented in a simplified fashion. UML: ”A well-formed model is one that is semantically self-consistent and in harmony with all related models.”

29 There are 9 types of diagrams in UML
Dynamic views Static views Use Case Diagrams Sequence Diagrams Some part of the model might not be visible on any diagram Class Diagrams Collaboration Diagrams Object Diagrams Model Activity Diagrams Component Diagrams Statechart Diagrams Deployment Diagrams

30 3.1 Use case diagram actor register a person
association use case system boundary include relationship register a person edit a registration/ delete a registration User navigate/view the register ”include” view next person view previous person ”include”

31 Use Case Diagram - One More Example
”A use case is a specific way of using the system by performing some part of the functionality. Each use case constitutes a complete course of events initiated by an actor, and it specifies the interaction that takes place between an actor and the system....” I. Jacobson

32 StudentCourseProfile
3.2 Class Diagram 1 responsible for * Course Person CourseModule name : String description : String name : String String homePage : String tech. responsible for name : String description : String 1 * * 1..* 1 1 * 1 Student * StudentCourseProfile * finished : boolean When a student register for course a StudentCourseProfile object will be made!

33 A Class Diagram With Navigation
1 responsible for * Course Person CourseModule name : String description : String name : String imail : String homePage : String 1 tech. responsible for * * 1..* name : String description : String 1 1 * * 1 StudentCourseProfile * Student finished : boolean

34 A Class Diagram - Mapping to Java
1 responsible for * Course Person name : String description : String name : String imail : String homePage : String 1 tech. responsible for * 1 * * 1 StudentCourseProfile Student finished : boolean public class Person { protected String name; protected String imail; protected String homePage; // // Navigation protected Course[] responsibleFor; protected Course[] techResponsibleFor; public Person() { } public class Student extends Person { // // Navigation public StudentCourseProfile[] studentCourseProfile; public Student() { }

35 A Class Diagram - Example With Interface
IStorable Register -reg 0..* 0..* edit() write() relization read() public void read(){ Person terminal.print("Name: "); name = terminal.readLine(); edit() ... write() } read() relization/implements To different representation of nearly the same dependency

36 A Class Diagram - One More Example With Interface

37 3.3 Object Diagram - Capture Instances and Links
Class Object Company HiA: Company noOfEmploees=600 noOfEmploees : int Possible object name object class attribute with value

38 Object Diagram with Links
Class Diagram Object Diagram Language: Department :LocatedAt Gimlemoen: Office Company Department Office LocatedAt 1 1..* * HiA: Company Possible object diagram Engineering : Department :LocatedAt Grooseveien: Office Link - A link is an instance of an association, analogous to an object being an instance of a class.

39 Object diagram and Rational Rose 2000
Rational Rose 2000 does not have object diagrams, but you can achieve much the same with a collobartion diagram You can not specify attributes inside object; One solution to this short-coming is to use a comment!

40 3.4 Sequence diagram ”create” register user controllerViewer person
<command r> <name, ,..> person ”create” setData(name, ..) insert(person)

41 3.5 Colloboration diagram
1.2: ”create” 1: register() 1.3: setDate(data) user controllerViewer person 1.1: data := getData() 1.4: insert(person) register

42 3.6 Statechart diagram StateChart for microwave oven "control unit"

43 Statechart for Applet Not Loaded Running Loaded Stopped init/init()
stop/ stop() Stopped start /start() start/start() destroy/destroy()

44 3.7 Activity diagram - Capture Dynamic Behaviour (Activity-oriented)

45 Activity diagram - One More Example
product of activity

46 Activity diagram - One More Example
user controller person register request registration create person (object) supply person-data forward person-data process person-data insert person

47 3.8 Component diagram - Captures the Physical Structure of the Implementation
applet1.class applet1.java Demo.html applet2.class applet2.java logo.gif

48 Component diagram - One More Example
Person.class Register.class ISortable

49 3.9 Deployment diagram Extended VLAN ”Server” ”network” LAN ”PC” ”PC”

50 Multi-tier Architecture - MVC - view: browser/jsp/servlet controller: jsp/servlet model: businessObjects client: Internet browser: server1: :WebServer :html :html :ServletContainer Intranet s1:Servlet s2:Servlet j1:Jsp j2:Jsp b1:BusinessObject b3:BusinessObject b2:BusinessObject b4:BusinessObject server2: :DB

51 References [1] Grady Booch, James Rumbaugh and Ivar Jacobson: The Unified Modeling Language User Guide. Addison-Wesley, 1999 James Rumbaugh, Michael Blaha, William Premerlani, Frederick Eddy and William Lorenzen: Object-Oriented Modeling and Design. Prentice Hall, 1991 Martin Fowler with Kendall Scott: UML Distilled. Addison-Wesley, 1997 Terry Quatrani: Visual Modeling with Rational Rose and UML. Addison-Wesley, 1998 Ari Jaaksi: A Method for Your First Object-Oriented Project. JOOP - The Journal of Object-Oriented Programming, Januar 1998 Rational software:


Download ppt "Introduction to UML Part 2."

Similar presentations


Ads by Google