Hint for drawing descriptors in UML
Descriptors are physical objects (stored in memory) so show them as a class
with attributes. Use aggregation with role names to show stored addresses,
references, and pointers. If drawing more than one type/class of descriptor
you may need Generalization.
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 ]
Question 2 Arrays
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.
Question 3 Array Descriptors
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 3a and 3b [ ole4.gif ]
Question 4 Pointers
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 4c [ ole5.gif ]
Note(2004). A recent graduate sent EMail saying that the job interview was
mainly about pointers....
Question 5 records, fields and pointers in the UML
Draw a diagram that expresses the following facts using the UML and
composition, aggregation and roles.
Answer to Question 5 [ ole6.gif ]
If you have time try these variations on question 5: