Confused about whether to use "stub on" or "stub in"? You're not alone. These phrases, while similar, serve different purposes and have distinct usage. Let's dive in to clear up the confusion.

The stems of these phrases, "stub" and "stub out," are in fact the same. A "stub" generally refers to a protruding piece, typically used to indicate a small amount or unfinished task. "Stub out" is often used in programming to temporarily stop execution, hence "stub it out." However, the primary difference lies in what follows "stub."

"Stub on"
Using "stub on" is common in contexts where one wants to emphasize the addition or attachment of a stub. For instance, in carpentry, you might "stub on a board to an existing shelf" to extend it.

This usage is also prevalent in networking, especially when referring to stub networks. A "stub network" is a network defined or 'stubbed' by a boundary router within a larger network. In this context, you might say, "set up a stub network on the main router."
Stubbing software

"Stub on" is also used in software methodology, especially in unit testing. Here, a "stub" is a simple substitute for a component in a system under development, providing canned responses rather than actual responses.
For instance, you might "stub on a function in the testing phase" to isolate and test another component of the system. This scenario is particularly useful when the function you want to stub on is complex or not ready for testing yet.
Stub on in everyday usage

In everyday conversations, "stub on" might be used to describe tripping on something. For example, "I stubbed on the rug and nearly twisted my ankle." The usage here is about coming into contact with or being caused to move by something, much like the other uses of "stub on."
Here's an example in a more figurative sense: "My friend stubbed on a great deal during our shopping trip and saved a lot of money." In this case, "stubbed on" means 'chanced upon' or 'found unexpectedly.'
"Stub in"

On the other hand, "stub in" emphasizes, not the addition or attachment, but the action of inserting or locating something within.
For instance, you might "stub in a nail to hang a picture" or "stub in a cable to connect your device." It's also used to describe the action of removing seeds from a fruit, like "stubbed in the grapes for wine making."










Stubbing for interchangeability
In programming, "stub in" or "stubbing in" might refer to replacing certain parts of the code with a version that will not fail the test or cause errors. This is somewhat different from the "stub on" concept in testing, which generally focuses on replacing or mocking whole components.
Here's an example: "Stub in a section of the code to ensure the rest of the program runs smoothly during this test phase."
Stubbing in experiments
"Stub in" might also refer to experiments or studies. For example, in scientific research, if you are studying the effects of a drug, you might "stub in the drug to the test subject." This usage is about introducing something into a situation to observe effects.
On a smaller scale, you might "stub in a new plant into your garden" to see how it grows and takes to its new environment.
In conclusion, while "stub on" and "stub in" may seem like a subtle difference, they implement distinct actions. "Stub on" is about addition or contact, while "stub in" focuses more on insertion or location. It's all about context, folks, so choose wisely!