Category: 

What Is a Boilerplate Code?

Article Details
  • Written By: Mary McMahon
  • Edited By: Shereen Skola
  • Last Modified Date: 28 November 2016
  • Copyright Protected:
    2003-2016
    Conjecture Corporation
  • Print this Article
Free Widgets for your Site/Blog
Contrary to popular belief, monkeys do not eat bananas in the wild because the banana is a cultivated fruit.  more...

December 6 ,  1877 :  Edison demonstrated the first sound recording.  more...

Boilerplate code is stock programming language that can be used without alterations on multiple projects. Programmers can drop it in to perform various functions without manually coding for those activities. In some cases, it may accomplish a function through a roundabout way that takes up space and creates clunky, cluttered code. Programmers may prefer to seek out alternatives to boilerplate code in these situations to streamline their work and limit extraneous processes when their programs or commands are executed.

The origins of the term “boilerplate” lie in the flat plates used to stamp generic publicity advertisements that could be sent to multiple newspapers at once. Newspapers could quickly drop in a boilerplate promotion to fill space, without having to set type or make a new plate. As a slang term, “boilerplate” spread to the legal community, where it is commonly used in contracts, and eventually into programming to describe any generic, interchangeable text.

Programmers using boilerplate code can move it between projects without needing to change it. Some programming sites have a code library users can access to grab boilerplate code for various projects. Coders may also maintain their own reference libraries. Boilerplate in a variety of programming languages may be made available through libraries and reference texts. The templates are known to work, because they've been added to other projects, and can create a shortcut when a programmer needs to drop a function into a block of code.

Ad

One issue with using boilerplate code is that it may be redundant for a particular project. There may be an easier, more streamlined way to perform the desired function, if the coder is willing to write a new section. Sometimes boilerplate code may appear multiple times in a project to provide functionality when a single block of custom code might be more appropriate. Some programmers work to avoid excessive code in their projects to keep them lean and functional.

Other examples are included in all programming as a matter of custom and style. For example, programmers often include notes at the beginning of programs and commands to provide information about the programming language. These can offer warnings about how the code can and should be used, may discuss copyright issues, and can name the developer and provide contact information. This data is not strictly necessary for function, but may be included by the developer for stylistic reasons because it is expected.

Ad

You might also Like

Recommended

Discuss this Article

Post your comments

Post Anonymously

Login

username
password
forgot password?

Register

username
password
confirm
email