Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
I'm ashamed to say some of my quick and dirty scripts look similar. Usually clean them up into multiple functions in a separate file when I can.
-
umnikos9658y@tisaconundrum At least it's better than a single if that is long 1000 characters and chained with ands...
-
Root797708yOne level of indentation is a good rule of thumb, but not always achievable. especially in JS.
-
Root797708y@Greggergalactic
In the case of Promises -- and especially serial Promise trees -- this is extremely difficult to do.
CoffeeScript:
function = (args) ->
externalPromiseService(args)
.then (resolve_value) ->
# code (interior)
, (err) ->
# catch
That's three levels of indenting before getting to your code. You can offload the interior to another method, but you've still exceeded the rule-of-thumb by two levels. Serial Promises require three levels of boilerplate, and breaking those levels out decreases their readability. -
Nesting, nesting, nesting.
If you turn it to the left
it kind of looks like the iron
throne. -
Root797708y@andros705 they're actually quite useful. But if you want to yell at JavaScript for supporting them, you should include a few others in your tirade: Ruby, Lisp, Python, Haskell, C++/C#, Java, Go, Lua, Perl, PHP, R, Rust, Scala ...
Related Rants
"Only one level of indentation per method". This image just made my day :)
undefined
php
ryu
indentation
hadouken