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

Kevlin Henney kevlin at curbralan.com
Wed Dec 29 12:49:46 EST 2004


In message <41CC8DC7.4020409 at jaggersoft.com>, Jon Jagger 
<jon at jaggersoft.com> writes
>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.

True, but the representation of the field must still exist for it to be 
intercepted, and anything much beyond operationally as opposed to 
functionally related extension of semantics might be considered 
surprising unless that is an accepted part of the architecture.

Kevlin
-- 
____________________________________________________________

   Kevlin Henney                   phone:  +44 117 942 2990
   mailto:kevlin at curbralan.com     mobile: +44 7801 073 508
   http://www.curbralan.com        fax:    +44 870 052 2289
   Curbralan: Consultancy + Training + Development + Review
____________________________________________________________



More information about the Effective-cpp mailing list