stub:桩;存根 skeleton:框架;骨架
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
distributed computing in addition to general software development and
testing.
A stub is this:
public String someMethod(int i) {
// yet to be implemented
return "a String";
}
Just a method that's declared, but not implemented. Skeleton IIRC is a class consisting of stubs.
> >Skeleton IIRC is a class consisting of stubs.
>
> IIRC ?
If I Remember Correctly.
No, the method's not implemented. It's just declared, and not in an interface, but not in a class. It has no usable body and always returns the same value. Would you think that
public Date getDateFromDatabaseTable(int key) {
// TODO needs to be implemented
return new Date();
}
counts as a valid implementation? Nope. But you might need the method in your design, to test your other classes or to implement an interface that requires it, even though the database isn't set up yet. It's simply a very minimal method declaration just so the compiler won't complain.
> It's just declared,
> and not in an interface,
but in a class.