1. Why user-defined types are needed
A user-defined data type is one the programmer creates, rather than a type built into the language.
The purpose is to create a new data type (from existing data types). The language may not have the type the application needs, so the programmer builds it. A user-defined type holds a particular group of data under a single identifier, and it makes the code easier to understand.
A user-defined type is either non-composite or composite. Enumerated and pointer types are non-composite. Record, set and class/object types are composite.
Examiner insight
Worked example 13 marks
User-defined data types may be created by programmers when writing software.
Explain the reasons why user-defined data types are needed.
- 1
The programmer may require a data type for their application that doesn't exist within the programming language. [1]
- 2
It lets them represent a particular group of data, a custom data structure, under a single identifier. [1]
- 3
They can extend the types already there using composite data types, which makes the code easier to understand. [1]