Method stub explained

A method stub[1] is a short and simple placeholder for a method that is not yet written for production needs. Generally, a method stub contains just enough code to allow it to be used a declaration with any parameters, and if applicable, a return value.[2]

A method stub may be used to implement an interface that is defined but for which the implementation is not available.

Example

In the following example pseudocode, the function returns a particular value even though ultimately it is supposed to read a value from a hardware source. It returns a valid value, allowing consuming code to be runnable. The function ignores the input parameter which is common for a stub.

function ReadThermometer(Source source) return 28 end function

Related

Distributed computing

In distributed computing, stub is like a mock object simulates existing code, such as a procedure on a remote machine. Such stubs can be useful in porting.

In RMI nomenclature, a stub on the client-side communicates with a skeleton on the server-side.[3]

Windows/DOS

In Windows and DOS, stub is like a shim small interface code left in conventional memory by self-relocating resident drivers which move most of themselves into upper memory, the high memory area, expanded or extended memory as well as similar stubs to allow the relocated code to communicate with real-mode DOS in conjunction with DOS extenders (like DPMI, DPMS, CLOAKING or NIOS).

See also

External links

Notes and References

  1. Book: Nell B. Dale. Chip Weems. Programming in C++. 2004. Jones & Bartlett Learning. 978-0-7637-3234-9. 308.
  2. Web site: stub . 23 March 1998 . WEBOPEDIA . 2012-08-28.
  3. Book: Freeman . Eric . Freeman . Elisabeth . Kathy . Sierra . Bert . Bates . Hendrickson . Mike . Loukides . Mike . 2004 . Head First Design Patterns . 1 . 440 . O'REILLY . paperback . 978-0-596-00712-6 . 2012-08-28 .