Why less emphasis on private data?
Jorgen Grahn
grahn+nntp at snipabacken.dyndns.org
Sun Jan 7 09:39:50 EST 2007
On 06 Jan 2007 17:38:06 -0800, Paul Rubin <http> wrote:
> "BJörn Lindqvist" <bjourne at gmail.com> writes:
>> It is given that emphasizing private data (encapsulation) leads to
>> more internal complexity and more lines of code because you have to
>> write getters and setters and stuff.
>
> You can have public variables in Java if you choose to. Writing
> private variables with public setters and getters is just a style choice.
Privates with getters/setters are (as I think someone else hinted) pretty
pointless. The interesting stuff is the private data that *is* private, i.e.
not meant for users at all.
But yes, I don't mind not having 'private:' in Python. I don't have
compile-time type checking anyway. In fact, I don't always know what the
attributes of my objects /are/ until runtime.
And besides, this is pretty close to a compile-time check:
find -name \*.py | \
xargs egrep '\._[_a-z]' | \
fgrep -v self._
/Jorgen
--
// Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu
\X/ snipabacken.dyndns.org> R'lyeh wgah'nagl fhtagn!
More information about the Python-list
mailing list