Boost logo

Boost Users :

Subject: Re: [Boost-users] What does "RALL-style" means ?
From: Peter (peter_foelsche_at_[hidden])
Date: 2009-05-05 16:29:49

A lot of things can be partitioned into do-actions and undo-actions.
E.g. resource allocation and deallocation.

According to this philosophy you should perform do-actions in a constructor and the matching un-do action in a destructor.
Throw an object containing rich error information in case of the do-action fails.

The win32 library can be nicely wrapped into such classes.

When you're going this way you can chain such objects into base class and member class relationships.
You only have to write code for the successful case.
The compiler will generate code, to deal with the case any of the base or member object fails to initialize.
Try to allocate only a single resource in a single constructor.
Otherwise you will have to deal with failure by yourself instead of leaving this up to the compiler.

Another good philosophy (which may be derived from RAII) is to design classes in such a way,
that all public methods are always callable as soon as such an object exists.
Or in other words: It is bad philosophy to design classes in such a way, that certain methods must be called in a particular order.
Following this philosophy leads to code which avoids null-pointer access.
  "ZouLei" <zoulei.vresearch.org_at_[hidden]> wrote in message
  Hi, everyone.

  When I refer the document of thread library, a word "RALL-style" appear in the introduction of the class lock_guard: This provides simple RAII-style locking of a Lockable object, to facilitate exception-safe locking and unlocking.

  I didn't got the main point of this word "RALL-style", could anyone tell me the meaning ? Thanks.

  Best wishes.


  Boost-users mailing list

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at