Presentation is loading. Please wait.

Presentation is loading. Please wait.

Unified Modeling Language (UML)

Similar presentations


Presentation on theme: "Unified Modeling Language (UML)"— Presentation transcript:

1 Unified Modeling Language (UML)

2 UML Graphic modeling language for describing object-oriented software.
Started in 1994 Combined notations from 3 leading OO methods OMT, Object-modeling technique (James Rumbaugh) OOSE, Object-oriented software engineering (Ivar Jacobson) Booch method (Grady Booch)

3 Core UML Diagrams A diagram is the graphical presentation of a set of elements, most often rendered as a connected graph of things and relationships. Use case diagrams Describe functional behavior seen by (external) users Class diagrams Describe static structure of the classes in system

4 Use case diagrams Use Case Diagrams describe the functionality of a system and users of the system, i.e. what a new system should do or what an existing system already does. These diagrams contain the following elements: Actors, which represent users of a system, including human users and other systems. Use Cases, which represent functionality or services provided by a system to users. System boundary Association Actor (People) Actor (Systems) Use Case System

5 An use-cases example Library Supplier Borrow books Return books
Interlibrary loan Circulation Clerk Do research Read books, newspaper Member Purchase supplies Supplier

6 Class diagrams The class diagram is the main building block in object oriented modeling. It represents the static structure of a system, describes how a system is structured rather than how a system behaves. contains the following elements: Classes, which represent entities with common characteristics or features. These features include attributes and operations. Associations, which represent relationships between classes.

7 Basic UML notation for classes
Class name Class name attribute:primitiveDataType or Class attribute: type or Class=default value method ( ) method (argument_list):type or Class Attribute visibility - (private) # (protected) + (public) ~(package) Operations - (private) # (protected) + (public) Basic UML notation for classes

8 Basic UML notation for classes
Example Basic UML notation for classes Class name Transcript +studentName: String +studentID: int +listOfCourseNames: List=null +lilstOfGrades:List=null +GPA: int +setStudentName(String name) +setStudentID(int ID) +addCourseName(String course) +addGrade(Char grade) +calculateAverage(): int +show() Attribute Operations

9 Parameterized classes
type Stack +pop() : <type>

10 Basic Class Relationships
Class A Class with parts Class with parts Class A Superclass Interface name Class B Assembly Class Assembly Class Class B Subclass Concrete Class Association Aggregation Composition Inheritance (Generalization) Dependency Realization

11 Associations A link between two classes
Typically modeled as a member reference A Person works for a Company multiplicity Role names employee employer Person Company 0..* 1 works for Association Name Role names and multiplicity at association ends Direction arrow to aid reading of association name

12 Recursive Association
Person Node Connects married to

13 Aggregation A special form of association that models a whole-part relationship between an aggregate (the whole) and its parts. Models a “is a part-part of” relationship. multiplicity 4 Car Wheel wheels Whole Part

14 Composition A strong form of aggregation
The whole is the sole owner of its part The part object may belong to only one whole Multiplicity on the whole side must be one The life time of the part is dependent upon the whole The composite must manage the creation and destruction of its parts multiplicity Line Point 3..* 2 Polygon

15 Dependency A dependency indicates a semantic relation between two or more classes in which a change in one may force changes in the other although there is no explicit association between them A stereotype may be used to denote the type of the dependency Iterator Vector

16 Generalization Indicates that objects of the specialized class (subclass) are substitutable for objects of the generalized class (super-class) “is a” relationship Shape Super Class May be an abstract class Generalization relationship Sub Class Circle

17 Generalization conti. A sub-class inherits from its super-class
Attributes Operations Relationships A sub-class may Add attributes and operations Add relationships Refine (override) inherited operations

18 <<interface>> List
Realization A realization relationship indicates that one class implements a behavior specified by another class (an interface or abstract class). An interface can be realized by many classes. A class may realize many interfaces. LinkedList <<interface>> List LinkedList List

19 Basic Class Diagram (Example)
Person Head Arm Class Student takes

20 Example: Class Diagram
Student Transcript Course * Transcript studentName studentID listOfCourseNames lilstOfGrades average setStudentName() setStudentID() addCourseName() addGrade() calculateAverage() show() Student studentName studentID listOfCoursesID transcript:Transcript setStudentName() getStudentName() setStudentID() getStudentID() addToListofCourseIDs() makeTranscript() Course courseName courseID grade readCourseData() readCourseGrade() setCourseID()

21 UML Class Diagrams  Java Code
Different representations of the same information Name, state, behavior of class Relationship(s) between classes Should be able to derive one from the other Motivation UML  Java Implement code based on design written in UML Java  UML Create UML to document design of existing code

22 Java  UML: Clock Example
Java class Clock // name { // fields, members int seconds; int minutes; int hours; // methods void start(); void adjustTime(); void reset(); } Name Attributes Operations Class diagram Java code

23 Two basic relationships of Java classes
class A { …. } class B { A x = new A(); } Class B has-a class A. class A { …. } class B extends/implements A { } Class B is-a class A. Relationships association, aggregation and dependency are has-a relationships. Generalization and realization are is-a relationships.

24 UML Packages A package is a general purpose grouping mechanism.
Can be used to group any UML element (e.g. use case, actors, classes, components and other packages. Commonly used for specifying the logical distribution of classes. Name

25 Packages and Class Diagrams
Add package information to class diagrams b a b.a a.A b.b.D b.b.E b.a.F b.a.G a.C a.B b.b

26 Homework A B C D E F In the following questions fill in is-a or has-a.
Class D ______ class A. Class D ______ class E. Class E ______ class B. Class E ______ class C. Class F ______ class E.


Download ppt "Unified Modeling Language (UML)"

Similar presentations


Ads by Google