pyfoo / python-twitter

Automatically exported from code.google.com/p/python-twitter
Apache License 2.0
0 stars 0 forks source link

get rid of all those java-ish getters and setters #43

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

Are there any plans to get rid of all the java-style getters and setters?

Code like the stuff below can be cut down to 1 line by replacing these
accessors by a normal variable, and does not reduce any of the
functionality, but does increase the legibility of the code.
Note that if a checking setter or special getter is needed, one can always
put that in later.

I'm offering to assist on resolving this issue if needed.

quoting twitter.py lines 107..124:
  def GetCreatedAt(self):
    '''Get the time this status message was posted.

    Returns:
      The time this status message was posted
    '''
    return self._created_at

  def SetCreatedAt(self, created_at):
    '''Set the time this status message was posted.

    Args:
      created_at: The time this status message was created
    '''
    self._created_at = created_at

  created_at = property(GetCreatedAt, SetCreatedAt,
                        doc='The time this status message was posted.')

Original issue reported on code.google.com by spa...@gmail.com on 2 Mar 2009 at 5:27

GoogleCodeExporter commented 9 years ago
Yes, I think that is the right approach.  In fact, I've been tentatively 
planning to
use protobufs for the next version of this library to mirror the work on
java-twitter.  The python protobuf interface does exactly what you recommend.  
See
http://code.google.com/apis/protocolbuffers/docs/reference/python-generated.html
 for
details.

This will of course break backward compatibility, so it should wait until a 
version 2.0.

Original comment by dclinton on 2 Mar 2009 at 5:38

GoogleCodeExporter commented 9 years ago
I'm a big +1 on this too. If class members have well-chosen names, they don't 
even
need commenting (they can be described in the docs, in examples, of course), let
alone a getter/setter. The above example is nicely chosen :-)

Terry

Original comment by terry.jo...@gmail.com on 2 Mar 2009 at 5:45