Wed Oct 17 - Avoiding Code Smells by Walter Bright
unprotected-entity
unprotected-entity at gmail.com
Fri Nov 2 00:25:21 UTC 2018
On Wednesday, 31 October 2018 at 10:48:24 UTC, Sebastien Alaiwan
wrote:
>
> "Encapsulation" is about implementation hiding and access
> control ("public/private"), and requires programming language
> support (e.g most dynamic languages don't have it).
"Encapsulation is sometimes referred to as the first pillar or
principle of object-oriented programming. According to the
principle of encapsulation, a class or struct can specify how
accessible each of its members is to code outside of the class or
struct. Methods and variables that are not intended to be used
from outside of the class .. can be hidden to limit the potential
for coding errors or malicious exploits."
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/
D simply has *zero* support for encapsulation of classes or
structs, within the module (only encapsulation from code that is
outside the module).
Any programmers interested in enforcing encapsulation in D (the
first pillar of OOP), are *forced* (because the language doesn't
provide the tool to do anything else) to use the one class, one
struct, per file solution. Which seems really silly to me. D
forces you into Java like programming - just to encapsulate a
little class or struct.
Speaking of 'structs', I don't see anyone in the D community,
telling others to use 'one struct per module'.
More information about the Digitalmars-d-announce
mailing list