@property get/set or public varaible?
vladdeSV via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Dec 4 07:30:22 PST 2016
Hello!
I have a question not directly related to D as it is with coding
standards.
My issue at hand is if I have one variable for a class, which I
want to be directly accessible for anything else, should it be
1. public, or
2. private, with @property get/setters?
From what I have been told is that variables should be private.
But if I do not want to make any checks whatsoever when setting a
variable, I see no benefit to the private approach.
Are there any other reasons to use get/setters?
More information about the Digitalmars-d-learn
mailing list