In general, a lawyer or real estate agent may give you a five-page contract to sign, but most of the contract is boilerplate — meaning it’s the same for everyone who gets that contract, with only a few changes.
In computer programming, boilerplate code or just boilerplate refers to sections of code that have to be included in many places with little or no alteration. It is often used when referring to languages that are considered verbose, i.e. the programmer must write a lot of code to do minimal jobs.
If you look around Github boilerplates, you will find plenty of boilerplate repositories for different programming languages or different common use cases(like a hackathon, game development, framework).
The concept of boilerplate was originated in the newspaper industry during the late 18th century.
In the software industry, most professional developers/teams created a collection of code snippets and assets that they reuse to boost development. In the case of web development, there are some basic global requirements needed for each website/application. Rather than every time rebuilding these, most developers start keeping a copy of base features & reusing it for each time.
These days, boilerplate is not limited for web development only but we can see much of boilerplate code for ML/AI as there are more growing frameworks & libraries in this area.
Why use the boilerplate code?
- Boost Early Development: The main advantage of using boilerplate code is to reduce your initial software development time by reusing core things.
- Less Complexity: It also takes care of complexity from your code & gives you possibly cleaner code.
- Short Learning Curve: If your software uses the standard boilerplate code as a base then there will be no learning curve for new developers who have worked on the same boilerplate.
When to use the boilerplate code?
- Your requirements are clear: In my opinion, if your software requirements are clear & those are matching with the specific boilerplate code features then you are good to go with it.
- Your requirements are not clear: For instance, the complete scope of the software is not much clear in the beginning then I would prefer to choose a specific framework or start with core development over using boilerplate. The reason not to choose boilerplate is, there might be some cases/requirements in the future which may not support this boilerplate or it restricts with specific approach or UI.
Things to check while using boilerplate code:
- Follows proper coding standard from specific language
- Proper documentation
- Easy & Standard testing tool
- Scalable in terms of performance & development
- Support for customising core things
- Community support
- License & ownership
- Coding standards followed
- Has CLI tool
Some useful boilerplates:
Neither I'm promoting nor recommending any of these boilerplates for your requirements. You should do your research in case you wants to use one. I'm just trying to give my bit to open-source community.
- React Boilerplate
- Electron & Vue
- jQuery Plugin
- Django & Angular
- Django & React
- WordPress Plugin
- Nginx Server Config
- Hackathon & quick prototyping - Node JS, express application with a bunch of basic features
The wisest thing is to get a deeper understanding of your software requirements & then look around for matching framework/boilerplate/core.