Lecture notes for the Introduction to Computer Science I by James Tam Return to the course web page

Defining New Types

Notes for the required material 

Optional teaching material

Background / Sources of additional information

Teaching Tips

Although many instructors teach the material in this section prior to talking about arrays I don't do this because in my opinion the introduction to composite types such as arrays is complicated enough without adding the additional complexity of learning about how to define a new types.   While there are some benefits to type-defining arrays (such as type checking) and in some cases it is mandatory in Pascal (when passing arrays as parameters to functions and procedures) it can also make the code harder to read.  When you see an instance of the new type you have to keep going back to the type definition in order to determine what that type consists of (e.g., to determine the boundaries for the type-defined array).