Is defining get/set methods for every field overkill?

Siarhei Siamashka siarhei.siamashka at gmail.com
Sun Nov 20 23:04:18 UTC 2022


On Sunday, 20 November 2022 at 12:23:39 UTC, Ali Çehreli wrote:
> On 11/20/22 00:31, [] () {} () wrote:
> > If anyone wants to learn more about why encapsulated types
> > (classes) have shown to be so useful in my many years of
> programming,
>
> Hm. 'private' is about access control. Encapsulation is 
> something else.

BTW, many software developers and also wikipedia actually agree 
with [] () {} (): 
https://en.wikipedia.org/wiki/Encapsulation_(computer_programming)

And this all is getting really silly. The proof is in the 
pudding. I mean the existence of really large successful software 
is the best evidence of the programming language or coding 
technique superiority. C++ has plenty of large successful object 
oriented software written using it (Mozilla, Chromium, 
LibreOffice, Qt, LLVM, ...). People had a lot of time to try 
various C++ features and everyone has their own opinion. Multiple 
inheritance isn't very popular, but having private class members 
and the ability to easily hide class implementation details is 
generally seen as a good and useful feature.

D makes a rather arbitrary change to encapsulation and claims 
that this is an improvement. But you can't easily convince 
everyone by just making such claims. How it really works in 
practice is the only thing that matters.


More information about the Digitalmars-d-learn mailing list