{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}


6data-representation_Nov01 - The Object of Study In many...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CSci 5106: Programming Languages Data Representation Gopalan Nadathur Department of Computer Science and Engineering University of Minnesota Lectures in Fall 2010 Gopalan Nadathur Data Representation The Object of Study In many programming situations, we need to handle data objects of arbitrary degrees of complexity For example, consider a “person record:” person dob day in year int year int name first name string last name string Id No string . . . Imperative programming languages provide mechanisms for constructing representations of such objects: representations for primitive kinds of values operators for composing simpler representations to yield more complex ones We will look at these and their use in representing values Gopalan Nadathur Data Representation Data Representation versus Data Object These concepts are distinct and should be recognized as such: The same object may have different representations day in year integer (counting days) structure containing month and day in month Representations may allow more operations than are meaningful on the object E.g., integers can be multiplied but “day in year” cannot Representations need to be interpreted to yield an object E.g., we need some external process to extract Feb 29 (or March 1) from the integer 60 Gopalan Nadathur Data Representation Realizing Data Objects The eventual desire is to allow programmers to deal with data objects rather than representations This is realized in two steps (IMPLEMENTATION) provide mechanisms for describing data representations E.g. we provide the means for representing the notion of “day in year” (ABSTRACTION) provide mechanisms for hiding the (inessential and obscuring) details of the representation Thus, we allow access to “day in year” only through specifically meaningful operations like month , day , etc In particular, we do not allow manipulation directly through integer or record operations For now, we deal only with the first part through data representation; data abstraction is the topic of Chapter 6 Gopalan Nadathur Data Representation
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
The Role of Types Data representations are classified according to the following Sets of permitted values Sets of operations permitted on these values Each category under such a classification is referred to as a type Such a categorization is useful in determining appropriateness of expressions and also in the construction of new types Two relevant operations concerning types defining new types classifying cells (variables) according to the data they can hold Abstract data types provide a similar classification at the level of data objects Gopalan Nadathur Data Representation Type Related Operations Defining New Types Programming languages typically have mechanisms for constructing new types E.g. in Pascal there is an array type constructor : array [ index-type ] of element-type Type declarations then allow names to be associated with such constructed types E.g. in Pascal we can write type String = array[1..100] of char;
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 15

6data-representation_Nov01 - The Object of Study In many...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon bookmark
Ask a homework question - tutors are online