Author pje
Recipients daniel.urban, lukasz.langa, ncoghlan, pitrou, pje, python-dev
Date 2013-05-25.19:02:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CALeMXf53qhohJJX3kSagXwBoab30Aji5gef6aZ1VWQHd_Ea6Lw@mail.gmail.com>
In-reply-to <1369502009.2.0.156769822517.issue16832@psf.upfronthosting.co.za>
Content
Antoine Pitrou added the comment:
> -1. Exposing a function allows to modify the underlying implementation
> without breaking any API.

This doesn't make any sense.  Once you've exposed an API that gives
out a value for this, you can't change the implementation in a way
that doesn't involve handing out a value... in which case you can just
as easily set it as an attribute.

So there is actually zero improvement in encapsulation: it's purely a
ritualistic wrapping, like Java programmers insisting on having
getFoo() methods in Python when an attribute would suffice.  If there
must be a way to change it later to be dynamic, it can always be
exposed as an attribute of an object that could grow a property later,
e.g.

    from abc import object_graph

    if object_graph.version != old_version:
        ...

Nick Coghlan added the comment:
> Trading correctness for speed is almost never a good idea.

How is "correctness" relevant to the question of whether a readable
value is exposed as an attribute or a method?
History
Date User Action Args
2013-05-25 19:02:55pjesetrecipients: + pje, ncoghlan, pitrou, daniel.urban, lukasz.langa, python-dev
2013-05-25 19:02:55pjelinkissue16832 messages
2013-05-25 19:02:54pjecreate