Header
Home | Sitemap  
Sections
Archive
Su Mo Tu We Th Fr Sa
1
2345678
9101112131415
16171819202122
23242526272829
30
Syndication



Programmer-Defined Functions

by

image

 
Programmer-Defined Functions
Functions allow the programmer to modularize a program. All variables declared in function
definitions are local variables—they are known only in the function in which they are
defined. Most functions have a list of parameters that provide the means for communicating
information between functions via function calls. When a function is called, the arguments
in the function call are assigned to the corresponding parameters in the function
definition. A function’s parameters are also considered to be local variables.
Several motivations exist for modularizing a program with functions. The divide-andconquer
approach makes program development more manageable. Another motivation is
software reusability—using existing functions as building blocks to create new programs.
With good function naming, programs can be created from prepackaged functions rather
than being built using customized code. For example, we did not have to define how to convert
strings to integers and floating-point numbers—WMLScript already provides method
parseInt to convert a string to an integer and method parseFloat to convert a string
to a floating-point number. A third motivation is to avoid repeating code in a program.
Packaging code as a function allows that code to be executed at different points in a program
by calling the function.
Software Engineering Observation 16.2
Each function should be limited to performing a single, well-defined task and the function
name should effectively express that task. This promotes software reusability. 16.2
Software Engineering Observation 16.3
If you cannot choose a concise name that expresses what the function does, it is possible that
your function is attempting to perform too many diverse tasks. It is usually best to break such
a function into several smaller functions. 16.3
189 times read

Related news

» Program Modules in WMLScript
by admin posted on Aug 24,2007
» wml script functions
by admin posted on Aug 28,2007
» Duration of Identifiers(WML)
by admin posted on Aug 28,2007
» Function Definitions
by admin posted on Aug 28,2007
» Functions
by admin posted on Jul 19,2007


More Top News
Cisco Wireless Networking
Most Popular
Featured Author