|
|
|
I'm sorry but you didn't explain why not having private members is not a lack.
You only reference another language with the same lack to convince but it's not sufficient.
Private members protect classes for non controlled access to their data.
Only the contractual access are allowed.
Say for exemple, class A has 2 attributes a and b and by contract you havoe to modify these data together and not spearately. You provide a method to manage this, but you can't be certain that somebody will modify a without b by inadvertence
With C# it is possible but it is not a mistake. It's intentional
Anonymous |
08/12/08 - 3:27 pm | #
|
|

"3. Private makes less sense than it used to... Get used to living in a more public world."
Actually I live in a world where the public interface to classes is defined by convention and it works fine (with thousands of developers and millions of lines of code). I would say that the burden of proof is on those who say that this is not sufficient...
Michael Foord |
Homepage |
08/12/08 - 3:50 pm | #
|
|
Sorry i didn't see this sentence.
But how many time spent with correcting bugs of developpers who never read conventions and don't use unit testing.
The time saved, which is the main benefit of dynamic languages is partially lost .
Python's challengers like Ruby and Groovy support this concept of private members.
Anonymous |
08/12/08 - 4:12 pm | #
|
|
Ruby only has partial support - you can simply reopen the class to access private members.
And your question:
"But how many time spent with correcting bugs of developpers who never read conventions and don't use unit testing."
In my experience very little time at all, that is exactly the point. It has been *very* rare to have problems caused by developers mangling data that they shouldn't have accessed - and the cost of preventing them (making introspection difficult or impossible) is a high cost indeed to pay.
Michael Foord |
Homepage |
08/12/08 - 4:52 pm | #
|
|
It's a point of view.
Not very convincing for me.
The sooner you can prevent defects, the better it is.
Regards
Anonymous |
08/12/08 - 5:29 pm | #
|
|
Well, if you wanted to enforce that behaviour in Python you can configure PyLint to raise a warning about use of private members outside the class and have this check as a pre-commit hook in your version control.
You *certainly* haven't convinced me that enforcing private members at the language level brings any benefits worth the cost.
Michael Foord |
Homepage |
08/12/08 - 5:49 pm | #
|
|
|
Commenting by HaloScan
|