Note that there are some explanatory texts on larger screens.

plurals
  1. POGetters and Setters: Code smell, Necessary Evil, or Can't Live Without Them
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/996179/allen-holub-wrote-you-should-never-use-get-set-functions-is-he-correct">Allen Holub wrote &ldquo;You should never use get/set functions&rdquo;, is he correct?</a> </p> </blockquote> <p>Is there a good, no, a <em>very</em> good reason, to go through all the trouble of using getters and setters for object-oriented languages? What's wrong with just using a direct reference to a property or method? Is there some kind of "semantical coverup" that people don't want to talk about in polite company? Was I just too tired and fell asleep when someone walked out and said "Thou Shalt Write Copious Amounts of Code to Obtain Getters and Setters"?</p> <hr> <p>Follow-up after a year:</p> <p>It seems to be a common occurrence with Java, less so with Python. <a href="http://cafe.elharo.com/programming/java-is-dead-long-live-python/" rel="nofollow noreferrer">I'm beginning to wonder if this is more of a cultural phenomena (related to the limitations of the language) rather than "sage advice".</a> As I do not program in Java (currently by choice) I cannot make that assessment.</p> <p>The current (current being as of this writing 2010-03-22) -1 question score is complete for-the-lulz as far as I am concerned. It's interesting that there are specific questions that are downvoted, not because they are "bad questions", but rather, because they hit someone's <em>raw nerve</em>.</p> <p>So let's get to the nut of the matter. I repeat myself:</p> <p><code>What's wrong with just using a direct reference to a property or method?</code></p> <p>And here's the unwritten corollary:</p> <p><code>Are we so undisciplined as programmers that we can't keep our hands off of things that are clearly marked "no touchy"?</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload