Object-Oriented Modeling and Programming

glintplainvilleΛογισμικό & κατασκευή λογ/κού

18 Νοε 2013 (πριν από 3 χρόνια και 11 μήνες)

59 εμφανίσεις

Object
-
Oriented Modeling and Programming

Summer 1999

Mid
-
term Exam

Instructions

Answer the following questions in the space provided. You can hand
-
write your responses, and illustrate
them with hand
-
drawn UML diagrams where appropriate. Typed answers are
preferable as long as they
conform to the space limitation for each question. Your responses don’t have to be long to be correct.

Question 1.

While modeling a word
-
processing application, you want to model a scenario “make
some text bold
-
faced.” The

most appropriate modeling construct for this is a:

1.

stereotype.

2.

class diagram.

3.

use case.

4.

meta
-
class.

5.

a member function on the class
String.



1.

Define the construct you chose.

2.

In 50 words or less explain you choice.

Question 2.

Consider the program fragme
nt given below.


Class Set<T> {



void insert (T newElement);



void remove(T anElement);

};


Set <Employee> employeeSet;


1.

Draw a UML model for the above code.

2.

Briefly outline two implementation strategies for instantiating the object code for
Set<Emplo
yee>.
(please limit your answer to less than a paragraph each.)









Question 3.

Consider a system that has a class called Customer, and a sub
-
class called
SpecialCustomer as shown in the following UML model.



True/False?

1.

Reference to the value
of BadJohn.Income is valid in the print() function defined on
the SpecialCustomer class.

2.

An attempt to print the value BadJohn.Customer_Id from the main program will
produce a syntax error.

3.

The member function Display() defined for the SpecialCustomer clas
s can directly
print out the Customer_Id but not the DOB.

4.

A public member is visible anywhere in the program and may be accessed by any
object with in the program.

5.

A private member is visible only to class that defines it, and its sub
-
classes, but not to
any other class, even a “friend” class.


Customer


# Customer_Id

+ Nam
e

-

DOB


SpecialCustomer



-

Income


BadJohn: SpecialCustomer


Question 4.

Study the following UML model.


1.

Assign an appropriate multiplicity to all the relationships
---

both the source and the
target ends
---

in the above model.

2.

In this model, can a polygon and a

circle share a point? For example, can an instance
of point be simultaneously a vertex of a polygon and the center of a circle? Explain
your answer.

3.

Write psudeo
-
code for the .h file of class Polygon.

4.

Write C++ style psuedo
-
code for the destructor of th
e class polygon. Your code will
be judged for semantics and not the syntax.

5.

Does the following object diagram conform to the above model. If not, explain your
answer.





Style


Color

IsFilled

LineStyle

Point

Polygon

Circle



radius

aStyle : Style


aPoly : Polygon

aCircle : Circle


Question 5.

Let W units (in some arbitrary units) be the total programming e
ffort required for a
project. Each programmer can do U units/day of programming when working alone.


1.

Assuming no communication or interaction overhead, and assuming that the overall
programming task is parallelizable, how many days N programmer will tak
e to finish
the job? Denote by T(W, U, N) the time to project completion (in number of days).
Assuming constant W and U, plot T(W, U, N) required to complete the project as a
function of N.

2.

Now assume that the there is a fixed, one
-
time interaction overh
ead in the project:
each programmer has to talk to every other at the beginning and at the end of the
project in order to divide and re
-
synchronize the overall effort. Each programmer to
programmer interaction adds C units/interaction of communication ov
erhead.



Compute the number of days required to complete the project, T(W, U, N, C),
as a function of W, U, N, and C.



Assuming constant W, U and C, plot T as a function of N.



For what value of N is T(W, U, N, C) the minimum? Explain, in non
-
trigonometric t
erms, why this value of N leads to the minimum project
duration.

3.

To further generalize, and make the above calculation more realistic, assume that the
programming task is not easily divided
-
up among the N programmers. Each
programmer has to meet with ever
y other programmer, individually. This is done by
individual programmer to programmer meetings at the beginning and at the end of
each day. This creates D units/interaction/day of additional work, on top of the W
units of actual project work.



Compute th
e number of days required to complete the project, T(W, U, N, D),
as a function of W, U, N, and D.



Assuming constant W, U and D, plot T as a function of N.



For what value of N is T(W, U, N, D) the minimum? Explain, in non
-
trigonometric terms, why this val
ue of N lead to the minimum project
duration.

4.

In the light of above calculations, briefly comment on the correctness of the saying:
“Addition of a new programmer makes a late project later.”


Question 6. True/False

1.

The basic building blocks of UML, viz.
,
things
,
relationships
, and
diagrams

allow
you model a system as a hierarchical graph.

2.

A stereotype similar to a meta
-
class because it can be instantiated twice: the first time
to give a class
-
like entity which in turn can be further instantiated to give
objects.

3.

Stereotypes are typically used to extend the language so that properties that should not
be stored in each instance of a class can be added to a class definition.

4.

A generalization is an instantiable relationship in UML.

5.

An adornment {isQuery} next

to two operations implies that those operations can
proceed in parallel without causing concurrency control problems.


Question 7.

1.

Define: (a) polymorphism, (b) overloading, and (c) information hiding?

2.

What is the difference between adding a tagged v
alue to a class as opposed to adding
a new data member to the class that can hold the same value. Please limit your
answer to 100 words.


Question 8.

Consider the UML model shown below (taken from page 73 of your text book). Using
the COOL or STL cont
ainer classes, write the header files (the .h files) for the various
classes shown in the model. Try to capture as much of the model semantics in your C++
code as possible. Where it is not possible to capture the UML semantics in C++, provide
appropri
ate comments in the code. Your code will be judged on how faithfully it mirrors
the semantics of the model and not on syntax.




Course



School

Student

Department

Instructor

1..*

*

1

1..*

1..*

1..*

*

*

0..1

1..*

0..1

chairper
son

1..*

*

1..*

membe
r

attends

AssignedT
o

has


Question 9.

1.

Give two benefits of link time shared libraries or DLL's in the context of a l
arge
object oriented software system.

2.

Give two disadvantages of link time shared libraries.

3.

Give an example of using run time dynamic linking to write device independent
software.


Question 10.

1.

Define an "Open" interface to a class or module.

2.

Define a "Cl
osed" interface to a class or module.

3.

Describe Object Oriented techniques that allow a software module or class to be both
"Open" and "Closed".


Question 11.

Describe the Facade pattern and give an example of its use.