private keyword dont appear to do anything

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Nov 3 21:52:22 UTC 2017


On Fri, Nov 03, 2017 at 05:43:55PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote:
> On 11/3/17 5:08 PM, Nathan S. wrote:
> > On Friday, 3 November 2017 at 20:01:27 UTC, Jonathan M Davis wrote:
> > > Most folks are surprised by this behavior
> > 
> > I found it surprising at first but now any other way seems absurd to
> > me.  None of the benefits of data encapsulation apply to code
> > written five lines away in the same file.
> 
> I also enjoy the mechanism, but I have to call this out as incorrect.
> Encapsulation is about being able to prove to yourself exactly how an
> object's private data can possibly be manipulated. It's not just 5
> lines away, it's the whole file you have to review.
> 
> If you have large flat files like Phobos, then encapsulation is
> essentially impossible to review.
[...]

Arguably, many of these large flat files ought to be split up into
smaller files.  For example, std.algorithm.* and std.range.* all tend to
be conglomerations of basically-independent groups of structs and
functions.  Iota and Cycle never interact with each other, and neither
of them interacts with Recurrence, yet these all sit in the same file.

Seems to me like a typical case of low cohesion, which, according to the
ideals of encapsulation, ought to be grounds for splitting up the file
into self-contained parts.

But of course, there are pragmatic reasons for the way things currently
are.


T

-- 
Государство делает вид, что платит нам зарплату, а мы делаем вид, что работаем.


More information about the Digitalmars-d-learn mailing list