[Skip Navigation] [CSUSB] / [CNS] / [CSE] / [R J Botting] /[CS320 Course Materials] /07q.html [07q.txt(Text)] [Search ]
Tue Apr 23 17:06:41 PDT 2013
[Schedule] [Syllabi] [Text] [Labs] [Projects] [Resources] [Grading] [Contact]
Notes: [01] [02] [03] [04] [05] [06] [07] [08] [09] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20]

Contents


    CS320/07 Chapter 6 - Data Types

      Hint for documenting data types in the UML

      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.

      Hint for drawing descriptors in UML

      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.

      Question 1 Definitions

      1a. What are: coercion, type checking, strong typing, and type compatibility?

      1b. Describe the good and bad points of strong typing .

      Question 2 Character Strings

      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 3 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 4 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 4a and 4b [ ole4.gif ]

      Question 5 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 5c [ ole5.gif ]

      Note(2004). A recent graduate sent EMail saying that the job interview was mainly about pointers....

      Question 6 records, fields and pointers in the UML

      Draw a diagram that expresses the following facts using the UML and composition, aggregation and roles.
    1. Class A is a record that has a field named foo of type C.
    2. Class B is a record that has a field called bar that is a pointer to something of type C.
    3. 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:

    4. B points to at least 1 C called mumble.
    5. A has 100 C's

      Project Question

      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?

    Review

( End of document ) <<Contents | Top