Hacker News new | past | comments | ask | show | jobs | submit login

I love chaining, but one verb per line. Instead of something like

    Me.getFish.skin.debone.flour.salt.fry.eat
It would be something like

    Me.getFish
      .skin
      .debone
      .flour
      .salt
      .fry
      .eat
I find this more readable than doing it without chaining like this:

    fish = Me.getFish
    fish.skin
    fish.debone
    fish.flour
    fish.salt
    fish.fry
    Me.eat(fish)



I find the version without chaining easier to debug.


I don't know, I'd just set a breakpoint in my editor regardless of the form?


personally I prefer without chaining, makes much more sense as its what I've always seen until the last ~5 years.

The other part you didn't mention is that you have to amend all the functions like getFish, skin etc to return the object which I think makes their signature unnecessarily less clear.


Yeah, just because something looks like chaining doesn't mean it's really repeated calls on the same object. Even with some static-checking of types, it could also be a copy of the object.

While blocky, the repeated thing.do() format is explicit about what object is being operated on.




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: