q2K BHP
Black History Portal
THE BHP WIRE —
HIDDEN TRUTHS
What's New!
THE JOURNEY THROUGH TIME

Explore Black History

Explore the people, places, events, achievements, struggles and stories that shaped our journey.

✊🏾

Civil Rights

Movements, leaders, victories and the continuing fight for equality.

⚙️

Black Inventors

Innovation, patents, science, technology and world-changing contributions.

🏆

Sports

Pioneers, champions, Negro Leagues, records, activism and excellence.

♟️

People

Meet the people whose lives, choices and achievements shaped the journey.

📍

Places

Black towns, communities, institutions and places where history happened.

📜

Events

Moments that changed communities, movements, institutions and the nation.

Enter a person, place, event, or topic.
MY'STORY

The MOVE Fire

This is a personal recollection on the Move fire on May 13, 1985 Philadelphia police fired thousands of rounds at the MOVE house, city officials approved dropping an explosive device on the roof, the resulting fire was allowed to burn, 11 people—including five children—died, and 61 homes were destroyed. Philadelphia City Council later called it a “brutal attack carried out by the City of Philadelphia on its own citizens” and acknowledged that no individual faced criminal consequences for the bombing. One timeline correction worth preserving for the BHP record: the major previous MOVE-police confrontation was August 8, 1978, about seven years before the bombing, not a year or two earlier. Officer James Ramp was killed, other police and firefighters were wounded, nine MOVE members were later convicted, and television cameras recorded police beating Delbert Africa during his arrest. The 1985 MOVE Commission later specifically criticized city planners for failing to adequately use lessons from that 1978 confrontation. And that actually strengthens the point you’re making: 1985 did not happen without precedent or institutional memory. There had already been a deadly confrontation with MOVE, years of conflict, negotiations and police involvement before Osage Avenue.

MORE →
BLACK FACTS
The Truths They Never Taught You...

Ruler of the Mali Empire in the 14th century

Mansa Musa was the ruler of the Mali Empire in West Africa. Details recorded here should be sourced; unknown information is left blank.

MORE →
BHP gathered finds from its connected research sources. Showing the 4 strongest Black History matches.
← BACK TO RESULTS
Wikipedia

Boilerplate code

In computer programming, boilerplate code, or simply boilerplate, are sections of code that are repeated in multiple places with little to no variation. When using languages that are considered verbose, the programmer must write a lot of boilerplate code to accomplish only minor functionality.[1]

The need for boilerplate can be reduced through high-level mechanisms such as metaprogramming (which has the computer automatically write the needed boilerplate code or insert it at compile time), convention over configuration (which provides good default values, reducing the need to specify program details in every project) and model-driven engineering (which uses models and model-to-code generators, eliminating the need for manual boilerplate code).

It is also possible to move boilerplate code to an abstract class so that it can be inherited by any number of concrete classes. Another option would be to move it into a subroutine so that it can be called instead of being duplicated.

Origin

[edit]

The term arose from the newspaper business. Columns and other pieces that were distributed by print syndicates were sent to subscribing newspapers in the form of prepared printing plates. Because of their resemblance to the metal plates used in the making of boilers, they became known as "boiler plates", and their resulting text—"boilerplate text". As the stories that were distributed by boiler plates were usually "fillers" rather than "serious" news, the term became synonymous with unoriginal, repeated text.[2][3]

A related term is bookkeeping code, referring to code that is not part of the business logic but is interleaved with it in order to keep data structures updated or handle secondary aspects of the program.

Preamble

[edit]

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. The following Perl example demonstrates boilerplate:

#!/usr/bin/env perl
use warnings;
use strict;

The first line is a shebang, which identifies the file as a Perl script that can be executed directly on the command line on Unix/Linux systems. The other two are pragmas turning on warnings and strict mode, which are mandated by fashionable Perl programming style.

This next example is a C/C++ programming language boilerplate, #include guard.

#ifndef MYINTERFACE_H
#define MYINTERFACE_H

...

#endif

This checks, and sets up, a global flag to tell the compiler whether the file myinterface.h has already been included. As many interdepending files may be involved in the compilation of a module, this avoids processing the same header multiple times, (which would lead to errors due to multiple definitions with the same name).

In Java and similar platforms

[edit]

In Java programs, DTO classes are often provided with methods for getting and setting instance variables. The definitions of these methods can frequently be regarded as boilerplate. 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, in the following Java class representing a pet, almost all the code is boilerplate except for the declarations of Pet, name, and owner:

Java

[edit]
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;
    }
}

Most of the boilerplate in this example exists to fulfill requirements of JavaBeans. If the variables name and owner were declared as public, the accessor and mutator methods would not be needed.

In Java 14, record classes were added to fight with this issue.[4][5][6]

To reduce the amount of boilerplate, many frameworks have been developed, e.g. Lombok for Java.[7] The same code as above is auto-generated by Lombok using Java annotations, which is a form of metaprogramming:

@AllArgsConstructor
@Getter
@Setter
public class Pet {
    private String name;
    private Person owner;
}

Scala

[edit]

In some other programming languages it may be possible to achieve the same thing with less boilerplate, when the language has built-in support for such common constructs. For example, the equivalent of the above Java code can be expressed in Scala using just one line of code:

case class Pet(var name: String, var owner: Person)

C / C++

[edit]

An include guard:

#ifndef MYINTERFACE_H
#define MYINTERFACE_H

...

#endif

C#

[edit]

Or in C# using automatic properties with compiler generated backing fields:

public class Pet
{
    public string Name { get; set; }
    public Person Owner { get; set; }
}

Starting with C# 9.0 there is an opportunity to use Records which generate classes with Properties automatically:

public record Pet(string Name, Person Owner);

HTML

[edit]

In HTML, the following boilerplate is used as a basic empty template and is present in most web pages:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8"/>
  <title>Test</title>
</head>
<body>

</body>
</html>

The WHATWG HTML Living Standard defines that the <html>, <head> and <body> tags may be safely omitted under most circumstances.[8] The <meta charset="UTF-8"> tag is technically redundant when coming directly from a web server configured to send the character encoding in an HTTP header, though it becomes useful when the HTML response is saved in an .html file, cache, or web archive.[9] Google's HTML/CSS style guide recommends that all optional tags be omitted,[10] resulting in much less boilerplate. The World Wide Web Consortium states that the element <title> must not be empty:[11]

<!DOCTYPE html>
<title>Test</title>

See also

[edit]

References

[edit]
  1. ^ Lämmel, Ralf; Jones, Simon Peyton (2003). "Scrap your boilerplate: a practical design pattern for generic programming". Proceedings of the 2003 ACM SIGPLAN International Workshop on Types in Languages Design and Implementation. TLDI '03. New York: ACM. pp. 26–37. doi:10.1145/604174.604179. ISBN 9781581136494. S2CID 9472305.
  2. ^ "Boilerplate". Dictionary.com. Retrieved 2018-01-27.
  3. ^ "Boilerplate". Merriam-Webster. Retrieved 2018-01-27.
  4. ^ "Record Classes". docs.oracle.com.
  5. ^ "JEP 395: Record". openjdk.org.
  6. ^ Evans, Ben (2020-11-01). "Records Come to Java". blogs.oracle.com.
  7. ^ Frankel, Nicolas (2009-12-07). "Lombok reduces your boilerplate code". DZone.com. Retrieved 2017-08-02.
  8. ^ "HTML Standard - The HTML syntax - Optional tags". WHATWG. 2017-05-05. Retrieved 2017-05-05.
  9. ^ "Is the charset meta tag required with HTML5?". stackoverflow.com. Retrieved 2017-05-05.
  10. ^ "Google HTML/CSS Style Guide". google.github.io. Retrieved 2017-05-05.
  11. ^ "HTML page has non-empty title". www.w3.org. Retrieved 22 July 2021.

Source: Wikipedia. Article content is retrieved live through the MediaWiki API.

No preview image
Wikipedia

Boilerplate code

In computer programming, boilerplate code, or simply boilerplate, are sections of code that are repeated in multiple places with little to no variation. When using languages that are considered verbose, the programmer must write a lot of boilerplate code to accomplish only minor functionality. The need for boilerplate can be reduced through high-level mechanisms such as metaprogramming (which has the computer automatically write the needed boilerplate code or insert it at compile time), convention over configuration (which provides good default values, reducing the need to specify program details in every project) and model-driven engineering (which uses models and model-to-code generators, eliminating the need for manual boilerplate code). It is also possible to move boilerplate code to an abstract class so that it can be inherited by any number of concrete classes. Another option would be to move it into a subroutine so that it can be called instead of being duplicated.

MORE →
No preview image
Wikipedia

Boilerplate

Boilerplate may refer to: Boilerplate text, any text that is or can be reused in new contexts or applications without being changed much from the original Boilerplate code, code that appears in different programs mostly unaltered due to conventions or syntactical requirements to form a minimal program Boilerplate contract, standard form contract between two parties that does not allow for negotiation Boilerplate clause, standard clauses of contractual terms which are included in many contracts Boilerplate (robot), fictional combat robot of the Victorian era and early 20th century, created in 2000 by artist Paul Guinan Boilerplate (spaceflight), non-functional craft, system, or payload which is used to test various configurations and basic size, load, and handling characteristics

MORE →
No preview image
Wikipedia

Signals and slots

Signals and slots is a language construct introduced in Qt for communication between objects which makes it easy to implement the observer pattern while avoiding boilerplate code. The concept is that GUI widgets, and other objects, can send signals containing event information which can be received by other objects using special member functions known as slots. This is similar to C/C++ function pointers, but the signal/slot system ensures the type-correctness of callback arguments. The signal/slot system fits well with the way graphical user interfaces are designed. Similarly, the signal/slot system can be used for other non-GUI usages, for example asynchronous I/O (including sockets, pipes, serial devices, etc.) event notification or to associate timeout events with appropriate object instances and methods or functions. It is easy to use and no registration/deregistration/invocation code need to be written, because Qt's metaobject compiler (MOC) automatically generates the needed infrastructure. A spreadsheet programs update system could be implemented using signals and slots such that when a cell is changed, its dependent cells are notified/updated.

MORE →
No preview image
Wikipedia

AWS Cloud Development Kit

The AWS Cloud Development Kit (AWS CDK) is an open-source software development framework developed by Amazon Web Services (AWS) for defining and provisioning cloud infrastructure resources using familiar programming languages. The AWS CDK aims to improve the experience of working with Infrastructure as Code by providing higher-level, reusable constructs that enable developers to create and manage AWS resources more efficiently and with less boilerplate code compared to traditional configuration files like AWS CloudFormation templates.

MORE →
TOPIC OF THE DAY

Greenwood / Black Wall Street

Before the 1921 destruction of Tulsa’s Greenwood District, Black residents had created a remarkable center of business and community life. The district included stores, professional offices, entertainment venues and homes owned by Black citizens. Understanding Greenwood means learning what was built—not only what was burned.

MORE →
TRIVIA QUESTION OF THE DAY

Which Black woman became the first elected to the United States Congress?

Shirley Chisholm, elected in 1968.