`restricted` member variables

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Wed Jun 22 13:14:21 UTC 2022


On Wednesday, 22 June 2022 at 13:08:44 UTC, claptrap wrote:
> On Wednesday, 22 June 2022 at 11:23:47 UTC, Ola Fosheim Grøstad 
> wrote:
>> On Wednesday, 22 June 2022 at 11:01:27 UTC, claptrap wrote:
>>> On Wednesday, 22 June 2022 at 08:16:26 UTC, Ola Fosheim 
>>> Grøstad wrote:
>>>>
>>>> It is useful when building your model. That is too obvious a 
>>>> point to argue: Start out by making everything maximally 
>>>> constrained, then loosen up (reluctantly) when you have no 
>>>> other option.
>>>
>>> 1. Nobody does that.
>>
>> Wrong.
>
> What do you mean by "maximally constrained"?

It means that you make everything hidden outside the scope, it 
also means using const, don't apply shared etc etc.

Basically, it means you start out providing minimal access both 
within the module and externally.

Then, when you find that yo need to do something that requires 
direct access (e.g. compare and swap) you give just enough access 
to enable that.

Sometimes you might want to not provide direct access, but create 
a new accessor-class that is given privileges (e.g. a 
smart-pointer).




More information about the Digitalmars-d mailing list