Reading various articles I sometimes come across such an expression:
Boilerplate code
In my team, clearly no one could explain this concept. What is it?
Reading various articles I sometimes come across such an expression:
Boilerplate code
In my team, clearly no one could explain this concept. What is it?
In Wikipedia, everything is written
The concept boilerplate code or boilerplate refers to sections of code that should be written in many places with minimal changes. It is often used in relation to languages in which a programmer must write a lot of code in order to perform a minimal task.
Many modern IDEs automatically generate a boilerplate code. There is also such a thing as a scaffold that allows you to generate a boilerplate (for example, in Ruby on Rails you can generate basic CRUD methods in controllers).
Examples:
html
<!DOCTYPE html> <title>Что такое Boilerplate code?</title> Boilerplate code, which we need to repeat in each pattern. ( Proof )
Java
public class Pet { private String name; private Person owner; public Pet(String name, Person owner) { this.name = name; this.owner = owner; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Person getOwner() { return owner; } public void setOwner(Person owner) { this.owner = owner; } } PS: this is the main reason why I once abandoned programming in Java.
<!doctype html><title>0</title> - title should not be empty. validator.w3.org/nu/#textarea - Qwertiy ♦Template code that should be written in many places with little or no changes. The programmer has to write this code every time, as a rule, taking up unnecessary space, cluttering up the program and diverting attention from business logic. This makes the program more complex, without any benefit.
Often there are projects on hitkhab in which a lot of things are done from what is often found in the average project, these projects were made to be copied and based on them to do their projects, not to bother with the same things when you start to make a project. This project is also called starter.
Here are examples: html5-boilerplate , react-boilerplate , electron-react-boilerplate , laravel-5-boilerplate , hackathon-starter .
Pros:
Minuses:
Source: https://ru.stackoverflow.com/questions/583342/
All Articles