`restricted` member variables
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Wed Jun 22 16:23:18 UTC 2022
On Wednesday, 22 June 2022 at 15:40:35 UTC, deadalnix wrote:
> But we aren't. We are just dumb monkeys. So we build
> abstractions under which we hide part of the complexity of the
> world we are dealing with and present it through a simplified
> API. This allow our monkey brain to do more because we can
> temporarily forget many aspect of the problem at hand.
You have have many reasons to do encapsulation. One is to
separate the specced interface from the implementation. Another
one is to reduce complexity in a project that is growing. Yet
another one is to document and enforce which parts are
subservient to other parts (also within a class). Yet another one
is to prevent mistakes when doing dangerous things… etc…
However, if you want to support going from an evolved prototype
to a solid model then it certainly is very useful to constrain
types maximally. In that setting it isn't only an
interface-issue, it is a tool for making sure that you tidy up
the code base in a gradual, orderly and timely manner.
Tighter encapsulation also allows more safe evolution, which is
closely related to going from prototype to final model.
There is a reason for why Smalltalk was favoured by some for
evolutionary development.
> But here, we see the whole bizarre of the current argument: if
> I want to isolate the user of my code from having to know of
> the implementation detail of my interface, then it logically
> follows that they don't belong in the same module, as the
> module is the unit of abstraction at which implementation
> happens.
I don't really think "module" is an abstraction, unless you use
it as a singleton. It is more like a namespace, for organizing.
Usually.
You can can use a module for organizing separating layers, in
which case it is an abstraction mechanism, but I wouldn't say it
generally is used for abstracting.
> The ask is fundamentally inconsistent in its motivations, and
> this is why the only argument we have for it so far all come in
> the form of "the holy scripture says so".
No… tigher encapsulation is a tool that gives me more control for
a wide variety of reasons.
More information about the Digitalmars-d
mailing list