What is boilerplate code

What is boilerplate code?


No employee had ever heard of it and I couldn't really provide a definition. For me it has always been an example of "I know when I see it".

Bonus question, who came up with the term?






Reply:


"Boilerplate code" is seemingly repetitive code that is displayed over and over to produce a result that seems a lot simpler.

It's a subjective definition.

The term comes from "boilerplate" in the newspaper industry: Wiki




On the etymology the term Boilerplate : from http://www.takeourword.com/Issue009.html ...

Interestingly, the term originated from the newspaper business. Columns and other pieces that were syndicated were mailed to subscribing newspapers in the form of a mat (ie, matrix). Upon receipt, boiling lead was poured into this mat to create the plate used to print the piece, hence the name Boilerplate. Because the item printed on a boiler plate could not be changed, the term has been used by lawyers to refer to the parts of a contract that have not changed from repeated use in different applications, and ultimately to the language in general, the Has not changed Any document that has been used repeatedly for different occasions.

What are the features of boilerplate in programming? As others may have pointed out, this is just part of the code that is copied over and over with no changes made.




Boilerplate code means code that can be used over and over again. On the other hand, anyone can say that it is reusable code.

The term actually comes from the steel industry.

For a little bit history according to Wikipedia:

In the 1890s, boilerplate was actually cast or stamped in metal for the printing press and distributed to newspapers in the United States. By the 1950s, thousands of newspapers received and used this type of hot plate from the country's largest supplier, the Western Newspaper Union. Some companies also sent out press releases as a boiler plate, so they had to be printed as written.

Loud now Wikipedia :

In object-oriented programs, classes are often provided with methods for getting and setting instance variables. The definitions of these methods can often be viewed as a boilerplate. Although the code varies from class to class, its structure is sufficiently stereotypical that it is better to generate it automatically than to write it by hand. For example, in the following Java class that represents a pet, almost all of the code, except for the pet, name, and owner declarations, is a boilerplate:


It is code that can be used by many applications / contexts with little or no change.

Boilerplate originated in the steel industry in the early 1900s.


From Wikipedia:

In computer programming, boilerplate is used to describe sections of code that must be included in many places with little or no changes. It is more commonly used when referring to languages ​​that are considered verbose, that is, the programmer has to write a lot of code to do minimal jobs.

Basically you can Boilerplate code as text that a programming language uses very often around the programs that you write in that language.

Modern languages ​​try to reduce this, but so does the older language with special type checkers (for example, OCaml has a type inferrer that allows you to avoid so many declarations that are boilerplate code in a more verbose language like Java ).


Good programmers avoid boilerplate: repetition.




Boilerplate in software development can mean different things to different people, but generally means the block of code that is used over and over again.

In the MEAN- Stack development, this term refers to the generation of code using templates. It's easier than hand-coding the entire application from scratch, and it gives the code block consistency and fewer bugs because it's clean, tested, and proven code, and it's open source, so it's constantly being updated or fixed, which a lot of time is saved when using the framework or code generator. Further information on the MEAN stack can be found here.


In practice, boilerplate code is what you cut and paste anywhere. Often times it's things like a module header and some standard / required declarations (every module has to declare a logger, every module has to declare variables for its name and revision, etc.) In my current project we write message handlers and they all have the same structure (read, validate, process a message) and to remove dependencies between the handlers, we didn't want them all to inherit from a base class, so we developed a boilerplate skeleton. All routine variables, the standard methods and the framework for exception handling have been declared. All a developer had to do was add the code that is specific to the message being handled. It would have been quick and easy to use


The definition of boiler plates is becoming more global in many other programming languages ​​these days. It comes from OOP and hybrid languages ​​that have become OOP and before the procedure had the same goal of repeating the code you create with a model / template / class / object over and over, which is why they use this term to adjust. You create a template and the only things you do for each instance of a template are the parameters for customizing an object. This part is called the boiler plate. You simply reuse the code from which you created a template, just with different parameters.

Synonyms
A blueprint is a boilerplate.
A template is a boiler plate.
A footer is a boilerplate.
A design pattern for multiple uses is a boilerplate.
A signature of a mail is a boilerplate



Of whatis.techtarget.com :

In information technology, a boilerplate is a writing unit that can be used over and over again without being changed. In a broader sense, the idea is sometimes applied to reusable programming, as in "boilerplate code". The term is derived from steelmaking, where the boiler plate is made of steel that is rolled into large plates for use in steam boilers. The implication is either that the writing on the boiler plate is tried and tested and strong as "steel", or that it may have been rolled out into something strong enough for repeated reuse.

Beyond programming:

A boilerplate can be compared to a certain type of template, which can be viewed as a boilerplate for filling in the gaps. Some typical boiler labels are: mission statements, safety warnings, commonly used installation procedures, copyright notices, and disclaimers.

In my experience as a programmer, the right kind of boilerplate code is usually a lot of code to start with that isn't big and / or complicated enough to be called a framework.

That would be a typical example HTML5 boilerplate .


You can call it a "snippet" or, more precisely, a "collection of snippets". The term was coined, in my opinion, from the printing and printing industry, where they actually used "plates" and then reused them as chunks. In the modern internet, he's part of an ongoing (annoying IMHO) trend of using fancy terms for simple things to look trendier and more sophisticated. see RESPONSIVE = adaptable / fluid.



A boilerplate is a writing unit that can be used over and over again without modification. In a broader sense, the idea is sometimes applied to reusable programming, as in the "boilerplate code"

We use cookies and other tracking technologies to improve your browsing experience on our website, to show you personalized content and targeted ads, to analyze our website traffic, and to understand where our visitors are coming from.

By continuing, you consent to our use of cookies and other tracking technologies and affirm you're at least 16 years old or have consent from a parent or guardian.

You can read details in our Cookie policy and Privacy policy.