You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I disagree that setValue/getValue style accessors are better than jQuery-style value()/value(10) accessors. They add unnecessary name length, and require twice as many function definitions.
Admittedly, it's slightly faster for a VM to deal with functions that always return a single value type, as opposed to sometimes returning a type and sometimes returning nothing. But it's also slightly faster to download scripts using jQuery-style accessors, because the function keyword, prototype keyword, and public property names are unminifiable -- and we've yet to run into issues where our JS was too slow (whereas we do run into issues where our files are too big). If we have to compromise in one direction, I'd lean towards filesize over VM execution speed.
Additionally: the setters can still return a value, despite being "only" setters. Which means the VM executes just as quickly as it normally does.
I picked using getValue / setValue because intent is clearer and you don't have to type out if (!arguments.length) { return this.val } everytime you want to make a new get/set for a property. I prefer the get(prop) / set(prop, val) way.
I can go either way on this one. Methods in Monorail, and often in our JS, are longer than they should be. Methods should be short and do only what their names say they do. By splitting into get and set, you know exactly what the methods do.
The jQuery way can be tricky if you don't check the value you pass to it. This is a contrived example, but it could happen:
functionObj(){}Obj.prototype.val=function(value){if(typeofvalue==='undefined'){returnthis.value;}else{this.value=value;}};vara;varb=10;varobj=newObj();obj.val(50);if(b>20){a=15;}// Expect to clear / set to undefined?obj.val(a);
That being said, we all use jQuery without any problems.
Activity
hshoff commentedon Nov 1, 2012
Up for whatever.
I picked using
getValue/setValuebecause intent is clearer and you don't have to type outif (!arguments.length) { return this.val }everytime you want to make a new get/set for a property. I prefer theget(prop)/set(prop, val)way.ssorallen commentedon Nov 2, 2012
I can go either way on this one. Methods in Monorail, and often in our JS, are longer than they should be. Methods should be short and do only what their names say they do. By splitting into
getandset, you know exactly what the methods do.The jQuery way can be tricky if you don't check the value you pass to it. This is a contrived example, but it could happen:
That being said, we all use jQuery without any problems.
spikebrehm commentedon Nov 2, 2012
I don't like the ambiguity that comes with using
value()/value(10).hshoff commentedon Nov 2, 2012
We just need to be consistent.
reissbaker commentedon Nov 2, 2012
Eh, guess I'm outvoted on this one. Oh well.
Code style #4
Merge pull request airbnb#4 from drivetribe/grid-system-components
Correctly require es2017 from es2016
RTL fix airbnb#4
edit airbnb#4 on branch1