Articles & Books

Design Patterns VS Design Principles: Observer, State and Strategy

Do you know about them?

Design Patterns VS Design Principles: Observer, State and Strategy

by Jonathan Boccara

From the article:

In this series of articles on design patterns and design principles, we analyse how the 23 GoF design patterns relate to the 9 GRASP design principles.

In a previous article, we classified the GRASP patterns like this (excluding “Managing complexity”).

The study we perform in this series is helpful to understand better both the GoF and the GRASP, with the goal of taking better decisions when it comes to organizing our code.

The GoF design patterns come from the seminal Design Patterns book. The GRASP design principles are explained in Craig Larman’s Applying UML and Patterns.

In this episode of the series, we examine the Observer, State and Strategy design patterns...

6 Ways to Refactor new/delete into unique ptr--Bartlomiej Filipek

Do you have that problem?

6 Ways to Refactor new/delete into unique ptr

by Bartlomiej Filipek

From the article:

In legacy code, you can often spot explicit new and delete lurking in various places and waiting to produce pointer-related issues. This blog post shows six patterns to improve that erroneous style and rely on modern techniques, especially unique_ptr and other helper standard types...

Automatic Return Type (C++98)--Rainer Grimm

The series continue.

Automatic Return Type (C++98)

by Rainer Grimm

From the article:

Depending on the used C++ standard, there are different ways to return the right return type of a function template. In this post, I start with traits (C++98), continue in my next post with C++11/14, and end with concepts (C++20)...

Chinese translation: "Thriving in a crowded and changing world: C++ 2006-2020" -- Bjarne Stroustrup

Thanks to the Chinese C++ experts who did this translation of Bjarne Stroustrup's latest History of Programming Languages paper! That's a massive job, and translations of technical papers are very rare in our field.

Bjarne Stroustrup: Thriving in a crowded and changing world: C++ 2006-2020

English (Jun 2020)

Chinese (Oct 2021)

See also: Pre-recording and Q&A

ACM/SIGPLAN History of Programming Languages conference, HOPL-IV. London. June 2020.

All the HOPL-4 papers are posted as Proceedings of the ACM on Programming Languages Vol. 4.

Dependent Names--Rainer Grimm

The series continue.

Dependent Names

by Rainer Grimm

From the articles:

A dependent name is essentially a name that depends on a template parameter. A dependent name can be a type, a non-type, or a template parameter. To express that a dependent name stands for a type or a template, you have to use the keywords typename or template...

Compiler Explorer with Cmake--Gajendra Gulgulia

New capabilities.

Compiler Explorer with Cmake

by Gajendra Gulgulia

From the article:

Compiler explorer has been one of the most widely used online tool for compiling C++ code, doing experiment with C++ features, sharing code snippets with friends and colleagues and also (my favorite feature) to compare and prove with the help of assembly code why a certain way of coding might be good or bad compared to another way.
Recently compiler explorer added support for compiling multiple files with CMakeLists.txt [1] . This opens up a new possibilities for developers around the world from testing complex pieces of code to testing the compilation behavior of the same.
In this issue, I would like to give a walk through on how to set up a simple layout of three files compiled with CMakelists.txt. Note that the focus is on setting up compiler explorer for multiple files and not on code efficiency. Also the article might at first glance look lengthy, but it may only be due to 19 images in the tutorial. So don’t get weighed down by the size of the article and lets start!

A Recap on User Defined Literals--Jonathan Boccara

Are you using them?

A Recap on User Defined Literals

by Jonathan Boccara

From the article:

User defined literals were introduced in C++11, evolved in C++14 and C++17, and are a nice way to write more expressive code.

The general idea behind user defined literals is that they allow to write a value and tack on a term describing what this value represents. For example:

auto const quantity = 42_bottles_of_water;

In this expression, 42 is the value and _bottles_of_water is the user defined suffix. The expression as a whole is a user defined literal.

A common usage of user defined literals is to represent units, but they can also be used to add meaning to values in more general contexts.

Here is how to write user defined literals in C++11, C++14 and C++17...