[Development] RFC: RAII for property changes

Matthew Woehlke mw_triad at users.sourceforge.net
Wed Apr 15 20:23:12 CEST 2015


On 2015-04-15 13:55, Alan Alpert wrote:
> The common case is one property I think, so keep that case to one
> line. I'd envision using it in all my basic setters to save code at
> the start of a project, and then when the features start to creep in
> it's easier to add complexity into the setters.

If you use the helper class always, sure. I was thinking I probably
would not use it for the "easy" cases, i.e. where only one value
changes, and instead use it only where it becomes more important to have
the helper, in which case it's more likely you have two or more values.
Anyway...

> Still, you could always leave in a convenience constructor or just
> wrap it in a macro as before.

...there's always this :-). The case with one property (or, for that
matter, if you don't care about having multiple instances of the helper)
can still use a macro to collapse the two lines of code that either
version "needs".

For that matter, the addProperty flavor doesn't preclude having
convenience ctors that also call addProperty :-).

-- 
Matthew




More information about the Development mailing list