Requirements Analysis 15.1 Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved INFO2005 Requirements Analysis Specialised Associations: Roles, Qualifiers, Aggregation, Composition & Inheritance Department of Information Systems
Requirements Analysis 15.2 Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved Learning Objectives Understand significance of, and notation for: v Navigability v Roles and Qualifiers v Aggregation v Composition v Inheritance v Self-association
Requirements Analysis 15.3 Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved Association Navigability v Associations are normally read left to right, but not always possible to draw neatly v Navigability arrows show which way to read an association label v A module is not enrolled on a student! a:StudentINFO2005:Module EnrolledOn
Requirements Analysis 15.4 Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved Association Navigability v In design, navigability has another meaning v This is not usually an issue in analysis
Requirements Analysis 15.5 Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved Class Roles v Roles help clarify v Only employees a:Vehiclean:Employee 1..*0..1 IsAssigned driver an:Employee 1..*0..1IsAssigned a:Vehicle
Requirements Analysis 15.6 Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved Class Roles v A common role v Every manager a:TeamMembera:Manager 1..*0..1 Supervises a:TeamMembera:Manager 1..*0..1 Supervises team leader
Requirements Analysis 15.7 Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved Class Roles v An object can play a:Manager a:TeamMember 1..*0..1 Supervises team leader driver 1..* 0..1 IsAssigned a:Vehicle
Requirements Analysis 15.8 Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved Association Qualifiers v Superficially similar to roles, qualifiers are actually quite different v A qualifier identifies the subset of objects that link to another object: “[It] distinguishes the set of objects at the far end of an association based on the qualifier value” Larman, 1998
Requirements Analysis 15.9 Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved Association Qualifiers Product Specification Catalogue 1..*1Contains productCode description Product Specification Catalogue 11 Contains productCode v Note the change of multiplicity v From unspecified many down to exactly one v A catalogue contains product specs v How do they relate?
Requirements Analysis Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved Association Qualifiers v Qualifiers are generally more useful in design than in analysis v But they can also sometimes help to clarify our understanding of the domain
Requirements Analysis Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved Aggregation v A special form of association v Models Whole-Part relationships v Aggregate (whole) may delegate some responsibilities to its parts v Parts are encapsulated v Aggregate (usually) presents the sole interface to other bits of the model
Requirements Analysis Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved Aggregation v The Rational people say that aggregation expresses: –Physical containment, e.g. car + passengers... –Physical composition, e.g. car + engine, body, wheels... –Conceptual collection, e.g family + mother, father, daughter… Jacobson et al, 1999
Requirements Analysis Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved UML Notation: Aggregation v Physical containment: Airspace Stacking Queue 1..n 1 * 1 Passenger Flight 0..n 1
Requirements Analysis Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved UML Notation: Aggregation Car Whole Part Aggregate Engine Wheels Body Components v Physical composition:
Requirements Analysis Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved UML Notation: Aggregation v Conceptual collection: Analysis Package * Use Case Realisation Analysis Class * * v Note the new notation for package v Analysis packages often become distinct subsystems in the software Adapted from Jacobson et al, 1999
Requirements Analysis Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved Composition v A strong form of aggregation:
Requirements Analysis Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved UML Notation:Composition Car Engine Wheels Body v Actually, the car example is better modelled as composition:
Requirements Analysis Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved Using Aggregation & Composition v Usefulness in analysis?
Requirements Analysis Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved Generalisation v Another term for inheritance relationship v Applies only where: v Familiar basis of most classification v Formally equivalent to “A is a kind of B”
Requirements Analysis Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved “Superclass is more general” v A superclass abstracts out some common features of its subclasses v May be common attributes, operations or associations AcademicStaff specialism assignModules pay calcHolidays name address phone nextOfKin AdminStaff grade calcHolidays pay name address phone nextOfKin
Requirements Analysis Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved UML Notation: Generalisation StaffMember name address phone nextOfKin calcHolidays pay AdminStaff grade AcademicStaff specialism assignModules Generalisation Base Class “Derived” Classes
Requirements Analysis Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved “Subclass is fully consistent...” v Every subclass inherits everything in its superclass definition v Redefined operations appear to break this rule, but actually they don’t v Suppose academic staff salaries are calculated differently from admin staff We may still define a generic pay operation at superclass level
Requirements Analysis Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved UML Notation: Generalisation StaffMember.pay is an abstract, generic definition of the operation AcademicStaff specialism assignModules pay AdminStaff grade calcHolidays pay StaffMember name address phone nextOfKin calcHolidays pay > Each subclass redefines this by adding the detailed logic for its own unique method of payment Note > stereotype on StaffMember
Requirements Analysis Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved “Subclass adds features...” v Every subclass is more specialised than all its superclasses: AcademicStaff specialism assignModules pay Person name address phone Staff pay calcHolidays dateAppointed staffNumber extension Student enrolOnModule passLevel nextOfKin currentLevel dateEnrolled PartTimeStudent studyDay
Requirements Analysis Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved UML Notation: Generalisation University Physical Resource * SupportAcademic Full-timePart-time TechAdmin * Person StudentStaff
Requirements Analysis Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved Using Generalisation v In analysis, inheritance offers a way to: v Even more useful during design v Mechanism for reuse of base class specifications
Requirements Analysis Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved Self-association v An object can have links with other objects of the same class v E.g. team members take turns at leading a team TeamMember leader led 1 * LeadsTeam v Note the use of roles to clarify multiplicities
Requirements Analysis Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved Self-association v Often combined with aggregation structures v E.g. recursive “parts explosion” for complex assemblies: Assembly 1 * Subassembly * 1 * 1 Part v Some assemblies are part of other assemblies
Requirements Analysis Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved Summary Explained significance of, and notation for: v Association Navigability v Class Roles and Association Qualifiers v Aggregation v Composition v Inheritance v Self-association
Requirements Analysis Specialised Associations b515.ppt © Copyright De Montfort University 2000 All Rights Reserved Further Reading Bennett, S. et al. “Object-Oriented Systems Analysis & Design using UML” McGraw-Hill 1999, esp Chs 7 and 8 Britton, C. and Doake, J. “Object-Oriented Systems Development: a Gentle Introduction” McGraw-Hill 2000 Jacobson, I. et al. “The Unified Software Development Process” Addison Wesley 1999 Larman, C. “Applying UML and Patterns” Prentice Hall 1998 Rational Unified Process, 2000