Docsity

Generalization 2-Object Oriented Analysis And Design-Lecture Slides, Slides of Object Oriented Analysis and Design

Partial preview of the text

Download Generalization 2-Object Oriented Analysis And Design-Lecture Slides and more Slides Object Oriented Analysis and Design in PDF only on Docsity!

Subtype

Supertype

Subtype

OO Relationships: Generalization

-Inheritance is a required feature of object orientation

-Generalization expresses a parent/child relationship among related classes.

-Used for abstracting details in several layers

Regular Customer

Loyalty Customer

Example: Customer

 Represent relationship between instances of classes

 Student enrolls in a course  Courses have students  Courses have exams  Etc.

 Association has two ends

 Role names (e.g. enrolls)  Multiplicity (e.g. One course can have many students)  Navigability (unidirectional, bidirectional)

OO Relationships: Association

Class diagram

[from UML Distilled Third Edition ] docsity.com

Association: Model to Implementation

Class Student {

Course enrolls[4];

Class Course {

Student have[];

Student Course

has enrolls

OO Relationships: Aggregation

Class C

Class E 1 Class E 2

AGGREGATION

Container Class

Containee Classes

Bag

Apples Milk

Example

Aggregation: expresses a relationship among instances of related classes. It is a specific kind of Container- Containee relationship.

express a more informal relationship than composition expresses.

Aggregation is appropriate when Container and Containees have no special access privileges to each other.

[From Dr.David A. Workman] docsity.com

Aggregation vs. Composition

Composition is really a strong form of association components have only one owner components cannot exist independent of their owner components live or die with their owner e.g. Each car has an engine that can not be shared with other cars.

Aggregations may form "part of" the association, but may not be essential to it. They may also exist independent of the aggregate. e.g. Apples may exist independent of the bag.