Method stub
From Wikipedia, the free encyclopedia
This article needs additional citations for verification. Please help improve this article by adding reliable references. Unsourced material may be challenged and removed. (September 2007) |
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 = ThermometerReadIn() IF Temperature > 40 THEN PRINT "It's HOT!" END IF END
BEGIN ThermometerReadIn() RETURN 28 END ThermometerReadIn
The above pseudocode utilises the function 'ThermometerReadIn' that returns a temperature. While the function 'ThermometerReadIn,' would be intended to read some hardware device, this function currently does not contain the necessary code. So, 'ThermometerReadIn' does not, in essence, simulate any process, yet it does return a legal value, allowing the main program to be at least partly tested.