Articles & Books

The Strategy Pattern -- Rainer Grimm

A canonical example:

 

The Strategy Pattern

by Rainer Grimm

From the article:

Purpose: Defines a family of algorithms and encapsulates them in objects

Also known as: Policy

Use case:

  • Different variations of an algorithm are needed
  • The client does not need to know the algorithm
  • The algorithm should be exchangeable at the run time of a program...

The Template Method -- Rainer Grimm

With or without actual templates:

The Template Method

by Rainer Grimm

From the article:

The key idea of the Template Method is easy to get. You define the skeleton of an algorithm that consists of a few typical steps. Implementation classes can only override the steps but cannot change the skeleton. The steps are often called hook methods...

C and C++ Profiling Tools -- David Faure

When profiling is a good thing:

C/C++ Profiling Tools

by David Faure

From the article:

This blog will give you a brief overview of profiling C and C++ applications. Additionally, it will lay before you all of the tools available, with the purpose of aiding you in choosing the right tools at the right times...

The Proxy Pattern -- Rainer Grimm

Untitled.pngPlaying the classics, at arm's length...

The Proxy Pattern

by Rainer Grimm

From the article:

A proxy controls access to another object, allowing you to perform additional operations before or after you access the original object. Sound familiar?

Which idiom is characteristic of C++? Right: RAII (Resource Acquisition Is Initialization). RAII is the C++ way to implement the Proxy Pattern. Here are the facts about the Proxy Pattern. ...

Using final in C++ to improve performance -- Niall Cooling

Screenshot_2022-11-16_163427.pngWhen having the "last word" makes stuff go faster...

Using final in C++ to improve performance

by Niall Cooling

From the article:

The final specifier was introduced in C++11 to ensure that either a class or a virtual function cannot be further overridden. However, as we shall investigate, this also allows them to perform an optimization known as devirtualization, improving runtime performance.

 

For Software Performance, the Way Data is Accessed Matters! -- Ivica Bogosavljević

Screenshot_2022-11-12_150618.pngAs Crocodile Dundee famously said, "That's not a loop, that's a loop." Just programmers having fun:

For Software Performance, the Way Data is Accessed Matters!

by Ivica Bogosavljević

From the article:

In our experiments with the memory access pattern, we have seen that good data locality is a key to good software performance. Accessing memory sequentially and splitting the data set into small-sized pieces which are processed individually improves data locality and software speed.

In this post, we will present a few techniques to improve the memory access pattern and increase data locality. The advantage of this approach is that the changes are localized in the algorithm itself, i.e. there is no need to change the data layout or the memory layout. The disadvantage is that the algorithms often become more difficult to understand and modify. ...

[... and deep inside the article ...]

Notice that, because the whole cache line is brought from the memory to the data cache, after accessing a[j][i] we can access a[j][i + 1]cheaply, since these two pieces of data belong to the same cache line. The problem in our case is that if n is large, access to a[j][i + 1] will come much after a[j][i] and by that time a[j][i + 1] will be evicted from the data cache. ...

The Facade Pattern -- Rainer Grimm

Untitled.pngPlaying the classics...

The Facade Pattern

by Rainer Grimm

From the article:

The key idea of the Facade Pattern is to provide a simplified interface to a complex system... 

The Facade Pattern is an ideal starting point for decoupling complex systems by introducing layers. Additionally, it can be used as a starting point for deprecating the old interface.

Here are the facts. ...