-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question regarding your usage of a getter #274
Comments
Your question is confusing because your examples are not semantically equivalent. To access To access |
Sorry, I should have been more explicit in my question. I was really probing into why the author preferred a getter (and by implication, setter) approach rather than a more common functional interface such as obj.getFoo() In other words, I was using the example as an excuse to engage in a broader discussion about the proper use cases for getters and setters. I've read the documentation at to how to use them but, as Jonathan Freeman pointed out, I'm not sure as to when or why to use them. Thanks in advance for any insights. |
The only reason the docs page uses this pattern is as an example for how to IMHO, the general reason to use getters and setters is to unify the If this.foo += 3; It's useful to programmers to be able to imbue this.setFoo(this.getFoo() + 3); Also, unless you got 100% to functional interfaces, the user must Ultimately these are subjective differences. My personal taste runs towards On Fri, Sep 13, 2013 at 8:39 AM, stela5 notifications@github.com wrote:
|
Thanks! |
I'm not a JavaScript expert so I could be totally wrong on this, but for the http://www.polymer-project.org/polymer.html docs page, instead of
wouldn't it be clearer to use
See:
http://jtfreeman.blogspot.com/2013/07/javascript-getters-and-setters-last.html
http://jsperf.com/es5-getters-setters-versus-getter-setter-methods/10
The text was updated successfully, but these errors were encountered: