Method stub

Method stub

A method stub or simply stub in software development is a piece of code used to stand in for some other programming functionality. A stub may simulate the behavior of existing code (such as a procedure on a remote machine) or be a temporary substitute for yet-to-be-developed code. Stubs are therefore most useful in porting, distributed computing as well as general software development and testing.

An example of a stub in pseudocode might be as follows:

   BEGIN
       Temperature = ThermometerRead(Outside)
       IF Temperature > 40 THEN
            PRINT "It's HOT!"
       END IF
   END
   BEGIN ThermometerRead(Source insideOrOutside)
        RETURN 28
   END ThermometerRead

The above pseudocode utilises the function ThermometerRead, which returns a temperature. While ThermometerRead would be intended to read some hardware device, this function currently does not contain the necessary code. So ThermometerRead does not, in essence, simulate any process, yet it does return a legal value, allowing the main program to be at least partly tested. Also note that although it accepts the parameter of type Source, which determines whether inside or outside temperature is needed, it does not use the actual value passed (argument insideOrOutside) by the caller in its logic.

A stub[1] is a routine that doesn't actually do anything other than declare itself and the parameters it accepts and returns something that is usually the values expected in one of the "happy scenarios" for the caller. Stubs are used commonly as placeholders for implementation of a known interface, where the interface is finalized/known but the implementation is not yet known/finalized. The stub contains just enough code to allow it to be compiled and linked with the rest of the program.

See also

References

External links


Wikimedia Foundation. 2010.

Игры ⚽ Нужно сделать НИР?

Look at other dictionaries:

  • Stub — may refer to: * Stub or stubb, a low pollard, a tree cut and allowed to regrow from the trunk (the origin of most other meanings) *Method stub, in computer programming, a piece of code used to stand in for some other programming functionality… …   Wikipedia

  • Method of Fluxions — is a book by Isaac Newton. The book was completed in 1671, and published in 1736. Fluxions is Newton s term for differential calculus (fluents was his term for integral calculus). He originally developed the method at Woolsthorpe Manor during the …   Wikipedia

  • Method of support — In statistics, the method of support is a technique that is used to make inferences from datasets. According to A. W. F. Edwards, the method of support aims to make inferences about unknown parameters in terms of the relative support, or log… …   Wikipedia

  • Method of Four Russians — In computer science, the Method of Four Russians is a technique for speeding up algorithms involving Boolean matrices, or more generally algorithms involving matrices in which each cell may take on only a bounded number of possible values.… …   Wikipedia

  • Method of simulated moments — In econometrics, the method of simulated moments (MSM) (also called simulated method of moments[1]) is a structural estimation technique introduced by Daniel McFadden[2]. It extends the generalized method of moments to cases where theoretical… …   Wikipedia

  • Method of continuity — In the mathematics of Banach spaces, the method of continuity provides sufficient conditions for deducing the invertibility of one bounded linear operator from that of another, related operator. Contents 1 Formulation 2 Applications 3 Proof 4 …   Wikipedia

  • Method of averaging — In the study of dynamical systems, the method of averaging is used to study certain time varying systems by analyzing easier, time invariant systems obtained by averaging the original system. Definition Consider a general, nonlinear dynamical… …   Wikipedia

  • Disk-covering method — A disk covering method is a divide and conquer meta technique for large scale phylogenetic analysis which has been shown to improve the performance of both heuristics for NP hard optimization problems and polynomial time distance based methods.… …   Wikipedia

  • Java Remote Method Invocation — Este artículo o sección necesita una revisión de ortografía y gramática. Puedes colaborar editándolo (lee aquí sugerencias para mejorar tu ortografía). Cuando se haya corregido, borra este aviso por favor. RMI (Java Remote Method Invocation) es… …   Wikipedia Español

  • Neumann–Dirichlet method — In mathematics, the Neumann–Dirichlet method is a domain decomposition preconditioner which involves solving Neumann boundary value problem on one subdomain and Dirichlet boundary value problem on another, adjacent across the interface between… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”