DOC PREVIEW
SJSU CMPE 196G - Relationships
Pages 43

This preview shows page 1-2-3-20-21-22-41-42-43 out of 43 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 43 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 43 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 43 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 43 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 43 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 43 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 43 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 43 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 43 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 43 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Software Patterns Dr M E Fayad Professor Computer Engineering Department Room 283I College of Engineering San Jos State University One Washington Square San Jos CA 95192 0180 http www engr sjsu edu fayad 2003 SJSU CmpE L4 S1 Relationships Lesson 04 Relationships 2 2003 SJSU CmpE M E Fayad L4 S2 Relationships Lesson Objectives Objectives Discuss UML Associations Discuss UML aggregation Understand UML inheritance Understand How to identify UML Artifacts 3 2003 SJSU CmpE M E Fayad L4 S3 Relationships Relationships A relationship is a connection among things Three most important relationships in OO dependencies generalizations associations Different kind of lines are used to distinguish various kinds of relationships 2003 SJSU CmpE M E Fayad 4 L4 S4 Relationships Dependencies 1 Dependencies are using relationships State that a change in specification of one thing the supplier may affect another thing that uses it the client but not necessary the reverse Graphically it is rendered as a dashed directed line 5 2003 SJSU CmpE M E Fayad L4 S5 Relationships Dependencies 2 Dependent Class Independent Class Client Supplier Order Book 2003 SJSU CmpE M E Fayad L4 S6 6 Relationships Associations 1 An association shows a two way relationship between objects instances of two or more classes and requiring special implementation to ensure integrity A particular instance of an association is often called a link Associations between classes are required if the objects need to communicate Associations are often named and have role names for each side of the link 2003 7 SJSU CmpE M E Fayad L4 S7 Relationships Types of Association Unary association both ends of an association circle back to the same class Binary association an association that connects exactly two classes N ary association an association that connects more than two classes 8 2003 SJSU CmpE M E Fayad L4 S8 Relationships Associations 2 Name an association can have a name and the name is used to describe the nature of the relationship Role when a class participates in an association it has a specific role that it plays in that relationship a role is just the face the class at the near end of the association presents to the class at the other end of the association 9 2003 SJSU CmpE M E Fayad L4 S9 Relationships Associations 3 Association Name Car model year of doors Vehicle Registration registeredCar owner Person name age address Roles Names 10 2003 SJSU CmpE M E Fayad L4 S10 Relationships Associations 4 Multiplicity Name Person 1 Owns by employee employer 11 Role Name 2003 Company SJSU CmpE M E Fayad L4 S11 Relationships More on Associations Simple example Window displays 0 GeomFigure An association has a name and a numerical specification multiplicity indication of how many objects on one side of the association are connected with how many objects on the other side Associations are called use relationships even if this may seem somewhat cheeky in the example below Company employs Employer 2003 0 Person Employee SJSU CmpE M E Fayad L4 S12 12 Relationships More on Associations Associations are directed one way bidirectional and undirected UML makes no distinction between bidirectional and undirected associations Multiplicity Stereotype RelationName Constraints Class1 role1 2003 Role2 interface SJSU CmpE M E Fayad Class2 L4 S13 13 Relationships More on Associations 2003 Recursive association A class has a relation with itself It is also possible to model associations that are valid only temporarily stereotype or temporary Constraints may be used to restrict the relation under specific aspects A role name describes how the object is seen by the opposite object in the association An association can be described in more detail by means of constraints tagged values and stereotypes Stereotypes are noted before or above the relation name constraints and tagged values after or below the name SJSU CmpE M E Fayad L4 S14 14 Relationships More on Associations Directed association is a one way association in which one side knows the other but not vice versa Multiplicity Specification 1 exactly one 0 1 zero or one 0 4 between zero and four 3 7 either three or seven 15 2003 SJSU CmpE M E Fayad L4 S15 Relationships More on Associations More multiplicity specifications 0 greater than or equal to zero default ditto 1 greater than or equal to one 0 3 7 9 between zero and three or exactly seven or greater than or equal to nine 16 2003 SJSU CmpE M E Fayad L4 S16 Relationships More Multiplicities Multiplicity how many objects may be connected across an instance of an association can be a range of values or an explicit value 2003 exactly one 1 zero or one optional 0 1 zero or more many 0 one or more mandatory numerically specified m n SJSU CmpE M E Fayad 1 17 L4 S17 Relationships More on Associations Recursive associations are associations in which one class is involved has Patient Employee name staffNo roomNo manager office clerk relative 1 Person leads 18 reports to 2003 SJSU CmpE M E Fayad L4 S18 Relationships N ary Association An n ary association is like a common binary association except that more than two association roles involved in it N ary association Class1 Class2 Ternary association Class3 2003 SJSU CmpE M E Fayad L4 S19 19 Relationships More on n ary Association Reservation Train date trainNo 1 1 Seat carriageNo seatNo 1 Passenger name title 2003 SJSU CmpE M E Fayad Ternary association L4 S20 20 Relationships More on Associations Recursive Associations N ary Associations Attributed Associations Association Class Association Constraints Qualified Associations Derived Associations Directed Associations Ordered Associations Realization Refinements Dependency 2003 SJSU CmpE M E Fayad L4 S21 21 Relationships More on Associations Associations are usually bidirectional Allows each object involved in the relationship to refer to the object to which it is related Bidirectional association means at the relationship has an inverse Associations do not have to be bidirectional 2003 SJSU CmpE M E Fayad L4 S22 22 Relationships Man husband Screen Woman Marriage Windows wife Association Type One to One Window One to Many One to Zero or More Nets Authorization User Many to Many Car 2003 Trailer SJSU CmpE M E Fayad Zero or One L4 S23 23 Relationships Square Line Sides Association Type Specified the of instances on the many side Secure Room Male Person Occupants TraditionalFamily father Female mother Specify the possible of instances using or Ternary relationship


View Full Document

SJSU CMPE 196G - Relationships

Download Relationships
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Relationships and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Relationships 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?