Your name is one of the most important parts of your identity. It is the same with code. Each module, class, function, and variable has a unique identity and fulfills…
Category: C++
Class Definition Layout
When we begin reading a class definition, we read top-down. When we want to know how to use a class, we need to know how to construct it (via the…
Reducing Indentation and Returning Early
Consider the following function that calculates a price based on a provided price, tax, and coupon code: There are 3 nested if-statements, each with a corresponding else case. It’s fairly…
Const Correctness
Const correctness refers to the correct use of const to indicate whether a variable or parameter shall be modified or not. Other languages may inherently make variables immutable or const…
Software Readability
More time is spent reading software than writing it, so software (and most other forms of writing) need to be optimized for readability. Readability is subjective. There is a term…
Generating and Debugging Core Dumps
We’ve all been there: you build your application, run it, and see it crash: possibly with an error message like Segmentation fault (core dumped). The (core dumped) part is what…
Debugging Loading Issues
Sometimes an application works in your developer environment but breaks elsewhere, usually on startup. You may get an error message like: <app>: error while loading shared libraries: lib<libname>.so: cannot open…
Bit-fields
Bit-fields are a feature of the C and C++ languages to optimize the space taken by an integral member variable of a struct or class. It specifies the exact number…