Reflexive associations It is possible for an association to connect a class to itself successor Course k isMutuallyEXclusiveWith prerequIsite www.oseng.com O Lethbridge/Laganiere 2001 Chapter 5: Modelling with classes 16
© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes 16 Reflexive associations • It is possible for an association to connect a class to itself Course * isMutuallyExclusiveWith * * prerequisite successor *
Directionality in associations Associations are by default bi-directional It is possible to limit the direction of an association by adding an arrow at one end Day Note www.oseng.com O Lethbridge/Laganiere 2001 Chapter 5: Modelling with classes 17
© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes 17 Directionality in associations • Associations are by default bi-directional • It is possible to limit the direction of an association by adding an arrow at one end * Day Note
5.4 Generalization pecializing a superclass into two or more subclasses The discriminator is a label that describes the criteria used in the specialization Animal Animal habitat △ ty pe Of Food AquaticAnimalLandAnimal Carnivore Herbivore www.oseng.com O Lethbridge/Laganiere 2001 Chapter 5: Modelling with classes 18
© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes 18 5.4 Generalization Specializing a superclass into two or more subclasses • The discriminator is a label that describes the criteria used in the specialization Animal Animal habitat typeOfFood AquaticAnimal LandAnimal Carnivore Herbivore
Avoiding unnecessary generalizations Inappropriate hierarchy of classes. which should be VideoRecod Audio Recording Instances MusicVideo Jazz Recording I ClassicalRecording BluesRecording RockRecording Recording- has Category Recording Category description Improved class diagram artist with its corresponding ecording Category ordingcatego video instance diagram ubcatego Recording Category: Recording Category: Recording Category Recording Category Recording Category classical blues Recording Beethoven The Beatles www.oseng.com O Lethbridge/Laganiere 2001 Chapter 5: Modelling with classes 19
© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes 19 Avoiding unnecessary generalizations MusicVideo JazzRecording ClassicalRecording BluesRecording RockRecording VideoRecoding AudioRecording Recording music video jazz classical blues rock video audio RecordingCategory * subcategory description Recording * hasCategory subcategory subcategory subcategory subcategory subcategory :RecordingCategory :RecordingCategory :RecordingCategory :RecordingCategory :RecordingCategory :RecordingCategory :RecordingCategory 9th Symphony :Recording Let it be :Recording Beethoven The Beatles title artist Inappropriate hierarchy of classes, which should be instances Improved class diagram, with its corresponding instance diagram
Handling multiple discriminators Creating higher-level generalization Animal habitat八 AquaticAnimal LandAnimal ty pe of Food \ty pe Of Food AquaticCamivore AquaticHerbivoreLandCamivoreLandHerbivore www.oseng.com O Lethbridge/Laganiere 2001 Chapter 5: Modelling with classes
© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes 20 Handling multiple discriminators Animal habitat AquaticAnimal LandAnimal AquaticCarnivore AquaticHerbivore LandCarnivore LandHerbivore typeOfFood typeOfFood • Creating higher-level generalization