In this lesson, our instructor Alvin Sylvain gives an introduction to part two of functions. He starts by discussing the parameters by value and reference, as well as default parameters. He then moves on to return value, overloading and modularization.
function may have “call by value”
parameters, where the caller provides input
arguments for the function to work on. The function is free to
change the values of these parameters without affecting the caller.
Where possible, this is the preferred method to increase isolation
function may have “call by reference”
parameters, where the caller expects the
function to return new values for the input arguments.
function may have “call by address”
parameters, where the caller passes pointers
function may have default parameters
that provide a default value for any argument not provided by the
function usually has exactly one return
value, or the caller’s “answer”, that
will be used by the caller.
may be overloaded
which allows the same function name to be used with different
are crucial to creating modular code, avoiding code duplication,
allowing more readable and reusable code. Readable code is easier to
maintain. Reusable code saves time and effort. Modules should be
insulated from their containing systems to decrease external
dependencies, and increase reusability
Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.