Boilerplate code

When using languages that are considered verbose, the programmer must write a lot of boilerplate code to accomplish only minor functionality.

As the stories that were distributed by boiler plates were usually "fillers" rather than "serious" news, the term became synonymous with unoriginal, repeated text.

One form of boilerplate consists of declarations which, while not part of the program logic or the language's essential syntax, are added to the start of a source file as a matter of custom.

Although the code will vary from one class to another, it is sufficiently stereotypical in structure that it would be better generated automatically than written by hand.

For example, the equivalent of the above Java code can be expressed in Scala using just one line of code: Or in C# using automatic properties with compiler generated backing fields: Starting with C# 9.0 there is an opportunity to use Records which generate classes with Properties automatically: In addition to declarations, methods in OOP languages also contribute to the amount of boilerplate.

A 2015 study on popular Java projects shows that 60% of methods can be uniquely identified by the occurrence of 4.6% of its tokens, making the remaining 95.4% boilerplate irrelevant to logic.