{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Functions, Scope, Modular Programming

Functions, Scope, Modular Programming - Function...

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

View Full Document Right Arrow Icon
Functions, Scope, Modular Programming Muldner, Chap. 7
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
7: Preview - a review of functions - modularization of programs: multiple files & separate compilation - scope rules - introduction to module based programming: header files for representing interfaces encapsulation of data in a file kinds of modules
Background image of page 2
7: Functions and Their Documentation A C program consists of one or more function definitions, including exactly one that must be called main The syntax for C functions is the same as the syntax for Java methods All functions are stand-alone , which means that they are not nested in any other construct, such as a class
Background image of page 3

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

View Full Document Right Arrow Icon
7: Function Declaration and Definition A declaration merely provides a function prototype: function header (includes the return type and the list of parameters) void hex(unsigned char *p, int max); The declaration does not say anything
Background image of page 4
Function documentation
Background image of page 5

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

View Full Document Right Arrow Icon
Background image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Function documentation • Function declaration or definition (or both) should be preceded by documentation : • Function : name • Purpose : a general description of the function • (typically, this is a description of what it is supposed to do) • Inputs : a list of parameters and global variables read in the function • Returns : value to be returned • Modifies : a list of parameters and global variables that are • modified - describes any side-effects • Function documentation • Documentation may also include a Bugs section, which documents cases that the implementation does not handle. • Make sure comments and code agree • In general, a function definition should not exceed one page. Code should be broken up; in particular, lines which are too long should be avoided....
View Full Document

{[ snackBarMessage ]}