260 likes | 491 Views
UML - Part 3. Modeling Element Structural things Behavioral things Grouping things Annotational things Relationships Dependency Association Generalization Realization. 3. Diagram Class diagram Object diagram Use case diagram Sequence diagram Collaboration diagram
E N D
Modeling Element Structural things Behavioral things Grouping things Annotational things Relationships Dependency Association Generalization Realization 3. Diagram Class diagram Object diagram Use case diagram Sequence diagram Collaboration diagram Statechart diagram Activity diagram Component diagram Deployment diagram Building Blocks of the UML
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: ”Awell-formed modelis one that is semantically self-consistent and in harmony with all related models.”
There are 9 types of diagrams inUML Dynamic views Static views Use CaseDiagrams SequenceDiagrams Some part ofthe model might not be visible onany diagram ClassDiagrams CollaborationDiagrams ObjectDiagrams Model ActivityDiagrams ComponentDiagrams StatechartDiagrams DeploymentDiagrams
actor register a person edit a registration/delete a registration include relationship view nextperson ”include” ”include” navigate/viewthe register view previousperson association ”include” User use case system boundary 3.1 Use case diagram
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
3.2 Class Diagram responsible for * 1 Course Person CourseModule name : String description : String name : String email : 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!
A Class DiagramWith Navigation responsible for * 1 Course Person CourseModule name : String description : String name : String imail : String homePage : String tech. responsible for name : String description : String 1 1..* * * 1 1 * * * StudentCourseProfile 1 Student finished : boolean
A Class Diagram - Mapping to Java responsible for * 1 Course Person name : String description : String name : String imail : String homePage : String tech. responsible for 1 * 1 * * StudentCourseProfile 1 Student finished : boolean publicclass Person { protected String name; protected String imail; protected String homePage; // // Navigation protected Course[] responsibleFor; protected Course[] techResponsibleFor; public Person() { } } publicclass Student extends Person { // // Navigation publicStudentCourseProfile[] studentCourseProfile; public Student() { } }
A Class Diagram - Example With Interface <<Interface>> IStorable Register -reg edit() 0..* 0..* write() relization read() public void read(){ Person terminal.print("Name: "); name = terminal.readLine(); edit() ... write() } read() relization/implements Two different representation of nearly the same dependency
3.3 Object Diagram -Capture Instances and Links Class Object Company HiA: Company noOfEmploees=600 noOfEmploees : int Possible object name object class attributewith value
Company 1 1..* LocatedAt Department Office * 1..* Object Diagram with Links Class Diagram Object Diagram Language:Department Gimlemoen: Office :LocatedAt HiA: Company Possibleobject diagram :LocatedAt Grooseveien: Office Engineering :Department Link - A link is an instance of an association,analogous to an object being an instance of a class.
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!
user controllerViewer register <command r> <name,e-mail,..> ”create” person setData(name, ..) insert(person) 3.4 Sequence diagram
1.2: ”create” 1: register() 1.1: data := getData() 1.4: insert(person) 3.5 Collaboration diagram 1.3: setDate(data) user controllerViewer person register
3.6 Statechart diagram StateChart for microwaveoven "control unit"
NotLoaded Running Loaded destroy/destroy() Stopped Statechart for Applet init/init() stop/stop() start/start() start/start()
3.7 Activity diagram -Capture Dynamic Behaviour (Activity-oriented)
Activity diagram -One More Example activity product of activity
Activity diagram - One More Example controller register user person request registration create person (object) supply person-data forward person-data process person-data insert person
applet1.class Demo.html applet2.class logo.gif applet1.java applet2.java 3.8 Component diagram -Captures the Physical Structure of the Implementation
Person.class Register.class Component diagram -One More Example ISortable
”PC” ”PC” ”Server” 3.9 Deployment diagram Extended VLAN ”network” LAN
:html j1:Jsp :html j2:Jsp s1:Servlet browser: :WebServer :ServletContainer s2:Servlet :DB b1:BusinessObject b2:BusinessObject b4:BusinessObject b3:BusinessObject client: Internet Multi-tier Architecture- MVC -view:browser/jsp/servletcontroller:jsp/servletmodel:businessObjects server1: Intranet server2:
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