UML Part 3 1 Building Blocks of the
UML - Part 3 1
Building Blocks of the UML 1. Modeling Element 1. 2. 3. 4. Structural things Behavioral things Grouping things Annotational things 2. Relationships 1. 2. 3. 4. Dependency Association Generalization Realization 3. Diagram 1. 2. 3. 4. 5. 6. 7. 8. 9. Class diagram Object diagram Use case diagram Sequence diagram Collaboration diagram Statechart diagram Activity diagram Component diagram Deployment diagram 2
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. ” 3
There are 9 types of diagrams in UML Dynamic views Sequence Diagrams Collaboration Diagrams Activity Diagrams Statechart Diagrams Static views Use Case Diagrams Some part of the model might not be visible on any diagram Class Diagrams Object Diagrams Model Component Diagrams Deployment Diagrams 4
3. 1 Use case diagram actor register a person edit a registration/ delete a registration User association use case ”include” navigate/view the register include relationship ”include” view next person ”include” view previous person system boundary 5
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 6
3. 2 Class Diagram Person name : String email : String home. Page : String 1 responsible for 1 tech. responsible for * Course : String * name description : String Course. Module * 1. . * name : String description : String 1 1 Student 1 * * Student. Course. Profile * finished : boolean When a student register for course a Student. Course. Profile object will be made! 7
A Class Diagram With Navigation 1 Person responsible for name : String 1 tech. responsible for imail : String home. Page : String * Course : String * name description : String Course. Module : String * 1. . * name description : String 1 1 * Student. Course. Profile * finished : boolean 8
A Class Diagram - Mapping to Java 1 Person responsible for name : String 1 tech. responsible for imail : String home. Page : String * Course : String * name description : String 1 Student 1 public class Person { protected String name; protected String imail; protected String home. Page; // // Navigation protected Course[] responsible. For; protected Course[] tech. Responsible. For; public Person() { } } * * Student. Course. Profile finished : boolean public class Student extends Person { // // Navigation public Student. Course. Profile[] student. Course. Profile; public Student() { } } 9
A Class Diagram - Example With Interface <<Interface>> IStorable Register -reg 0. . * relization public void read(){ terminal. print("Name: "); name = terminal. read. Line(); . . . } edit() write() read() Person edit() write() read() relization/implements Two different representation of nearly the same dependency 10
A Class Diagram One More Example With Interface 11
3. 3 Object Diagram Capture Instances and Links Class Company no. Of. Emploees : int Object Hi. A: Company no. Of. Emploees=600 Possible object name attribute with value object class 12
Object Diagram with Links Class Diagram Company Object Diagram Language: : Located. At Department Gimlemoen: Office 1 1. . * Located. At Department Office * 1. . * Hi. A: Company Possible object diagram Engineering : Department : Located. At Grooseveien: Office Link - A link is an instance of an association, analogous to an object being an instance of a class. 13
Object diagram and 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! 14
3. 4 Sequence diagram user controller. Viewer register <command r> <name, e-mail, . . > ”create” person set. Data(name, . . ) insert(person) 15
3. 5 Collaboration diagram 1. 2: ”create” 1. 3: set. Date(data) 1: register() user controller. Viewer person 1. 1: data : = get. Data() 1. 4: insert(person) register 16
3. 6 Statechart diagram State. Chart for microwave oven "control unit" 17
Statechart for Applet Not Loaded init/init() Running Loaded start stop/ stop() /start() destroy/destroy() start/start() Stopped 18
3. 7 Activity diagram Capture Dynamic Behaviour (Activity-oriented) 19
Activity diagram One More Example activity product of activity 20
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 21
3. 8 Component diagram Captures the Physical Structure of the Implementation Demo. html applet 1. class applet 1. java applet 2. class applet 2. java logo. gif 22
Component diagram One More Example Person. class Register. class ISortable 23
3. 9 Deployment diagram Extended VLAN ”Server” ”network” LAN ”PC” 24
client: browser: Internet Multi-tier Architecture - MVC - server 1: : Web. Server : html view: browser/jsp/servlet controller: jsp/servlet model: business. Objects : Servlet. Container s 1: Servlet s 2: Servlet b 1: Business. Object j 1: Jsp j 2: Jsp Intranet b 3: Business. Object b 2: Business. Object : DB b 4: Business. Object server 2: 25
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: http: //www. rational. com/uml/documentation. html 26
- Slides: 26