Null Function
   HOME

TheInfoList



OR:

In
computer science Computer science is the study of computation, information, and automation. Computer science spans Theoretical computer science, theoretical disciplines (such as algorithms, theory of computation, and information theory) to Applied science, ...
, a null function (or null operator) is a
subroutine In computer programming, a function (also procedure, method, subroutine, routine, or subprogram) is a callable unit of software logic that has a well-defined interface and behavior and can be invoked multiple times. Callable units provide a ...
that leaves the
program state In information technology and computer science, a system is described as stateful if it is designed to remember preceding events or user interactions; the remembered information is called the state of the system. The set of states a system can oc ...
unchanged. When it is part of the
instruction set In computer science, an instruction set architecture (ISA) is an abstract model that generally defines how software controls the CPU in a computer or a family of computers. A device or program that executes instructions described by that ISA, s ...
of a processor, it is called a NOP or NOOP (No OPeration). Mathematically, a (computer) function f is null if and only if its execution leaves the program state s unchanged. That is, a null function is an
identity function Graph of the identity function on the real numbers In mathematics, an identity function, also called an identity relation, identity map or identity transformation, is a function that always returns the value that was used as its argument, unc ...
whose
domain A domain is a geographic area controlled by a single person or organization. Domain may also refer to: Law and human geography * Demesne, in English common law and other Medieval European contexts, lands directly managed by their holder rather ...
and
codomain In mathematics, a codomain, counter-domain, or set of destination of a function is a set into which all of the output of the function is constrained to fall. It is the set in the notation . The term '' range'' is sometimes ambiguously used to ...
are both the
state space In computer science, a state space is a discrete space representing the set of all possible configurations of a system. It is a useful abstraction for reasoning about the behavior of a given system and is widely used in the fields of artificial ...
S of the program, and for which: f(s)=s for all elements s \in S. Less rigorous definitions may also be encountered. For example, a function may take a single operand, transform it into a new
data type In computer science and computer programming, a data type (or simply type) is a collection or grouping of data values, usually specified by a set of possible values, a set of allowed operations on these values, and/or a representation of these ...
, and return the result.Example of a
type conversion In computer science, type conversion, type casting, type coercion, and type juggling are different ways of changing an expression from one data type to another. An example would be the conversion of an integer value into a floating point val ...
function labeled as a "null function"
_NULLF - null function.
/ref> While such usages bear a strong visual resemblance to identity functions, they create or alter a binary data value and thus change the program state. From a software maintainability perspective it is better to identify such "minor" alternations of state explicitly, since calling them null functions provides future maintainers of the code with no insights on their actual purposes.


Uses

Null functions have several uses. During
software development Software development is the process of designing and Implementation, implementing a software solution to Computer user satisfaction, satisfy a User (computing), user. The process is more encompassing than Computer programming, programming, wri ...
, null functions with the same names and
type signature In computer science, a type signature or type annotation defines the inputs and outputs of a function, subroutine or method. A type signature includes the number, types, and order of the function's arguments. One important use of a type sign ...
s as a planned functions are often used as
stub Stub or Stubb may refer to: Shortened objects and entities * Stub, a tree cut and allowed to regrow from the trunk; see pollarding * Pay stub, a receipt or record that the employer has paid an employee * Stub period, period of time over which i ...
s—that is, as non-functional placeholders that allow the incomplete body of code to be compiled and tested prior to completion of all planned features. Null functions, particularly the NOP variety, are also used to provide delays of indeterminate length within wait loops. This is a common strategy in dedicated device controllers that must wait for an external input and have no other tasks to perform while they are waiting. Such wait loops are also used in
software applications Application software is any computer program that is intended for end-user use not operating, administering or programming the computer. An application (app, application program, software application) is any program that can be categorized as ...
on larger
multiprocessing Multiprocessing (MP) is the use of two or more central processing units (CPUs) within a single computer system. The term also refers to the ability of a system to support more than one processor or the ability to allocate tasks between them. The ...
computer systems. However, for multiprocessing systems a better approach is to use
operating system An operating system (OS) is system software that manages computer hardware and software resources, and provides common daemon (computing), services for computer programs. Time-sharing operating systems scheduler (computing), schedule tasks for ...
functions that let other processes use the
CPU A central processing unit (CPU), also called a central processor, main processor, or just processor, is the primary processor in a given computer. Its electronic circuitry executes instructions of a computer program, such as arithmetic, log ...
during the waiting period. A third use of null functions is as the definition of a program feature that, if created inadvertently, is almost always deleterious. Unintended null functions can arise during the development of complex programs, and like
dead code The term dead code has multiple definitions. Some use the term to refer to code (i.e. instructions in memory) which can never be executed at run-time. In some areas of computer programming, dead code is a section in the source code of a program whi ...
, such occurrences indicate serious flaws in program structures. A null function or method is often used as the default behavior of a revectorable function or overrideable method in an object framework.


See also

* IEFBR14


References


External links

* Makes humorous statements about the NULL encryption algorithm. {{DEFAULTSORT:Null Function Subroutines