Use the data types defined in the UML/OCL if possible( Enumeration, Real,
Integer, String, Boolean). Use the UML notation for arrays[n..m]. Show
pointers and references as one-way associations (--->). Show records (structs in
C/C++) as classes with public(+) attributes and no operations. Suppress
empty compartments.
Descriptors are physical objects (stored in memory) so show them as a class
with attributes. Use aggregation or associations with arrowheads plus role names to show stored addresses,
references, and pointers. If drawing more than one type/class of descriptor
you may need Generalization.
1a. What are: coercion, type checking, strong typing, and type compatibility?
1b. Describe the good and bad points of strong typing .
a. Define a character string type.
b. Name an important string operation available in your favorite high level
programming language. How is it expressed in your favorite high level
language
c. List two(2) design issues for strings.
d. Describe three(3) strings length design options.
e. For each string length option: name a language that has it and draw a
UML class diagram of that language's implementation of the option. Do not
use the UML's array-like attributes: 'contents[*]:char' or
'contents:char[*]' for example.
Answer:
[ ole2.gif ]
a. Define an array
b. List 3(three) design issues and options for arrays.
c. Explain in detail one way that a two dimensional array is coded in a
language that has only got one dimensional arrays.
d. State the formula for calculating the position of an item in your two
dimensional array.
a. Draw a diagram using the UML of an example of a descriptor for a 2
dimensional array.
b. Explain the precise mathematical relationship between the elements of
the descriptor and the address of the i,j th item in such an array.
Answers to 4a and 4b
[ ole4.gif ]
a. List the design issues and options for pointer data types.
b. What is a record data type?
c. Draw in the UML: Class Pointer points at a Record that has a field named
foo of type Type
Answers for Question 5c
[ ole5.gif ]
Note(2004). A recent graduate sent EMail saying that the job interview was
mainly about pointers....
Draw a diagram that expresses the following facts using the UML and
composition, aggregation and roles.
- Class A is a record that has a field named foo of type C.
- Class B is a record that has a field called bar that is a
pointer to something of type C.
- Class B is a record that has a field called fubar that is an
array of 26 items of type C.
Answer to Question 6
[ ole6.gif ]
If you have time try these variations on question 6:
- B points to at least 1 C called mumble.
- A has 100 C's
What data types would you like to have in your new language? For each one:
what issues and options must you address to make it clear how it works in
your new LRM?