Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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'});


"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.


It should be

    var t = texture().lines().stroke('red')
    if(this.button.on) t.heavier()




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: