Re:Show HN: Textures.js, SVG Patterns for Data Visualization
by ttty on Wednesday March 18, 2015 @06:51PM
(#9229183)
Image you have an UI which talks to this. For example you have a button on/off. How would you do?
var t = texture().lines().stroke('red')
if(this.button.on) t= texture.heavier()
Compare the previous with this one. var t = texture({lines: true, heavier: this.button.on, stroke: 'red'})
I also hate the non standard constructor: this should be like this var texture = new Texture({lines: true, heavier: this.button.on, stroke: 'red'});
Re:Show HN: Textures.js, SVG Patterns for Data Visualization
by siddboots on Wednesday March 18, 2015 @11:53PM
(#9230118)
"heavier: this.button.on" has ambiguous semantics. Do libraries really use this pattern?
Also, use of the "new" keyword is contentious. You can hardly pretend that it is best practice.
I feel it’s a matter of taste, but one practical reason I prefer chaining to configuration objects is that you get a runtime error when you misspell a property, rather than it being silently ignored.