Loading ...
Sorry, an error occurred while loading the content.

Re: [XP] Re: Good practices We No Longer Need

Expand Messages
  • Peter Hansen
    ... I can answer for myself and perhaps a handful of others. I no longer worry so much about public instance variables, and apparently neither do quite a few
    Message 1 of 6 , Apr 1 6:21 PM
    • 0 Attachment
      Kevin Lawrence wrote:
      >
      > In the past, I have typically made methods as private as possible unless I
      > have a good reason to make them more public. Why ?
      >
      > How many people would question the rule
      > that proscribes public instance variables ?

      I can answer for myself and perhaps a handful of others. I no
      longer worry so much about public instance variables, and apparently
      neither do quite a few Python coders. Python best practices tend
      to focus on pragmatism more often than not and in this case they
      seem to say "if you don't need it to do something magic under the
      covers, what's the big deal about allowing external access?"

      (No doubt one could say this is rationalizing Python's minimal
      enforcement of data hiding.)

      The resulting code generally seems more readable to me since
      you don't have the accessor methods getting in your mental way.

      > If you tell me that I might need to *do something* when the value
      > changes, I have a five letter answer for you.

      You Aren't Gonna Need It. (At first I thought I was giving you an
      alternative point of view, but now I think that must have been the
      "five letter answer" you meant. :)

      Of course, sometimes conditions change and you do need it, but
      then you change the tests, refactor the code, and you're in.

      -Peter
    Your message has been successfully submitted and would be delivered to recipients shortly.