Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Sometimes in a programming exercise, boilerplate generation, putting guide rails around the tasks for a junior programmer to implement, etc., it happens that the programmer is presented unimplemented code and told to "fill in the blank." For example, a unit test that may compile, but fails, or a class declaration with empty methods.

Is there a common term for this practice?

share|improve this question
Not exactly what you're asking, but related. If there are also test scripts in place which show what your code is expected to do, then it's known as Test Driven Development. – AJFaraday Mar 9 at 0:54
To whomever voted to close: sure, "name this thing" might not be an especially interesting question. However, this question does have an objective answer that is not primarily opinion-based. As proof, I present my answer below. – Snowman Mar 9 at 6:29
I would say "Terrible coding practice." – Euphoric Mar 9 at 7:33
NotImplementedException :) – David Grinberg Mar 9 at 12:50
"Exercise for the reader" seems to be the textbook approach if you're talking about error handling. – Phil Lello Mar 9 at 22:07
up vote 174 down vote accepted

You are referring to a stub or skeleton:


This is typically a method or function with a mostly-empty body that simply returns a dummy value so code will compile.


This is a method that has a high-level algorithm implemented, but individual parts are left unimplemented. They may be empty code blocks, or reference stub methods (see above) that will eventually perform subtasks. This is a good way to express a software design for a junior programmer who may struggle with the larger design effort, or for making sure you have the algorithm correct before investing too much time in the low-level details.

The practice of using these code elements would be called stubbing or creating a code skeleton.

share|improve this answer
Although I like your terms better, I think that the term 'scaffolding' in Ruby on Rails is the same concept. – dcorking Mar 9 at 13:36
I also thought stub was the right word for this, but was not sure because I was getting push back from others at my job. Thank you. – Brandon Arnold Mar 9 at 15:29
It's a "stub" if done in an academic context. Done in a professional/commercial context, it's "technical debt". – aroth Mar 10 at 5:09
@aroth it is not technical debt if the code does not work - it must be implemented. Technical debt implies poorly written code that ends up being used in a production environment, meaning it requires significant effort to refactor correctly. A stub would ideally have a failing test case, so it must be implemented and tested before being set loose on production. – Snowman Mar 10 at 5:13
@BrandonArnold: When talking to your colleges, you should use words they understand. Unless you are the boss. – Stig Hemmer Mar 10 at 8:39

I've seen the term “stub” being used.

For example, I believe that Eclipse automatically inserts a comment

String getName() {
    // TODO: Auto-generated method stub
    return null;

into its infamous auto-generated, well, stubs.

Also note the usage of the term “stub” in the context of unit testing.

share|improve this answer
"// TODO: Auto-generated method stub" I think. – immibis Mar 9 at 3:38
Definitely useful to know this. . . – Brandon Arnold Mar 9 at 15:30

In Visual Studio, when writing code intellisense will give you the option "generate a new method stub". When you choose this option, Visual Studio will generate a stub/skeleton of code exactly as you have described.

Microsoft refers to this as a stub, so I would also call these stubs.

share|improve this answer

Resharper uses hot spots in it's implementation of snippets.

These are tabbable areas of code that you are supposed to complete yourself; that being, they are slightly more functional that just a comment saying TODO: write here. They'll often update other bits of code as you type.

share|improve this answer
In most contexts, "hot spot" would probably mean a performance bottleneck in the code — parts of the program where it spends most of its execution time. – 200_success Mar 9 at 17:23

protected by MichaelT Mar 10 at 17:19

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.