Questions tagged [boilerplate]

In computer programming, boilerplate is the term used to describe sections of code that have to be included in many places with little or no alteration. It is more often used when referring to languages which are considered verbose, i.e. the programmer must write a lot of code to do minimal jobs.

489 questions
416
votes
14 answers

What is boilerplate code?

A coworker had never heard of this, and I couldn't provide a real definition. For me, it's always been an instance of 'I-know-it-when-I-see-it'. Bonus question, who originated the term?
Nate Parsons
  • 12,853
  • 12
  • 48
  • 66
91
votes
12 answers

Java error: Implicit super constructor is undefined for default constructor

I have a some simple Java code that looks similar to this in its structure: abstract public class BaseClass { String someString; public BaseClass(String someString) { this.someString = someString; } abstract public String…
Joel
  • 10,593
  • 17
  • 58
  • 72
54
votes
4 answers

HTML5 Boilerplate vs. HTML5 Reset

Hey everyone — HTML5 Boilerplate and HTML5 Reset are two HTML, CSS, and JavaScript templates with a lot of modern best practices built-in. Their goals are largely the same: Fast, robust, modern Web development HTML5 (duh!) Cross-browser…
Rudiger
  • 5,986
  • 9
  • 37
  • 57
44
votes
6 answers

A good HTML skeleton

I want to start creating websites again, but I've been out of the HTML scene for a while now. I was just wondering if this is a good skeleton for a website. And if not, what should I change, add and/or remove?
Nick
  • 1,072
  • 1
  • 14
  • 27
43
votes
7 answers

What are the risks with Project Lombok?

I'm coming up with performance goals for the new year, and I thought I'd be fun to put a goal to reduce the size of the code base, especially boilerplate. One action I've come up with to address this is to use Project Lombok to make beans as short…
jldugger
  • 2,041
  • 6
  • 21
  • 24
35
votes
7 answers

"Boilerplate" code in Python?

Google has a Python tutorial, and they describe boilerplate code as "unfortunate" and provide this example: #!/usr/bin/python # import modules used here -- sys is a very standard one import sys # Gather our code in a main() function def main(): …
Bhaxy
  • 4,866
  • 10
  • 34
  • 40
29
votes
2 answers

Constructing simple Scala case classes from Strings, strictly without boiler-plate

I seek succinct code to initialize simple Scala case classes from Strings (e.g. a csv line): case class Person(name: String, age: Double) case class Book(title: String, author: String, year: Int) case class Country(name: String, population: Int,…
Perfect Tiling
  • 643
  • 4
  • 11
28
votes
5 answers

How to reduce boilerplate currently necessary for serialization

Our software is abstracting away hardware, and we have classes that represent this hardware's state and have lots of data members for all properties of that external hardware. We need to regularly update other components about that state, and for…
sbi
  • 204,536
  • 44
  • 236
  • 426
28
votes
4 answers

How do I avoid writing this type of Haskell boilerplate code

I run into this situation often enough for it to be annoying. Let's say I have a sum type which can hold an instance of x or a bunch of other things unrelated to x - data Foo x = X x | Y Int | Z String | ...(other constructors not involving x) To…
Anupam Jain
  • 7,323
  • 2
  • 34
  • 71
27
votes
1 answer

What is the main use of the site.webmanifest file?

I am using a HTML Boilerplate and I see a file called site.webmanifest. I have searched information on the Internet and I don't understand the use of it. Is it a mandatory file in the development of web pages? When and why it is used? How do I know…
JusitoFelix
  • 380
  • 1
  • 3
  • 6
27
votes
2 answers

Is there a way to auto generate a __str__() implementation in python?

Being tired manually implementing a string representation for my classes, I was wondering if there is a pythonic way to do that automatically. I would like to have an output that covers all the attributes of the class and the class name. Here is an…
Marco Ferrari
  • 4,086
  • 4
  • 30
  • 48
26
votes
10 answers

Assign function arguments to `self`

I've noticed that a common pattern I use is to assign SomeClass.__init__() arguments to self attributes of the same name. Example: class SomeClass(): def __init__(self, a, b, c): self.a = a self.b = b self.c = c In fact…
Jonathan
  • 84,911
  • 94
  • 244
  • 345
25
votes
4 answers

Using 'window', 'document' and 'undefined' as arguments in anonymous function that wraps a jQuery plugin

Honestly, I didn't know how to make the title shorter. I learnt how to write a jQuery plugin by studying the source of SlidesJS plugin. When I encountered something new, I just asked my good friend Google and most of the times, got a satisfactory…
Zia Ur Rehman
  • 1,091
  • 2
  • 11
  • 20
21
votes
2 answers

Is Project Lombok suitable for large java projects?

Is anybody out there using Project Lombok for a large scale production system? How does it influence your compile process (i.e. does it do two-pass compilation, slow it down, make it more fragile)?
Jacob
  • 21,087
  • 7
  • 37
  • 55
18
votes
7 answers

Java: Is there support for macros?

I am just curious on how people solve this. I often write the same type of code all the time. For instance: new Thread() { //... //... //... //Change this line //... //... }.start(); I keep changing the line where it says "Change…
Legend
  • 104,480
  • 109
  • 255
  • 385
1
2 3
32 33