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'.


              • ... unprotected-entity via Digitalmars-d-announce
              • ... unprotected-entity via Digitalmars-d-announce
              • ... Atila Neves via Digitalmars-d-announce
              • ... Walter Bright via Digitalmars-d-announce
              • ... 12345swordy via Digitalmars-d-announce
          • Re: Wed O... Adam D. Ruppe via Digitalmars-d-announce
            • Re: ... 12345swordy via Digitalmars-d-announce
              • ... Adam D. Ruppe via Digitalmars-d-announce
      • Re: Wed Oct 17 - ... Sebastien Alaiwan via Digitalmars-d-announce
        • Re: Wed Oct 1... Walter Bright via Digitalmars-d-announce
        • Re: Wed Oct 1... unprotected-entity via Digitalmars-d-announce
          • Re: Wed O... H. S. Teoh via Digitalmars-d-announce
          • Re: Wed O... ShadoLight via Digitalmars-d-announce
            • Re: ... H. S. Teoh via Digitalmars-d-announce
            • Re: ... Ali Çehreli via Digitalmars-d-announce
              • ... ShadoLight via Digitalmars-d-announce
            • Re: ... Atila Neves via Digitalmars-d-announce
  • Re: Wed Oct 7 - Avoiding C... Codifies via Digitalmars-d-announce

Reply via email to