Jan 2005Ron McFadyen Qualified Associations ProductCatalogueProductDescription A one to many association can be altered in a diagram to a one to one if there is an appropriate qualifier that identifies exactly one itemID is an attribute of ProductDescription that uniquely identifies an instance *1 ProductCatalogueProductDescription 1 1 itemID contains
Jan 2005Ron McFadyen Singleton Classes Random For some classes, it will be planned to only ever instantiate one object from that class Indicate this with a “1” in the upper righthand corner Later we will discuss the Singleton Pattern. 1
Jan 2005Ron McFadyen Interface classes AlarmClock An interface class is a collection of methods. We can use these to indicate that other classes implement the methods specified in the interface class attach() detach() notify() « interface » Subject
Jan 2005Ron McFadyen Aggregation and Composition both are associations used to denote that an object from one class is part of an object of another class HonoursProgrammeCourse An example of Aggregation: a course is part of an honours programme. The same module could be part of several honours courses “Software Engineering with Objects and Components” is part of both the “Software Engineering” and the “Computer Science” honours programmes **
Jan 2005Ron McFadyen 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. What is the multiplicity at the composition end of the association? * Note: the 3 rd edition suggests not using Aggregation, instead us Composition if the business rules suggest it
Jan 2005Ron McFadyen Aggregation and Composition InvoiceInvoiceLine Consider Invoices and their Invoice Lines Question: Is the association aggregation or composition? ? ? *
Jan 2005Ron McFadyen Aggregation and Composition SaleSalesLineItem Consider Sales and their SalesLineItems Is the association an aggregation or a composition? ? ? *
Jan 2005Ron McFadyen Aggregation and Composition Consider the Product Catalogue and its Product Specifications. Is the association an aggregation or a composition? Consider the General Calendar and its Course Specifications. Is the association an aggregation or a composition?
Jan 2005Ron McFadyen Aggregation and Composition Hand Finger Palm Thumb Several associations sharing the same aggregation/composition can be drawn with converging lines
Jan 2005Ron McFadyen Aggregation and Composition Suppose a document comprises a TOC, a preface, a number of sections, and possibly an index. composition or aggregation?
Jan 2005Ron McFadyen Association Class Business rule: a store has a different merchant ID for each service Association Class: a modeling element that is both an association and a class. It has attributes, operations, multiplicities, etc. It can participate in other relationships.
Jan 2005Ron McFadyen Many to many associations likely candidate for an Association Class Limitation !!! each company object can be associated to a person object only once. If we wanted to provide for a person to be employed by the same company more than once, we would need to promote Employment to be a regular class. How do we model this?
Jan 2005Ron McFadyen Reflexive Association An association involving the same class more than once. marries Person 1 1
Jan 2005Ron McFadyen Reflexive Association An association involving the same class more than once. marries Person * *
Jan 2005Ron McFadyen Contrasting two models Can be very accurate: one person plays more than one role More difficult to implement: may need to mutate an object from one class to another
Jan 2005Ron McFadyen Packages Packages are used to organize model elements. name