ch19 - Chapter 19: Program Design Chapter 19 Program Design...

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

View Full Document Right Arrow Icon
Chapter 19: Program Design All rights reserved. 1 Chapter 19 Program Design
Background image of page 1

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

View Full DocumentRight Arrow Icon
Chapter 19: Program Design Introduction Most full-featured programs are at least 100,000 lines long. Although C wasn’t designed for writing large programs, many large programs have been written in C. Writing large programs is quite different from writing small ones. All rights reserved. 2
Background image of page 2
Chapter 19: Program Design Introduction Issues that arise when writing a large program: Style Documentation Maintenance Design This chapter focuses on design techniques that can make C programs readable and maintainable. All rights reserved. 3
Background image of page 3

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

View Full DocumentRight Arrow Icon
Chapter 19: Program Design Modules It’s often useful to view a program as a number of independent modules. A module is a collection of services, some of which are made available to other parts of the program (the clients ). Each module has an interface that describes the available services. The details of the module—including the source code for the services themselves—are stored in the module’s implementation. All rights reserved. 4
Background image of page 4
Chapter 19: Program Design Modules In the context of C, “services” are functions. The interface of a module is a header file containing prototypes for the functions that will be made available to clients (source files). The implementation of a module is a source file that contains definitions of the module’s functions. All rights reserved. 5
Background image of page 5

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

View Full DocumentRight Arrow Icon
Chapter 19: Program Design Modules The calculator program sketched in Chapter 15 consists of: calc.c , which contains the main function A stack module, stored in stack.h and stack.c calc.c is a client of the stack module. stack.h is the interface of the stack module. stack.c is the implementation of the module. All rights reserved. 6
Background image of page 6
Chapter 19: Program Design All rights reserved. 7
Background image of page 7

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

View Full DocumentRight Arrow Icon
Chapter 19: Program Design Modules The C library is itself a collection of modules. Each header in the library serves as the interface to a module. <stdio.h> is the interface to a module containing I/O functions. <string.h> is the interface to a module containing string-handling functions. All rights reserved. 8
Background image of page 8
Modules Advantages of dividing a program into modules: Abstraction Reusability Maintainability All rights reserved.
Background image of page 9

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

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

Page1 / 82

ch19 - Chapter 19: Program Design Chapter 19 Program Design...

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

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