1402 20 - 3/18/2010 COMP1002/1402...

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

View Full Document Right Arrow Icon
3/18/2010 1 COMP 1002/1402 Introduction to Systems Programming Chapter 20: Writing Generic Code Notes Adapted from Dr. J. Morrison, Dr D. Nussbaum Purpose Often code is designed as a special purpose Examples : Linked lists of students Sorting functions of students Result Repetitive implementation A large amount of code to be maintained Maintenance is expensive and time consuming COMP1002/1402 - Chapter 20: Writing Generic Code 2
Background image of page 1

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

View Full DocumentRight Arrow Icon
3/18/2010 2 Objectives Create generic code that can be reused . The code can be used to generate a variety of data types. Ensure that all bugs are fixed only in one place. Examples Having a single linked list code that can be used for any data type. Sorting routing that can sort in any array. COMP1002/1402 - Chapter 20: Writing Generic Code 3 What is Needed A mechanism for transferring knowledge about the specific details of the data type without interference with the regular execution of the module. A mechanism for writing generic code without the a priori knowledge of future usage. COMP1002/1402 - Chapter 20: Writing Generic Code 4
Background image of page 2
3/18/2010 3 Void data type Void plays two roles in C: Signals the system that no parameters are to be transferred or that no value is returned: int rand( void ) void rewind(FILE *fp) Signals the system that an unknown type is to be used. The user will make sure proper usage.
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/11/2010 for the course COMP 1402 taught by Professor Sprite during the Spring '10 term at Carleton CA.

Page1 / 9

1402 20 - 3/18/2010 COMP1002/1402...

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

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