In C++, when using the Resource Acquisition is Initialization (RAII) pattern, are there any common conventions for naming the classes?
In my case, I have classes which do the following kinds of things and I would like names which are likely to invoke a useful meaning to a first time reader when seeing one of these on the stack:
- A class to suppress logging (which can be nested).
- A class to put in place an observer.
- A class to record the current object being processed for the current thread.
- A derived class to process the object in addition to the base class behavior (in prior line).
As a first cut, I have used names like these (in corresponding order to above), but hope to improve upon them:
- class SuppressLogger
- class ScopedObserver
- class WithCurrentObject
- class WithObjectProcessed : public WithCurrentObject
Log
to the last two (e.g.LogWithCurrentObject
), but depending on the code, that might not be necessary. – Esch