subroutine
Học thuậtThân thiện
Definition
- Noun:
- A set sequence of steps, part of a larger computer program: A
subroutineis a self-contained block of code within a larger program that performs a specific, well-defined task. It is designed to be called or invoked from other parts of the program, often multiple times, to promote code reusability and organization.
Usage Examples
- Noun:
- The programmer wrote a
subroutineto calculate the average of a list of numbers. - To sort the data, the main function calls a dedicated sorting
subroutine. - Debugging is easier when complex tasks are broken down into separate
subroutines.
Advanced Usage
"To call a subroutine": To execute the code within a subroutine from another part of the program.
- The main algorithm calls the validation
subroutinebefore processing the input.
"To define a subroutine": To write and name the block of code that constitutes the subroutine.
- She defined a new
subroutineto handle user authentication.
Variants and Related Words
Subprogram (n): Another term for subroutine.
- Functions and procedures are types of subprograms.
Function (n): A type of subroutine that typically returns a value.
- Procedure (n): A type of subroutine that performs an operation but may not return a value.
- Method (n): In object-oriented programming, a subroutine associated with an object or class.
Synonyms
- Module: A separable component, often interchangeable with subroutine in modular programming.
- Routine: A general term for a sequence of instructions performing a task.
Related Phrases
Library routine: A pre-written subroutine stored in a library for common use.
- The software uses a library
subroutinefor advanced mathematical operations.
Recursive subroutine: A subroutine that calls itself as part of its operation.
- The factorial calculation was implemented as a recursive
subroutine.
Noun
- a set sequence of steps, part of larger computer program