Skip to main contentCal State San Bernardino / [CNS] / [Comp Sci Dept] / [R J Botting] / [CSci320] [Search ]
[Schedule] [Syllabi] [Text] [Labs] [Projects] [Resources] [Grading] [Contact]
Sessions: [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20]
07q.html (HTML) [07q.txt(Text)] Thu Apr 5 17:49:00 PDT 2007

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 aggregation (<>->). 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 with role names to show stored addresses, references, and pointers. If drawing more than one type/class of descriptor you may need Generalization.

      Question 1 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 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.
    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 5 [ ole6.gif ]

      If you have time try these variations on question 5:

    4. B points to at least 1 C.
    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?

End