Routine
In software engineering, a "routine" refers to a set of instructions that perform a specific task. It's a fundamental concept in programming and is known by various names depending on the context and programming language being used. The most common terms for routines are functions, methods, procedures, and subroutines. Here's a brief overview of each:
Function:
A function is a routine that takes inputs (arguments), performs some computation or operation, and often returns a result. Functions are fundamental in functional programming languages but are used in almost all programming paradigms.
Method:
A method is similar to a function but is associated with an object or class in object-oriented programming. Methods often manipulate the data contained in the object they belong to or perform operations related to that object.
Procedure:
A procedure is a routine performing a specific task but not returning a value. This term is often used in procedural programming languages. In some contexts, "procedure" and "function" are used interchangeably, though technically, a function is expected to return a value.
Subroutine:
This term is often used interchangeably with "procedure" and "function". It refers to a program instruction sequence that performs a specific task, packaged as a unit. This unit can be used in several program parts or other subroutines.
Regardless of the specific term used, the primary purpose of these routines is to reduce code repetition, enhance modularity, and improve readability. By encapsulating specific functionalities into routines, programs become more organized and easier to understand, maintain, and debug. Routines also facilitate code reuse and can help implement abstraction, a key principle in software engineering.
The following books provide a comprehensive overview of fundamental programming concepts, including routines and their various forms in different programming paradigms. They are considered standard references in the field of computer science.
"Structure and Interpretation of Computer Programs" by Harold Abelson and Gerald Jay Sussman.
"Introduction to Algorithms" by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein.
"The Art of Computer Programming" by Donald E. Knuth.
Last updated