Creating Functions
New Terminology
- class
- Container that holds the template for objects or
provides services to another class
- void method
- A method that carries out an action and returns nothing
- value returning method
- A method that carries out an action and returns a value to
the calling program.
- invocation
- Calling a method during program execution
- qualified name
- An identifier which uses the name of a class or an object
to specify the location of the identifier.
- pass by value
- A term which describes the process of passing an actual
parameter to a formal parameter in which the value of the actual
parameter is copied into the formal parameter container.
Programming specific structures and terms
- method header
- The introduction of the method. The header contains all of
the information the compiler needs to use the method.
- method body
- The code that carries out the action of the method.
- method modifiers
- The keywords of public and static which identify the
visibility and the useage respectively
- return type
- The datatype of the value returned by a method. In the case
of a void method, the datatype is replaced by the keyword,
void
.
- method identifier
- The name of the method. By convention, method identifiers
begin with a small letter and use capital letters or underscore
characters to separate words.
- formal parameter list
- The list of variable declarations that accept values from
the calling program into the method.
return
- A keyword in java that signifies the beginning of a return
statement.
@param
tag
- The tag (one per formal paramter) which describes the
method arguments
@return tag
- The tag that describes the return type of a method. Not
used in the case of a void method.
- stack trace
- The display of method calls produced when java encounters
an unhandled run-time exception.
- exception
- An error in the execution of a program.
- stub
- A method with a final header and appropriate return type
which
can be used to test other parts of the program. It returns a
value appropriate to the method return type.
Class notes
- Method examples n1006.ppt
- SimpleMethod.java
- Creating a method in a different class. (SimpleDriver.java, SimpleContainer.java)
- DeepAndDeeper.java
- PassArg.java
- LocalVars.java
- PassString.java
- ValueReturn.java
- Documenting methods
- @param tags
- @return tags
- Preview tomorrow lab - Will be working in teams of two for
tomorrow's lab.
- Design issues for methods. Looking for
patterns...chunking a program into functional units. Who are
the players? Example.java