Wed Oct 17 - Avoiding Code Smells by Walter Bright

unprotected-entity unprotected-entity at gmail.com
Mon Nov 5 05:55:02 UTC 2018


On Saturday, 3 November 2018 at 21:28:22 UTC, Stanislav Blinov 
wrote:
>
> The only difference is that `func` became a member function. 
> And now what? You can just as easily "forget" what's in your 
> struct/class as in your whole module.

ok. Now, what are your options then (assuming you want an 
independent type)?

(option 1) define one encapsulated type, per module.
(option 2) have a means for type independence within a module - 
i.e. selective hiding.

D only gives you one choice here, not two.

I would say, that your response backs up my argument, that is, a 
second option might actually be worthwhile. perhaps, something 
like: __private

(now __private is everything private already is, but 
additionally, its private outside the scope of the type declaring 
it, and now, you'd get a compile time guarantee of correctness - 
e.g. if you accidently tried to ignore that types independence.

It's call 'type encapsulation' ;-)



More information about the Digitalmars-d-announce mailing list