Learn something new every day
More Info... by email
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.
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.
One of our editors will review your suggestion and make changes if warranted. Note that depending on the number of suggestions we receive, this can take anywhere from a few hours to a few days. Thank you for helping to improve wiseGEEK!