Windows DatabaseebooksStatistical Information

LLE10268 : What is a software stub?


you would like to know what a stub is an how it can be used




A stub is a piece of code used to replace another programming functionality. (e.g. a Procedure for function) Instead of the original source code, the stub will be called. The software stub may simulate the existing behavior or even do nothing at all. In the latter case, you can think of using a stub as a temporary piece of software yet to be written. Stub are usefull in porting and testing software.

An example of a stub in c++ might be:

int GetWindSpeed(void)
    cout << "Here you connect to the device and get the speed back." << endl;
    cout << "Stub returns always 4!" << endl;

    return 4;

In the case above, you can compile and test your software without even having a hardware device. It just returns a "legal" value.

Most of the time you can think of a stub as a piece of code which declares a function with parameters the real function accepts. A kind of a placeholder with a known interface to make it possible to compile and link your application.


The information provided in this document is intended for your information only. Lubby makes no claims to the validity of this information. Use of this information is at own risk!
Copyright © 2004-2011 Lubby (V3.0.10 Aug 2011)
Sponsored by Keskon.
Statistical information by Google Analytics