Take the 2-minute tour ×
English Language & Usage Stack Exchange is a question and answer site for linguists, etymologists, and serious English language enthusiasts. It's 100% free, no registration required.

I am not very clear about the word boilerplate when it comes to programming. How is it different to other similar terms such as template and prototype? I would appreciate some examples that clearly explain the difference.

share|improve this question
Isn't this question more appropriate to SO? –  Em1 Nov 2 '12 at 14:01
@Em1 I would tend to disagree, since it is purely a question on English terminology. "How do you write boilerplate code?" is more like something that belongs on SO. –  Ataraxia Nov 2 '12 at 14:22
What these terms mean in the context of programming, as the OP clearly sets out in his question, is in the expertise of SO. –  Kris Nov 2 '12 at 14:48
IMHO, nine times out of ten, boilerplate is dismissive/derogatory, and this is a more significant difference than the finer semantic distinctions between OP's three terms, since the other two are invariably either positive or at least neutral. –  FumbleFingers Nov 2 '12 at 15:21
I would see this better at programmers.SE than here. But then again it got moved from there in the first place... –  MPelletier Nov 2 '12 at 16:00
add comment

4 Answers

Well, this is the meaning of the three words you asked, in a programming context:

Template: it is usually referred in web design or programming as a base you take to make your own fixes. But you do not usually use a template witouth your own fixes/changes.

Prototype: this word is quite different since it refers to the small work you code before making the final proyect. It is like a previous test to check if your idea is going to work in the right way or if you should check for an alternative.

Boilerplate: this is not really different, but we say some piece of code is a boilerplate if you are going to include it in several differents places of your entire project (they can also be called includes). For example, you may have a programm that shows products for a catalog, and you've created a function to show the product image. When you include this function in all the files where you are going to execute it, you can say this function is your boilerplate. Or in C programming, they call it “headings boilerplate” when they include all the basic libraries in their code.

Note that in the general case, template is something you take from others (posted on the Internet, for example), while prototype or boilerplate is something you make on your own.

share|improve this answer
Please do not use backticks on ELU: it looks horrible. Carefully use italics when necessary, but avoid making things look like ransom notes. Thank you. –  tchrist Nov 2 '12 at 14:13
I would not say that the function is "part of the boilerplate". boilerplate is text that is literally inserted wherever it is needed. The "header boilerplate" you mention is a good example. you just copy this huge block of headers stuff into your source. But you don't copy the function. You call it. It's part of a library. The bit of text that includes/loads/references that library is boilerplate. The copyright comments at the top of every file are boilerplate. A template might contain lots of boilerplate code or might require you to write some boilerplate code. –  Mr. Shiny and New 安宇 Nov 2 '12 at 14:36
Thank you, I said it is a part because some definitions say the boilerplate is the whole included stuff (and the function might not be the whole included stuff on this specific project). –  Lucky Horse Nov 2 '12 at 14:42
@tchrist Oh dear, I am a prime offender. I am an increasingly ardent fan of backticks. They do look much worse on ELU than other SE sites. You are correct. Yet the "ransom note" effect is so dramatic ;o) in lieu of a full-blown rebus. –  Feral Oink Nov 19 '12 at 19:54
add comment

Boilerplate has a negative connotation and refers to repetitive code that does't really contribute to the logic of the program, but is required by the language or the framework. It indicates tedium and a violation of the "Don't Repeat Yourself" programming ethos.

For example, in Java, it's common to provide getter and setter methods to access certain properties on an object. Say we want a class to represent brands of hot sauce:

class HotSauce {
   String name;
   float scovilleRating;

This is a simple data object without any real internal logic. However, the standard practice is to provide "getter" and "setter" methods in case we want to add logic later or use the object with frameworks that make use of the getter and setter pattern:

public class HotSauce {
    private String name;
    private float scovilleRating;

    public String getName() {
        return name;

    public void setName(String name) {
        this.name = name;

    public float getScovilleRating() {
        return scovilleRating;

    public void setScovilleRating(float scovilleRating) {
        this.scovilleRating = scovilleRating;

These methods are boilerplate. They take up most of the file, yet they contain no real logic and do not tell us anything more about the HotSauce class. They are tedious to write, and are often automatically generated by the editor program.

Boilerplate can also come from a buildup of declarations that normally save effort. For example, when using the Spring framework with Java, one must declare several things at the top of every unit test class:

public class BoilerPlateExampleTest {

    public void testExample() throws Exception {
        // ...

The declarations at the top of the file convey important information: that we want these tests to be Spring-enabled, and to be initialized in the given context with the given active profile. The Spring framework uses those lines to do a great deal of initialization, yet they are still a bit verbose, and they must be repeated at top of every test class. Thus, even though they are useful, they become boilerplate.

share|improve this answer
add comment

In the context of programming, I do not believe that boilerplate is strictly a technical term like prototype and template.

An actual boilerplate is something that was placed on a boiler. It is usually pre-printed with the exception of a serial number, boiler capacity, etc. In this respect, it is closer to a template.

share|improve this answer
boilerplate was standard text made up for printing. It is called boiler plate because it's a big heavy curved bit of metal, on an original printing press, like the rolled steel plates to make a boiler. It's also a bit derogatory - it's boring crude pointless text rather the importnt content –  mgb Nov 2 '12 at 15:46
add comment


  • a template is a pattern in which some few items can be modified. The general structure is preserved but free changing items are inserted at specific places. This can be used for non-text things like a graphical layout or an artistic pattern.

  • boilerplate (a mass noun) is simply an unchanging piece of text. It is inserted as is without change.

With respect to programming, a template can have a very technical meaning, which usually involves a class that has some type parameters, and boilerplate is just a piece of code that is inserted verbatim (both these uses respect the non-technical meanings).

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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