Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 7 Understanding More Complex Requirements Models Using Generalization / Specialization and Whole-Part Hierarchies.

Similar presentations


Presentation on theme: "Chapter 7 Understanding More Complex Requirements Models Using Generalization / Specialization and Whole-Part Hierarchies."— Presentation transcript:

1 Chapter 7 Understanding More Complex Requirements Models Using Generalization / Specialization and Whole-Part Hierarchies

2 Understand systems having a Generalization / Specialization Hierarchy Generalization / Specialization Hierarchy associated with another class Inheritance from a class that is not Abstract Generalization / Specialization with Multiple Inheritance Whole / Part Relationships Complex Whole-Part Hierarchies Chapter Objectives

3 Generalization / specialization hierarchy tree of classes and subclasses that lead from the general to the specific Generalization / Specialization

4 Source: Specialization Generalization Super ClassSub Class

5 Whole / Part Whole / part hierarchy tree of classes and subclasses that lead from the entire entity to its individual components also an example of aggregation

6 Whole / Part Components Aggregation Part Whole Super ClassSub Class

7 A medical clinic needs to store information about doctors and patients. want to store information about each doctor name, date of birth, date employed, specialty also need information about patients name, date of birth, employer, insurance company Object classes in this problem domain obviously include doctors and patients These two classes have things in common names and date of birth as attributes Leads to general class: Person Still need to define two specialized classes for these two types of people because they do have unique attributes for doctors, still want to know date of employment and specialty for patients still want to know employer and insurance company Example

8 Result is three classes Person, DoctorPerson, PatientPerson Person is a general class Generalization / Specialization hierarchy is indicated in UML by the triangle symbol on the line which connects Person to DoctorPerson and PatientPerson. Example (c)

9 Use case (Add new doctor) Event: A doctor is newly employed by the clinic Use Case: Add new doctor, Main scenario user sends message to DoctorPerson class asking it to add new DoctorPerson object DoctorPerson class needs Name, Date of Birth, Date Employed, and Specialty to add a DoctorPerson object, so user is asked to provide those values user supplies requested values DoctorPerson class adds new DoctorPerson object and tells the user task is complete

10 Sequence Diagram Add new Doctor

11 Event: A new patient is added to the clinic. Use Case: Add new patient, Main scenario user sends message to PatientPerson class asking it to add new PatientPerson object PatientPerson class needs Name, Dare of Birth, Insurance Company, and Employer to add PatientPerson object, so user asked to provide those values user supplies requested values PatientPerson class adds new PatientPerson object and tells user task is complete Use case (Add new patient)

12 Sequence Diagram Add new Patient

13 No reason to add a Person object explicitly Person class is inherited by DoctorPerson and PatientPerson This design enables users to look up information about doctors and patients query capability is implicit user could ask to see all doctors with specific specialty user could ask to see all the patients with specific insurance company would require extended interface and additional programming objects could become records in relational database DBMS would enable queries against those records Comments on Use Cases

14 Example (c) Add another class to the problem domain Treatment attributes are Date, Start Time, End Time Each Treatment is associated with the DoctorPerson we providing the treatment assuming one doctor per treatment A PatientPerson might receive many treatments Such associations are shown on the class diagram

15 Generalization / Specialization Hierarchy Associated with Treatment

16 Use Case (Record Treatment) Event: A patient receives a treatment Use Case: Record treatment, Main scenario user sends a message to Treatment class asking to add new Treatment object Treatment needs DoctorPerson Name and PatientPerson Name because it is required to connect to both objects, so user is asked to provide these values user supplies the values Treatment class needs the Date, Start Time, and End Time for the time, so user is asked to provide these values user supplies the values Treatment class adds new Treatment object using Date, Start Time and End Time connects to correct DoctorPerson object connects to correct PatientPerson object tells user task is complete

17 Sequence Diagram Record Treatment

18 Inheritance from a Class That is not Abstract Generalization / Specialization hierarchies can be complex Sometimes a general class includes objects and is also specialized into subclasses that also include objects

19 Generalization / Specialization with Multiple Inheritance In the dive shop example, some customers are both dive customers and boat customers. Some customers who dive always rent a boat. Class diagram that includes an additional class, Dive&BoatCustomer, appears to solve the problem. Dive&BoatCustomer inherits all attributes and services of DiveCustomer & BoatCustomer. This called multiple inheritance because the object inherits attributes and services from multiple classes.

20 Multiple Inheritance

21 Whole-Part Relationships Object relationships in which an object has a particularly strong association with other objects the first object’s parts Example of whole-part relationship specific college and the faculty who teach in the college college “contains” or “includes” faculty UML symbol for a whole-part relationship is a diamond on the line connecting to classes.

22 Whole-part Relationships (aggregation) with Cardinality / Multiplicity Indicated

23 Example Whole-Part Hierarchy At the dive shop, a Boat Assembly, not a boat, is rented. one type contains a boat hull, motor, trailer another type Boat Assembly contains boat hull, two motors, but no trailer third type Boat Assembly contains boat hull and trailer, but no motor Important for the dive shop to know what each type Boat Assembly includes. Boat Assemblies are permanent “packages” whose parts stay together and are never rented separately. Dive shop needs to know what they are renting determines rental price ensures return of complete assembly

24 Boat Assemblies

25 Use Case (Add new Boat) Event: New boat assembly purchased for rental. Use Case: Add a new boat assembly, Main scenario user sends a message to BoatAssembly asking for new BoatAssembly object BoatAssembly needs Coast Guard ID and Total Weight to add new Boat Assemble object user asked user for those values user supplies requested values BoatAssembly then adds new BoatAssembly object

26 BoatAssembly is a collection of parts has one Boat Hull user asked for Hull Number and Capacity of Boat Hull user supplies Boat Hull values BoatAssembly asks BoatHull to add new BoatHull object BoatAssembly might include one trailer user asked if assembly includes Trailer if so, user asked for Serial Number and License Number User supplies Trailer Values Adding a new boat

27 BoatAssembly asks Trailer to add new Trailer object BoatAssembly might include one or more Motors if so, for each motor, user asked for Serial Number, Manufacturer, Model Number, Horsepower User supplies Motor values BoatAssembly asks Motor to add Motor object Adding a new boat

28 Adding a new boat Sequence diagram

29 Review Questions 1. What can one class inherit from another class? 2. What symbol in the class diagram indicates A Generalization / Specialization Hierarchy? 3. What is the difference between a class with its name written in italics and a class with its name written with ordinary letters? 4. What is a nonexhaustive Generalization / Specialization Hierarchy?

30 5. What is multiple inheritance? 6. Why is the multiple inheritance example for the dive shop a potential problem? 7. Explain why whole-part hierarchies contain object relationships but Generalization / Specialization Hierarchies do not. 8. What are the advantages of using whole-part hierarchies in the class diagram? Review Questions


Download ppt "Chapter 7 Understanding More Complex Requirements Models Using Generalization / Specialization and Whole-Part Hierarchies."

Similar presentations


Ads by Google