310414 oo modeling with uml 1 object-oriented modeling with uml — questions & examples 310313...

20
310414 310414 OO MODELING WITH UML OO MODELING WITH UML 1 OBJECT-ORIENTED MODELING WITH UML OBJECT-ORIENTED MODELING WITH UML — QUESTIONS & EXAMPLES — QUESTIONS & EXAMPLES 310313 310313 SOFTWARE ENGINEERING SOFTWARE ENGINEERING

Upload: michael-mckinney

Post on 29-Dec-2015

221 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: 310414 OO MODELING WITH UML 1 OBJECT-ORIENTED MODELING WITH UML — QUESTIONS & EXAMPLES 310313 SOFTWARE ENGINEERING 310313 SOFTWARE ENGINEERING

310414310414 OO MODELING WITH UMLOO MODELING WITH UML1

OBJECT-ORIENTED MODELING WITH OBJECT-ORIENTED MODELING WITH UML — QUESTIONS & EXAMPLESUML — QUESTIONS & EXAMPLES

OBJECT-ORIENTED MODELING WITH OBJECT-ORIENTED MODELING WITH UML — QUESTIONS & EXAMPLESUML — QUESTIONS & EXAMPLES

310313310313SOFTWARE ENGINEERINGSOFTWARE ENGINEERING

310313310313SOFTWARE ENGINEERINGSOFTWARE ENGINEERING

Page 2: 310414 OO MODELING WITH UML 1 OBJECT-ORIENTED MODELING WITH UML — QUESTIONS & EXAMPLES 310313 SOFTWARE ENGINEERING 310313 SOFTWARE ENGINEERING

310414310414 OO MODELING WITH UMLOO MODELING WITH UML2

1) roads.

2) land topology (e.g., contours showing elevation above sea level.

3) historical sites to see (e.g., the HKUST beach).

4) the types and places of vegetation (i.e., trees and other types of plants).

5) location of hiking trails.

6) bus routes.

If you had to draw a map of the area around HKUST to explain to someone how to get to HKUST from Choi Hung, what is the one most important thing you would include?

QUESTION?QUESTION?

Page 3: 310414 OO MODELING WITH UML 1 OBJECT-ORIENTED MODELING WITH UML — QUESTIONS & EXAMPLES 310313 SOFTWARE ENGINEERING 310313 SOFTWARE ENGINEERING

310414310414 OO MODELING WITH UMLOO MODELING WITH UML3

1) roads.

2) land topology (e.g., contours showing elevation above sea level.

3) historical sites to see (e.g., the HKUST beach).

4) the types and places of vegetation (i.e., trees and other types of plants).

5) location of hiking trails.

6) bus routes.

If you had to draw a map of the area around HKUST to explain to someone how high the Academic Building is above sea level, what is the one most important thing you would include?

QUESTION?QUESTION?

Page 4: 310414 OO MODELING WITH UML 1 OBJECT-ORIENTED MODELING WITH UML — QUESTIONS & EXAMPLES 310313 SOFTWARE ENGINEERING 310313 SOFTWARE ENGINEERING

310414310414 OO MODELING WITH UMLOO MODELING WITH UML4

1) classification only

2) aggregation only

3) generalization only

4) classification and aggregation

5) aggregation and generalization

6) classification and generalization

7) classification, aggregation and generalization

8) none of the above

QUESTION?QUESTION?

Consider the relationship between files and directories in a computer system. Which type(s) of abstraction models this relationship?

Page 5: 310414 OO MODELING WITH UML 1 OBJECT-ORIENTED MODELING WITH UML — QUESTIONS & EXAMPLES 310313 SOFTWARE ENGINEERING 310313 SOFTWARE ENGINEERING

310414310414 OO MODELING WITH UMLOO MODELING WITH UML5

Which type of abstraction relates objects and classes?

1) classification only

2) aggregation only

3) generalization only

4) classification and aggregation

5) aggregation and generalization

6) classification and generalization

7) classification, aggregation and generalization

8) none of the above (this is not a type of abstraction)

QUESTION?QUESTION?

Page 6: 310414 OO MODELING WITH UML 1 OBJECT-ORIENTED MODELING WITH UML — QUESTIONS & EXAMPLES 310313 SOFTWARE ENGINEERING 310313 SOFTWARE ENGINEERING

310414310414 OO MODELING WITH UMLOO MODELING WITH UML6

Which type of abstraction relates objects and classes?

QUESTION?QUESTION?

apply classification abstraction to objects to form classes

IS_MEMBER_OFrelationship

Page 7: 310414 OO MODELING WITH UML 1 OBJECT-ORIENTED MODELING WITH UML — QUESTIONS & EXAMPLES 310313 SOFTWARE ENGINEERING 310313 SOFTWARE ENGINEERING

310414310414 OO MODELING WITH UMLOO MODELING WITH UML7

Which type of abstraction relates attributes and classes?

1) classification only

2) aggregation only

3) generalization only

4) classification and aggregation

5) aggregation and generalization

6) classification and generalization

7) classification, aggregation and generalization

8) none of the above (this is not a type of abstraction)

QUESTION?QUESTION?

Page 8: 310414 OO MODELING WITH UML 1 OBJECT-ORIENTED MODELING WITH UML — QUESTIONS & EXAMPLES 310313 SOFTWARE ENGINEERING 310313 SOFTWARE ENGINEERING

310414310414 OO MODELING WITH UMLOO MODELING WITH UML8

Which type of abstraction relates attributes and classes?

QUESTION?QUESTION?

apply aggregation abstraction to attributes to form classes

name instructor prerequisitecourse#

IS_PART_OFrelationship

Course

Page 9: 310414 OO MODELING WITH UML 1 OBJECT-ORIENTED MODELING WITH UML — QUESTIONS & EXAMPLES 310313 SOFTWARE ENGINEERING 310313 SOFTWARE ENGINEERING

310414310414 OO MODELING WITH UMLOO MODELING WITH UML9

The coverage of the generalization shown above is:

– overlapping, complete

– disjoint, complete

– overlapping, incomplete

– disjoint, incomplete

QUESTION?QUESTION?

Cash DebitCardCreditCard

Payment

What is the policy of the organization?

Page 10: 310414 OO MODELING WITH UML 1 OBJECT-ORIENTED MODELING WITH UML — QUESTIONS & EXAMPLES 310313 SOFTWARE ENGINEERING 310313 SOFTWARE ENGINEERING

310414310414 OO MODELING WITH UMLOO MODELING WITH UML10

The coverage of the generalization shown above is:

– overlapping, complete

– disjoint, complete

– overlapping, incomplete

– disjoint, incomplete

QUESTION?QUESTION?

Individual Company

Customer

Page 11: 310414 OO MODELING WITH UML 1 OBJECT-ORIENTED MODELING WITH UML — QUESTIONS & EXAMPLES 310313 SOFTWARE ENGINEERING 310313 SOFTWARE ENGINEERING

310414310414 OO MODELING WITH UMLOO MODELING WITH UML11

Which type of abstraction relates links and associations?

1) classification only

2) aggregation only

3) generalization only

4) classification and aggregation

5) aggregation and generalization

6) classification and generalization

7) classification, aggregation and generalization

8) none of the above (this is not a type of abstraction)

QUESTION?QUESTION?

Page 12: 310414 OO MODELING WITH UML 1 OBJECT-ORIENTED MODELING WITH UML — QUESTIONS & EXAMPLES 310313 SOFTWARE ENGINEERING 310313 SOFTWARE ENGINEERING

310414310414 OO MODELING WITH UMLOO MODELING WITH UML12

Which type of abstraction relates links and associations? apply classification abstraction to links to form associations

QUESTION?QUESTION?

WorksFor

Person University

Page 13: 310414 OO MODELING WITH UML 1 OBJECT-ORIENTED MODELING WITH UML — QUESTIONS & EXAMPLES 310313 SOFTWARE ENGINEERING 310313 SOFTWARE ENGINEERING

310414310414 OO MODELING WITH UMLOO MODELING WITH UML13

Which type of abstraction relates links and associations? apply aggregation abstraction to classes to form associations

Person University

QUESTION?QUESTION?

WorksFor

Page 14: 310414 OO MODELING WITH UML 1 OBJECT-ORIENTED MODELING WITH UML — QUESTIONS & EXAMPLES 310313 SOFTWARE ENGINEERING 310313 SOFTWARE ENGINEERING

310414310414 OO MODELING WITH UMLOO MODELING WITH UML14

What is the most likely multiplicity of the following associations?

QUESTION?QUESTION?

ServiceOrder ServiceCallHas

ServiceAgent ServiceOrderTakes

ServiceOrder PartWaitsFor

Product PartComposedOf

1 0..*

1

*

1..*

0..*

*

1..*

Page 15: 310414 OO MODELING WITH UML 1 OBJECT-ORIENTED MODELING WITH UML — QUESTIONS & EXAMPLES 310313 SOFTWARE ENGINEERING 310313 SOFTWARE ENGINEERING

310414310414 OO MODELING WITH UMLOO MODELING WITH UML15

QUESTION?QUESTION?

* 0..3

0..1

0, 1, 2 or 3 days

0 or 1 classrooms

many courses

for each (course, classroom)

for each (course, day)

for each (classroom, day)

Classroom

Course Day

Meets

Page 16: 310414 OO MODELING WITH UML 1 OBJECT-ORIENTED MODELING WITH UML — QUESTIONS & EXAMPLES 310313 SOFTWARE ENGINEERING 310313 SOFTWARE ENGINEERING

310414310414 OO MODELING WITH UMLOO MODELING WITH UML16

EXAMPLEEXAMPLE

The classes shown have some attributes that are internal object identifiers (OIDs) that should not appear at the conceptual level and should either be deleted or be replaced with relationships. All such attributes conveniently have names ending in ID.

Some further information about the application follows. A person may work for any number of companies. Persons, companies, or banks may own cars. The car owner ID represents either the person, company, or bank who owns the car. A car may have only one owner (person, company, or bank). A car loan given by a bank is for the purchase of a car. A car may have multiple car loans.

Prepare a class diagram in which the OIDs are either deleted or replaced with relationships. Use associations and generalizations as necessary. Show the most likely multiplicities for all associations and the final attributes for each class.

Note: Your final class diagram should contain no OIDs.

Page 17: 310414 OO MODELING WITH UML 1 OBJECT-ORIENTED MODELING WITH UML — QUESTIONS & EXAMPLES 310313 SOFTWARE ENGINEERING 310313 SOFTWARE ENGINEERING

310414310414 OO MODELING WITH UMLOO MODELING WITH UML17

EXAMPLEEXAMPLE

Person

nameageemployer1IDemployer2IDemployer3IDpersonIDaddress

Car

ownerIDvehicleIDownerTypemodelyear

CarLoan

vehicleIDcustomerTypecustomerIDaccountNumberbankIDinterestRatecurrentBalance

Company

namecompanyID

Bank

namebankID

Page 18: 310414 OO MODELING WITH UML 1 OBJECT-ORIENTED MODELING WITH UML — QUESTIONS & EXAMPLES 310313 SOFTWARE ENGINEERING 310313 SOFTWARE ENGINEERING

310414310414 OO MODELING WITH UMLOO MODELING WITH UML18

EXAMPLE SOLUTIONEXAMPLE SOLUTION

It is important to realize that some IDs represent associations while others are simply internal OIDs and so should not appear as attributes at all.

Car

modelyear

CarLoan

accountNumberinterestRatecurrentBalance

Owner

name

WorksForIsFor

Lends

Owns

Person

ageaddress

Company*

1

*

*

*

1

*

Bank1

{disjoint, complete}

{incomplete}

Page 19: 310414 OO MODELING WITH UML 1 OBJECT-ORIENTED MODELING WITH UML — QUESTIONS & EXAMPLES 310313 SOFTWARE ENGINEERING 310313 SOFTWARE ENGINEERING

310414310414 OO MODELING WITH UMLOO MODELING WITH UML19

EXAMPLEEXAMPLE

Construct a class diagram for the classes listed below. Use association, aggregation and generalization relationships as necessary. Show the multiplicity for all relationships.

file system drive file directory

sector ASCII file disk executable file

track

Page 20: 310414 OO MODELING WITH UML 1 OBJECT-ORIENTED MODELING WITH UML — QUESTIONS & EXAMPLES 310313 SOFTWARE ENGINEERING 310313 SOFTWARE ENGINEERING

310414310414 OO MODELING WITH UMLOO MODELING WITH UML20

EXAMPLE SOLUTIONEXAMPLE SOLUTION

ASCIIDirectory

File

Executable

File system Drive

Disk

Track

Sector

*

1..*

1..*

1..*

1..*

1..*

*

can also be aggregation(e.g., floppy, removable)

ResidesOn