Download presentation
Presentation is loading. Please wait.
1
November 200291.3913 R McFadyen1 Aggregation and Composition – section 27.2 both are associations used to denote that an object from one class is part of an object of another class ProgrammeCourse An example of Aggregation: a course is part of the 4-year programme. The same course could be part of several programmes “Relational Application Development” is part of both the “3- Year” and the “4-Year” programmes *
2
November 200291.3913 R McFadyen2 Aggregation and Composition BoardSquare Composition is similar to, but stronger than aggregation. If you specify composition, then you are saying that one object owns its parts. A Board is made up of several Squares. A Square will belong to just one Board. If a Board is deleted, then its Squares are deleted too. *
3
November 200291.3913 R McFadyen3 Aggregation and Composition InvoiceInvoiceLine Consider Invoices and their Invoice Lines Question: Is the association aggregation or composition? ? ? *
4
November 200291.3913 R McFadyen4 Association Classes (Section 27.1) In a typical university: We have a Course class and a Student class. A Student enrolls in an Course and is eventually assigned a grade. A Student may enroll in several Courses. A Course will have many Students enrolled. Consider : StudentCourse ** Where is the student’s grade kept? We can’t keep it with Student … nor with Course
5
November 200291.3913 R McFadyen5 Association Classes StudentCourse ** Grade is considered an attribute that belongs to the association between a student and a course. If your model has a many-to-many association between two classes, then there will likely be a need for an association class Enrollment grade courseNum
6
November 200291.3913 R McFadyen6 Association Classes StudentCourse ** Enrollment grade 2914 3913 123 333 789 Suppose we have 3 students taking courses : courseNum studNum StudentCourse A A B C
7
November 200291.3913 R McFadyen7 Association Classes StudentCourse ** Now suppose we need to track these grades over several terms we need to know what grades a student received for a course that was repeated more than once. The above model doesn’t accommodate this - there are different approaches (see section 27.3, next slide) Enrollment grade courseNum studNum
8
November 200291.3913 R McFadyen8 Association Classes StudentCourse ** For a given combination of Student and Course, there is only one instance of Enrollment. The association class cannot keep track of history, only the most current association between a given student and a given course is kept. Enrollment grade courseNum studNum
9
November 200291.3913 R McFadyen9 Association Classes StudentCourse ** We’ll look at two alternatives: Promotion of association class to class Using explicit notion of time Enrollment grade courseNum studNum
10
November 200291.3913 R McFadyen10 Association Class – Promotion of association class to class Student Course ** Enrollment Grade Term courseNum studNum 11 Consider the following where the association class is promoted to a full class, and the association is replaced by two associations. permits the same course and the same student to be related several times Enrollment is promoted to a full-fledged class There are two associations now, instead of one
11
November 200291.3913 R McFadyen11 Association Classes (including element of time) StudentCourse ** Associate a collection of Offerings with a course - each offering is associated with a particular time interval (in this case the time interval is duration of the term) Section 27.3 refers to a Moment-Interval archetype - a concept promoted by Peter Coad. The idea recognizes that some things that we need to track, either occur at a moment in time, or, they occur over an interval of time. (read section 27.3) Enrollment grade Offering courseNum term courseNum instructor studNum *
12
November 200291.3913 R McFadyen12 Moment-Interval archetype Coad would indicate these types of classes with the designation: >, and, they would be coloured: > Offering term courseNum instructor > Offering term courseNum instructor Colour makes these kinds of classes stand out in a diagram. (See Java Modeling in Color with UML) Supposed to be pink
13
November 200291.3913 R McFadyen13 From the text – section 27.3 Up till now, there has been only one price kept for a ProductSpecification. If there have been price changes, then getting the right subtotal could not be done correctly. Above: A SalesLineItem is related to a ProductSpecification which is associated with a collection of ProductPrice
14
November 200291.3913 R McFadyen14 Roles (sections 27.5, 27.5) Store Manager * * Person 1 1 Figure 27.11 Two approaches that are very similar Cashier Store manager Employs-to-manage Employs-to-handle-sales cashier worker manager 1 manages * Roles played in associations * * * manages 1 1 Employs Roles as concepts
15
November 200291.3913 R McFadyen15 Reflexive Associations (section 27.8) child parent2 parent1 Person
16
November 200291.3913 R McFadyen16 Reflexive Associations Would an association class be of any use here? Could subclasses be useful? What do we need to do if we need to keep track of history? marries husband wife **
17
November 200291.3913 R McFadyen17 Packages Enrollment Student Course ** Enrollment grade courseNum studNum 11 See section 27.10 (just the UML package notation on pages 425-6)
18
November 200291.3913 R McFadyen18 Payments Package - Figure 27.23
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.