[Exceptional C++ Style] Fw: const data - was Item 17

Jon Jagger jon at jaggersoft.com
Fri Dec 24 16:44:39 EST 2004


Kevlin Henney wrote:

>
> So, back to immutable data. Public immutable data is more encapsulated 
> than public mutable data because it eliminates a large class of 
> incorrect usages, ie it has few unintended and malign affordances. It 
> may or may not simplify usage, but that depends on the specific 
> situation. The one Jon has presented it seems not to cause any 
> problems. However, the degrees of freedom open to the implementor are 
> restricted, eg should Jon wish to switch to a handle-body 
> representation he cannot. 

This depends on the language. In C# (CLR) the proxying facilities allow 
interception. I could intercept field access if I wanted to. And yes I 
do mean fields and not properties (of course I could intercept 
properties too if I wanted). There would be no change required to the 
users code.

Cheers
Jon





More information about the Effective-cpp mailing list