OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  1998-1999 Rational Software, all rights reserved 1 Building Analysis Classes.

Slides:



Advertisements
Similar presentations
Writing Good Use Cases - Instructor Notes
Advertisements

OOAD – Dr. A. Alghamdi Mastering Object-Oriented Analysis and Design with UML Module 3: Requirements Overview Module 3 - Requirements Overview.
Introduction to Rational Rose 2000 v6.5 Copyright © 1999 Rational Software, all rights reserved 1 Rational Rose 2000 Interaction Diagrams.
1 Generalizations Multiple Inheritance (finishing up Class Design) Class Design – Another Look – Part 11.
OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 1/20 Interaction Diagrams.
OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 1/18 Use Case Analysis – continued Control Classes.
UML Class Diagram. UML Class Diagrams2 Agenda What is a Class Diagram? Essential Elements of a UML Class Diagram Tips.
Use Case Diagram © copyright 2001 SNU OOPSLA Lab..
Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page: Lecture.
UML Class Diagram and Packages Written by Zvika Gutterman Adam Carmi.
Essentials of class models. 2 A very simple class model In UML, a class is shown in a class diagram as a rectangle giving its name.
J. Scott Hawker p. 1 Material © IBM Rational Software Use-Case Analysis Analyze the requirements to discover what the system objects are These.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
© 2005 Prentice Hall4-1 Stumpf and Teague Object-Oriented Systems Analysis and Design with UML.
OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 1 Interaction Diagrams.
Page 1  Copyright © 1997 by Rational Software Corporation Class Diagrams A class diagram shows the existence of classes and their relationships in the.
Sharif University of Technology1 Design and Use-case Realization Software Engineering Laboratory Fall 2006.
Use Case Analysis – continued
1 Business Models Modeling. 2 Why Model the Business Business modeling is a technique to help answer critical questions, such as: What do the workers.
PRJ566: PROJECT PLANNING AND MANAGEMENT Class Diagrams.
UML Class Diagrams: Basic Concepts. Objects –The purpose of class modeling is to describe objects. –An object is a concept, abstraction or thing that.
The Unified Modeling Language (UML) Class Diagrams.
OOAD – Dr. A. Alghamdi Mastering Object-Oriented Analysis and Design with UML Module 6: Use-Case Analysis Module 6 - Use-Case Analysis.
CSE314 Database Systems Data Modeling Using the Entity- Relationship (ER) Model Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson Ed Slide Set.
1 CSc 131 Computer Software Engineering Fall 2012 Lecture # 7 Object-Oriented Design & UML Class Models.
Page 1 What is the UML? UML stands for Unified Modeling Language The UML combines the best of the best from – Data Modeling concepts (Entity Relationship.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Copyright 2002 Prentice-Hall, Inc. Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich Chapter 20 Object-Oriented.
Presented by: CHAN LAI SAN ( ) REBAH DAW SARREB ( ) FIDA AL-OBAISI ( ) 08 April 2008 (Tuesday 6pm – 7:30pm)
UML Diagrams: Class Diagrams The Static Analysis Model Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
Solid Palette Gradient Palette I Gradient Palette II APPLYING THESE COLORS Click on the desired color Click on the paintbrush tool located.
Page 1  Copyright © 1997 by Rational Software Corporation Computer System Business Process Order Item Ship via “ Modeling captures essential parts of.
Requirements Artifacts Precursor to A & D. Objectives: Requirements Overview  Understand the basic Requirements concepts and how they affect Analysis.
Requirements Analysis Visual Modeling] Lab 02 Visual Modeling (from Visual Modeling with Rational Rose and UML) A way of thinking about problems using.
CSC 395 – Software Engineering Lecture 13: Object-Oriented Analysis –or– Let the Pain Begin (At Least I’m Honest!)
CS3773 Software Engineering Lecture 04 UML Class Diagram.
Requirements as Usecases Capturing the REQUIREMENT ANALYSIS DESIGN IMPLEMENTATION TEST.
Introduction to Rational Rose 2000 v6.5 Copyright © 1999 Rational Software, all rights reserved 1 Rational Rose 2000 Class Diagrams.
® IBM Software Group © 2006 IBM Corporation Rational Software France Object-Oriented Analysis and Design with UML2 and Rational Software Modeler 03. Classes,
The Static Analysis Model Class Diagrams Prof. Hany H. Ammar, CSEE, WVU, and Dept. of Computer Science, Faculty of Computers and Information, Cairo University.
1 CMPT 275 Software Engineering Requirements Analysis Phase Requirements Analysis activity Janice Regan,
1 IBM Software Group ® Mastering Object-Oriented Analysis and Design with UML 2.0 Module 6: Use-Case Analysis.
Class diagram Used for describing structure and behaviour in the use cases Provide a conceptual model of the system in terms of entities and their relationships.
A Use Case Primer 1. The Benefits of Use Cases  Compared to traditional methods, use cases are easy to write and to read.  Use cases force the developers.
UML Class Diagram Trisha Cummings. What we will be covering What is a Class Diagram? Essential Elements of a UML Class Diagram UML Packages Logical Distribution.
Discovering object interaction. Use case realisation The USE CASE diagram presents an outside view of the system. The functionality of the use case is.
What is a Structural Model?
Lecture 1: UML Class Diagram September 12, UML Class Diagrams2 What is a Class Diagram? A class diagram describes the types of objects in the system.
Use Case Diagram The purpose is to communicate the system’s functionality and behaviour to the customer or end user. Mainly used for capturing user requirements.
1 The Unified Modeling Language. 2 The Unified Modeling Language (UML) is a standard language for writing software blueprints. The UML may be used to.
ASU Course Registration System System Analysis Communication Diagram Use Case: Select Courses to Teach.
Design Model Lecture p6 T120B pavasario sem.
Object Oriented Analysis: Associations. 2 Object Oriented Modeling BUAD/American University Class Relationships u Classes have relationships between each.
1 IBM Software Group ® Essentials of Visual Modeling with UML 2.0 Module 5: Interaction Diagrams.
CS212: Object Oriented Analysis and Design Lecture 33: Class and Sequence Diagram.
UML Class Diagram notation Indicating relationships between classes SE-2030 Dr. Mark L. Hornick 1.
Page 1  Copyright © 1997 by Rational Software Corporation Putting the UML to Work The ESU University wants to computerize their registration system –
Object Oriented Analysis and Design using the UML Use-Case Analysis Adapted by Dr. Spiegel from Slides Provided by Rational Software.
Analysis Yaodong Bi. Introduction to Analysis Purposes of Analysis – Resolve issues related to interference, concurrency, and conflicts among use cases.
ITEC0724 Modern Related Technology on Mobile Devices Lecture Notes #2 1.
Class Diagram Lecture # 1. Class diagram A Class Diagram is a diagram describing the structure of a system shows the system's classes Attributes operations.
Kyung Hee University Class Diagramming Notation OOSD 담당조교 석사과정 이정환.
OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 1 Use Case Analysis – continued Control Classes.
OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 1 Use Case Analysis – Part 4 Analysis Mechanisms.
Entity-Relationship Modeling
UML SEQUENCE AND CLASS DIAGRAMS
The Unified Modeling Language
UML Class Diagram.
Understand and Use Object Oriented Methods
Use Case Analysis – continued
Presentation transcript:

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 1 Building Analysis Classes

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 2  Supplement the Use-Case Descriptions  For each use-case realization  Find Classes from Use-Case Behavior  Distribute Use-Case Behavior to Classes  For each resulting analysis class  Describe Responsibilities  Describe Attributes and Associations  Qualify Analysis Mechanisms  Unify Analysis Classes  Checkpoints Use-Case Analysis Steps

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 3 So, where are we…Describe Responsibilities  At this point, analysis classes have been identified and use-case responsibilities have been allocated to those classes.  This was done on a use-case-by-use-case basis, with a focus primarily on the use-case flows of events.  The fact is: a class and its objects often participate in several use-case realizations.  It is important to coordinate all the requirements on a class and its objects that different use-case realizations may have.

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 4 So, where are we…Describe Responsibilities  The ultimate objective of these class-focused activities is to to document what the class knows and what the class does.  The resulting Analysis Model gives you a big picture and a visual idea of the way responsibilities are allocated and what such an allocation does to the class collaborations.  Such a view allows the analyst to spot inconsistencies in the way certain classes are treated in the system, for example, how boundary and control classes are used.  The purpose of “Describe Responsibilities” step is namely to describe the responsibilities of the analysis classes.

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 5 // PerformResponsibility :Client:Supplier Supplier // PerformResponsibility Interaction Diagram Class Diagram Describe Responsibilities  What are responsibilities? (something that an object can be asked to provide…) How do I find them? (Responsibilities (in Analysis -> one or more Operations in Design) Objects can perform actions; Objects have knowledge that can be provided to other objects.

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 6 // PerformResponsibility :Client:Supplier Supplier // PerformResponsibility Interaction Diagram Class Diagram Describe Responsibilities  Responsibilities are derived from messages on interaction diagrams. For each message, examine the class of the object to which the message is sent. If the responsibility does not yet exist, create a new responsibility that provides the requested behavior.. Some responsibilities come from non-functional requirements. When a new responsibility is created, check the non-functional requirements to see if there are related requirements which apply. Either augment the description of the responsibility or create a new responsibility to reflect this.

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 7 // PerformResponsibility :Client:Supplier Supplier // PerformResponsibility Interaction Diagram Class Diagram Describe Responsibilities  There are a couple of ways that Analysis Class responsibilities can be documented.  We will use the convention //Analysis Operation  (We know this will change into Operations in Design..

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 8 RegisterForCoursesForm // submit schedule() // display course offerings() // display schedule() // create schedule() // select 4 primary and 2 alternate offerings() // display blank schedule() > PrimaryScheduleOfferingInfo grade // is enrolled in?() // mark as enrolled in() > CourseCatalogSystem // get course offerings() >RegistrationController // get course offerings() // submit schedule() // create schedule with offerings() > Student // add schedule() // has pre-requisites() > ScheduleOfferingInfo status // mark as selected() // mark as cancelled() // is selected?() > CourseOffering number : String = "100" startTime : Time endTime : Time days : Enum // add student() // still open?() // save() > Schedule // create with offerings() // submit() // save() > Example: View of Participating Classes (VOPC) Class Diagram The VOPC class diagram contains classes whose instances participate in the use case realization interaction diagrams, as well as relationships required to support the interactions. Relationships: later. But now, interested in identified classes and responsibilities allocated to them.

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 9 VOPC – more on last slide…  The generalization relationship has been shown because it is important to understand the relationship between the two new classes, ScheduleOfferingInfo and PrimaryScheduleOfferingInfo.  The PrimaryScheduleOfferingInfo class contains information about a primary CourseOffering that is schedule-specific.  For example, the grade the student received in the CourseOffering, as well as the status of the CourseOffering on the Schedule (e.g., has the CourseOffering been enrolled in yet, or has it just been selected on the Schedule).  The ScheduleOfferingInfo class was created because status will need to be maintained for alternate CourseOfferings, as well as primary CourseOfferings, with the only difference being that Students can only be enrolled in and receive a grade in a primary CourseOffering.  Thus, generalization was used to model the commonality amongst the different types of CourseOffering information.

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 10 Maintaining Consistency: What to Look For  In order of criticality  Redundant responsibilities across classes May combine; update interaction diagrams.  Disjoint responsibilities within classes May need to split the object into two classes. Then, need to update the interaction diagram  Class with one responsibility – no problem; but is it really needed?  Class with no responsibilities  Better distribution of behavior may be warranted.  Easier to change things now, but don’t get hung up on trying to optimize the class interactions.

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 11  Supplement the Use-Case Descriptions  For each use-case realization  Find Classes from Use-Case Behavior  Distribute Use-Case Behavior to Classes  For each resulting analysis class  Describe Responsibilities  Describe Attributes and Associations: Identify the other classes on which the analysis class depends Define the events in other analysis classes that the class must know about Define the information that the analysis class is responsible for maintaining.  Qualify Analysis Mechanisms  Unify Analysis Classes  Checkpoints Use-Case Analysis Steps

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 12 Describe Attributes and Associations  To carry out responsibilities, classes frequently depend on other classes to supply needed behavior.  Associations document inter-class dependencies and help us understand class coupling;  Careful coupling can help us build better, more resilient systems.  So let’s:  Define Attributes  Establish Aggregations and Associations

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 13 Attributes  Attributes are used to store information.  Attributes are atomic things with no responsibilities.  The attribute name should be a noun that clearly states what information the attribute holds.  The attribute description should describe what information is to be stored in the attribute.  During analysis, the attribute types should be from the domain, and not adapted to the programming language in use

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 14 ClassName > Attribute : Type = InitValue CourseOffering > number :String=“100” startTime : Time endTime: Time days: enum attribute In analysis, do not spend time on attribute signatures Review: What is an Attribute? enum will need to be replaced with a true enumeration that describes the days the CourseOffering is offered (e.g., MWF, TR, etc.).

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 15 Finding Attributes 1 of 2  Sources of possible attributes:  Domain knowledge  Requirements  Glossary  Domain model  Business model, etc.  Properties/characteristics of identified classes  Information retained by identified classes  “Nouns” that did not become classes  Information whose value is the important thing  Information that is uniquely "owned” by an object  Information that has no behavior  Information accessed by operations, which only get, set, or perform simple transformations on the data.

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 16 Finding Attributes 2 of 2  Information has complex behavior or is shared by two or more objects  Model information as a separate class.  Attributes are domain dependent  Remember, the process is use-case-driven.  all discovered attributes should support at least one use case.

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 17 Review: What is an Association?  Models a semantic connection among instances of different classes Simple association > Student > Schedule > CourseOffering Reflexive association is a pre-requisite of > Course Association is a structural relationship between objects of different classes; information that must be preserved for some duration and not simply procedural dependency. (one object has a permanent association to another object.)

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 18 Associations – simple; ternary; recursive  You can use associations to show that objects know about other objects.  Sometimes, objects must hold references to each other to be able to interact, for example send messages to each other  Most associations are simple (exist between exactly two classes), and are drawn as solid paths.  Ternary relationships are also possible.  Sometimes, a class has an association to itself.  This does not necessarily mean that an instance of that class has an association to itself; more often, it means that one instance of the class has associations to other instances of the same class.

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 19 Associations – Naming them  May have name placed on, or adjacent to the association path.  The name of the association should reflect the purpose of the relationship and be a verb phrase  Can be omitted, particularly if role names are used (see next slide).  Avoid names like "has" and "contains", as they add no information about what the relationships are between the classes.

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 20 Review: What are Roles?  Each end of an association is a role specifying the face that a class plays in the association.  Each role must have a name; a noun that indicates the associated object’s role in the relation to the associating object. Pre-requisites Instructor > CourseOffering Department head > Professor > Department > Course Role Name

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 21 Roles - more  Use of association names and role names is mutually exclusive  Decide which conveys more information.  The role name is placed next to the end of the association line of the class it describes.  In the case of self-associations, role names are essential to distinguish the purpose for the association. (see ‘prerequisites’)  In the previous example, the Professor participates in two separate association relationships, playing a different role in each.

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 22 Multiple Associations  Can have these between the same two classes, but be careful that they are indeed two separate relationships.  Should not be for invoking separate operations  If > one association between two classes, then they MUST be named.  It is unusual to find more than one association between the same two classes.  Occurrences of multiple associations should be carefully examined.

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 23 CourseOffering > Schedule > primaryCourses Can see two roles here! Here (invalid) the two relationships represent two operations of Course Offerings, not two roles of CourseOffering. alternateCourses - two kinds of offerings! CourseOffering > Schedule > add student to remove student from Multiple associations must reflect multiple roles Example: Multiple Associations

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 24 Review: Multiplicity * 0..* 1 *  Unspecified  Exactly one  Zero or more (many, unlimited)  One or more  Zero or one (optional scalar role)  Specified range  Multiple, disjoint ranges 2, 4..6

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 25 Multiplicity primaryCourses alternateCourses 0..* 1 > Student > Schedule > CourseOffering Example: Multiplicity A Student can have zero or more Schedules. It is zero when the Student has not registered for any course offerings yet. It is more than one because the system retains schedules for multiple semesters. A Schedule is only associated with one Student A Schedule can contain up to four primary course offerings and two alternate courses A CourseOffering can appear on any number of Schedules, as either a primary or alternative course A CourseOffering does not have to appear on any Schedule. Remember, Students and CourseOfferings are related via the Schedule class. Students are enrolled in a CourseOffering if there is a relationship between the Student’s Schedule and the CourseOffering.

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 26 Bi-directional Uni-directional Class1Class2Class1Class2 Review: Navigability  Possible to navigate from an associating class to the target class – indicated by arrow which is placed on the target end of the association line next to the target class (the one being navigated to).  Associations are bi-directional by default – suppress arrows.  Arrows only drawn for associations with one-way navigability. Navigability is inherently a design and implementation property. Can be specified in Analysis, but with expectation of refining in Class Design. In analysis, associations are usually bi-directional; design, we really check this.

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 27 2-way navigation primaryCourses alternateCourses 0..* > Schedule > CourseOffering 1-way navigation 1 1 > RegisterForCoursesForm > RegistrationController Example: Navigability A RegisterForCoursesForm invokes a single RegistrationController that will process the registration for the current Student. The RegistrationController will never need to communicate directly to the RegisterForCoursesForm. Here, two way. You can ask a Schedule what Course Offerings it contains and you can ask a Course Offering what Schedules it appears on.

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 28 Whole/aggregatepart primaryCourses alternateCourses 0..* 1 > Student > Schedule > CourseOffering Review: What is Aggregation?  A special form of association that models a whole-part relationship between an aggregate (the whole) and its parts An aggregation is a stronger form of association which is used to model a whole-part Relationship between model elements. Use a hollow diamond to indicate aggregate. Since aggregation is a special form of association, the use of multiplicity, roles, navigation, etc. is the same as for association.

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 29 Aggregation - more  Sometimes, a class may be aggregated with itself - means that one instance if the class is an aggregate composed of other instances of the same class. Whole/aggregatepart primaryCourses alternateCourses 0..* 1 > Student > Schedule > CourseOffering

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 30 Aggregation – still more Whole/aggregatepart primaryCourses alternateCourses 0..* 1 > Student > Schedule > CourseOffering In the above example, the relationship from Student to Schedule is modeled as an aggregation because a Schedule is inherently tied to a particular Student. A Schedule outside of the context of a Student makes no sense in this Course Registration System. The relationship from Schedule to CourseOffering is an association because CourseOfferings may appear on multiple Schedules.

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 31 Aggregation – where used:  An object is physically composed of other objects (e.g. car being physically composed of an engine and four wheels).  An object is a logical collection of other objects (e.g., a family is a collection of parents and children).  An object physically contains other objects (e.g., an airplane physically contains a pilot).

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 32 When in doubt use association association aggregation Class1Class2Class1Class2 Association or Aggregation?  Consideration  Context, independent identity of Class2

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 33 Association or Aggregation?  Aggregation should be used only where the "parts" are incomplete outside the context of the whole.  If the classes can have independent identity outside the context provided by other classes, if they are not parts of some greater whole, then the association relationship should be used.  When in doubt, an association is more appropriate.  Aggregations are generally obvious.  A good aggregate should be a natural, coherent part of the model.  The meaning of aggregates should be simple to understand from the context.  Choosing aggregation is only done to help clarify, it is not something that is crucial to the success of the modeling effort.

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 34 Association or Aggregation?  The use of aggregation versus association is dependent on the application you are developing.  If you are modeling a car dealership, the relationship between a car and its wheels might be modeled as aggregation because the car always comes with wheels and the wheels are never sold separately.  If you are modeling a car parts store, you might model the relationship as an association, as the car (the body) might be independent of the wheels.

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 35 Association Class  A class “attached” to an association  Contains properties of the relationship  One instance per link  Full-fledged class!  Allows you to store information about the relationship itself, where the info is not appropriate (does not belong to) within the classes at either end of the relationship. ScheduleOfferingInfo status // mark as selected() // mark as cancelled() // is selected?() > CourseOffering > Schedule > 0..* 0..4 primaryCourses alternateCourses 0..*0..2 PrimaryScheduleOfferingInfob grade // is enrolled in?() // mark as enrolled in() // mark as committed() >

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 36 Association Classes:  There is an instance of the association class for every instance of the relationship (e.g., for every link).  In many cases, association classes are used to resolve many-to-many relationships, as shown in the example.

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 37 Association Classes: Many to many relations  In this case, a Schedule includes multiple primary CourseOfferings and a CourseOffering can appear on multiple schedules as a primary.  Where would a Student’s grade for a primary CourseOffering “live”?  It cannot be stored in Schedule because a Schedule contains multiple primary CourseOfferings.  It cannot be stored in CourseOffering because the same CourseOffering can appear on multiple Schedules as primary.  Grade is really an attribute of the relationship between a Schedule and a primary CourseOffering.

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 38 Association Classes: Many to many relations  The same is true of the status of a CourseOffering, primary or alternate, on a particular Schedule.  Thus, association classes were created to contain such information.  Two classes related by generalization were created to leverage the similarities between what must be maintained for primary and alternate CourseOfferings.  Remember, Students can only enroll in and receive a grade in a primary CourseOffering, not an alternate.

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 39 1: PerformResponsibility Link Association Collaboration Diagram Class Diagram 0..* Prime suppliers 0..* Client Supplier :Client:Supplier Client Supplier PerformResponsibility() Relationship for every link! Finding Relationships To find relationships, start studying the links in the collaboration diagrams. Links between classes indicate that objects of the two classes need to communicate with one another to perform the use case. Thus, an association or an aggregation is needed between the associated classes

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 40 Finding Relationships - more  Reflexive links do not need to be instances of reflexive relationships.  An object can send messages to itself.  A reflexive relationship is needed when two different objects of the same class need to communicate.  The navigability of the relationship should support the required message direction.  In the above example, if navigability was not defined from the Client to the Supplier, then the PerformResponsibility message could not be sent from the Client to the Supplier.  Focus only on associations needed to realize the use cases; don't add association you think "might" exist unless they are required based on the interaction diagrams

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 41 Finding Relationships - more  Remember to give the associations role names and multiplicities.  You can also specify navigability, though this will be refined in Class Design.  Write a brief description of the association to indicate how the association is used, or what relationships the association represents.  This is easy to do in Rose (Open Specification box)