Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a common naming convention for RAII classes? [closed]

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
like image 397
WilliamKF Avatar asked Jul 02 '12 18:07

WilliamKF


1 Answers

RAII should be used all throughout the language. Since it should be the default, there's is no naming convention to follow.

like image 161
Paul Manta Avatar answered Sep 28 '22 01:09

Paul Manta