3 ms·
I hardly feel that backbone is well written and straightforward. This is one of the lines in backbone.js: if ((callback && callback !== (ev.callback._callback
by jtchang 14y ago
I hardly feel that backbone is well written and straightforward.
This is one of the lines in backbone.js:
if ((callback && callback !== (ev.callback._callback || ev.callback)) || (context && context !== ev.context))
I feel stuff like this takes a lot of mental power to understand the context that it is being executed in and what exactly it is doing. It feels like I am knee deep in some obfuscated C code.
- tubbo 14y agoYeah dude I feel you. How confusing is Ruby on Rails too? I mean, this is one of the lines in Rails: end Come on man?? How the fuck am I supposed to know what that means? End what? And where do we begin??! :rolleyes:
- ams6110 14y agoIt's not that hard when you know the idioms. && is a guard and || is a default. With a little bit more context and experience in writing concise javascript, it's actually pretty clean.
- nailer 14y agocallback._callback seems a little obscure to me.
- wilmoore 14y agoI wouldn't go so far as to say this is horrible code, I also wouldn't say this is good refactored code. It definitely gets the job done; however, I would imagine someone figures they'll come back and refactor at some point. Code is never finished, it is merely shipped. This is shipping code, but it certainly can be refactored into a more intention revealing function. It's a trade-off. If you pull it into a new function, it adds LOC. It also is another layer of abstraction. Is it worth it? Perhaps...but maybe not. Just looking at this one line of code in isolation without context is a bit unfair though.