C++ Object Programming Terminology

This blog post explains object programming terminology used in C++.

Data Hiding
Is when we hide the implementation details of a class behind the private access control modifier. This way the code that uses our class (client code) can not access these private implementation details. This makes the class easier to modify and maintain as the the client code has no knowledge of or dependencies on the implementation details. As a result of keeping the aspects of the class private that are most likely to change, we are left with a public interface for the class that can be more stable and less likely to change, thus potentially breaking client code.

DRY (Don't Repeat Yourself)
A programming principle that discourages the use of duplicative or repetitive code, typically code copied from one place and pasted into another. Such duplicated code can be huge maintenance problem as problems with the code will have to be fixed every place it is duplicated. As formulated by Andy Hunt and Dave Thomas in their book The Pragmatic Programmer, "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system".

Encapsulation
In his book on object-oriented designGrady Booch defined encapsulation as "the process of compartmentalizing the elements of an abstraction that constitute its structure and behavior; encapsulation serves to separate the contractual interface of an abstraction and its implementation." Basically this mean that in C++ we define the structure of a class, i.e. is data members, and the operations on that structure, i.e. the member functions, in the same place, i.e. the class definition.

Exceptions

Metaprogramming
A programming technique by which computer programs have the ability to treat other programs as their data. In C++ metaprogramming is accomplished using the template mechanism.

NTTP (Non-Type Template Parameter)
Template parameter that is a literal instead of a type name. Typically an integral literal, but other effectively literal types can be used since C++20.

POD (Plain Old Data)
C++ allows us to define data types using the class keyword and the older C keyword struct. A POD type is one that doesn't have all the trappings associated with class and is typically declared using struct even though both are mostly equivalent in C++. In C++ struct data types have public members by default. A POD is a struct or class that has only other POD data members (this includes intrinsic types), no user-provided constructors, no brace-or-equal-initializers for non-static data members), no private or protected non-static data members, no base classes, and no virtual functions. Basically a POD type in C++ supports static initialization and has the same memory layout as the same struct in C.

RAII (Resource Acquisition is Initialization)
A programming idiom used to eliminate resource leaks by tying the resource acquisition and release to an object lifetime. The resource allocation (or acquisition) is done during object creation (specifically initialization), by the constructor while resource deallocation (release) is done during object destruction (specifically finalization), by the destructor.

SFINAE (Substitution Failure Is Not An Error)
SFINAE refers to a situation in C++ where an invalid substitution of template parameters is not in itself an error. David Vandevoorde first introduced the acronym. Basically it means that if there are multiple templates that can be used in an overload situation, templates that fail to be instantiated do not cause an error, they just become unavailable for overload resolution.

Template
Template metaprogramming (TMP) is a technique in which code patterns are used by the compiler to generate temporary source code. This template expanded code is merged with the rest of the source code and then compiled. Templates can be used to create compile-time constants, data structures (class or struct) and functions. The use of templates can be thought of as compile-time polymorphism.