Abstraction-Occurrence Antipatterns: Libraryltem Librarvitem Title name na me name u tho auton au thol is bn publicati on Date oublicati on date publicati on Date libOfCongress li boc ongress li boiC ongress barco renumber barcodenumber Libraryltem GulliversTravels Moby Dick bar codenumber www.oseng.com O Lethbridge/Laganiere 2001 Chapter 6: Using design patterns 6
© Lethbridge/Laganière 2001 Chapter 6: Using design patterns 6 Abstraction-Occurrence Antipatterns: name author LibraryItem ba rCodeNumber is bn publicationDate libOfCongre ss Title name author LibraryItem ba rCodeNumber is bn publicationDate libOfCongre ss name author LibraryItem ba rCodeNumber is bn publicationDate libOfCongre ss GulliversTravels MobyDick
Abstraction-Occurrence Square variant Scheduledtrain SpecificTrain number date ScheduledLeg SpecificLeg scheduled DepTime actualDepTime scheduledarr time actualArr Time origIn destination Station www.oseng.com O Lethbridge/Laganiere 2001 Chapter 6: Using design patterns
© Lethbridge/Laganière 2001 Chapter 6: Using design patterns 7 Abstraction-Occurrence Square variant ScheduledTrain number SpecificTrain date * * * ScheduledLeg SpecificLeg actualDepTime * actualArrTime scheduledDepTime scheduledArrTime Station origin destination * *
6.3 The general hierarchy pattern · Context -Objects in a hierarchy can have one or more objects above them superiors and one or more objects below them(subordinates) Some objects cannot have any subordinates · Problen objects cannot have subordinates y of objects, in which some How do you represent a hierarchy orces You want a flexible way of representing the hierarchy that prevents certain objects from having subordinates -all the objects have many common properties and operations www.oseng.com O Lethbridge/Laganiere 2001 Chapter 6: Using design patterns 8
© Lethbridge/Laganière 2001 Chapter 6: Using design patterns 8 6.3 The General Hierarchy Pattern • Context: —Objects in a hierarchy can have one or more objects above them (superiors), - and one or more objects below them (subordinates). —Some objects cannot have any subordinates • Problem: —How do you represent a hierarchy of objects, in which some objects cannot have subordinates? • Forces: —You want a flexible way of representing the hierarchy - that prevents certain objects from having subordinates —All the objects have many common properties and operations
General hierarchy Node》 · Solution: 《 subordinate》 Non SuperiorNode》 SuperiorNode》 Employee supervises File Systemltemk contains SecretaryTechnician/[ Manager File Directory www.oseng.com O Lethbridge/Laganiere 2001 Chapter 6: Using design patterns
© Lethbridge/Laganière 2001 Chapter 6: Using design patterns 9 General Hierarchy • Solution: «subordinate» * «Node» «NonSuperiorNode» «SuperiorNode» * supervises Manager Employee Secretary Technician 0..1 0..1 * contains Directory FileSystemItem File 0..1
General Hierarch Antipattern Recording VideoRecoding AudioRecording MusicVideo JazzRecording ClassicalRecording Blues Recording RockRecordingl www.oseng.com O Lethbridge/Laganiere 2001 Chapter 6: Using design patterns
© Lethbridge/Laganière 2001 Chapter 6: Using design patterns 10 General Hierarchy Antipattern: MusicVideo JazzRecording ClassicalRecording BluesRecording RockRecording VideoRecoding AudioRecording Recording