What is stub?

Source: Internet
Author: User


Small knowledge point, I Google a bit, find some think more satisfied with the answer posted. For your reference.


Actually, if you know it's a substitute abbreviation, you can.


A stub is a small program routine this substitutes for a longer program, possibly to being loaded later or that's located re Motely. For example, a program that uses Remote Procedure Calls (RPC) are compiled with stubs that substitute for the program tha T provides a requested procedure. The stub accepts the request and then forwards it (through another program) to the remote procedure. When that procedure have completed its service, it returns the results or other status to the stub which passes it back to The program that made the request.


A routine that doesn ' t actually does anything other than declare itself and the parameters it accepts. Stubs is used commonly as placeholders for routines, still need to be developed. The stub contains just enough code to allow it to is compiled and linked with the rest of the program.


A stub is a controllable replacement a existing dependency (or collaborator) in the system. By using a stubs, you can test your code without dealing with the dependency directly.

The dependency here may refer to a function or class, and so on:

Anything that the code uses. It might help for understand if you re-read and replace ' dependency ' with ' class ' or ' function ' or whatever (depends on you R background).



A stub, in this context, means a mock implementation.

That's, a simple, fake implementation that conforms to the interface and was to being used for testing.

---------------------------------------------------------------------------------

A bit more professional explanation:

A stub, in the context of distributed computing, was a piece of code that's used to convert parameters during a remote pro Cedure Call (RPC). An RPC allows a client computer to remotely call procedures on a server computer. The parameters used in a function call has to is converted because the client and server computers use different address Spaces. Stubs perform this conversion so, the remote server computer perceives the RPC as a local function call.


Translation to do the relay or substitution, many for the machine automatically generated.


Stub libraries is generally installed on the client and server. Client stubs convert parameters used in function calls and reconvert the result obtained from the server after function ex Ecution. Server stubs, on the other hand, Reconvert parameters passed by clients and convert results to after function execution.


Stubs is generated either manually or automatically. In a manual generation, a remote procedure call implementer provides translation functions, from which a user constructs S Tubs. They handle complex parameter types. Automatic stub generation is commonly used to generate stubs. They use integration Description language to define client and server interfaces.



--------------------------------------------------------------------------------------------------------------- ------

A more Classic summary:

Https://en.wikipedia.org/wiki/Method_stub


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


An example of a stubs in pseudocode might is 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 is intended to read some hardware device, this function currently does not contain the Necessa Ry code. So Thermometerread does no, in essence, simulate no process, yet it does return a legal value, allowing the main program To is at least partially 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 does anything other than declaring itself and the parameters it accepts and re Turning something that's usually the values expected in one of the ' happy scenarios ' for the caller. Stubs was used commonly as placeholders for implementation of a known interface, where the interface was Finalized/known BU T the implementation is not yet known/finalized. The stub contains just enough code to allow it to is compiled and linked with the rest of the program. In RMI nomenclature, a stubs communicates on the server-side with a skeleton. [2]


Android Binder There is also a stub, if you understand binder, then the stub is well understood.

A more popular understanding is: " default generation, to be implemented "


That's it, not too much.


Merlin

2015/10/22

What is stub?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.