When building an actual webapp, the Backbone method is going to be much easier to extend, test, and understand versus jQuery spaghetti.
> [The backbone] code is more maintainable, easier to reuse and extend, and easier to test.
"Ravioli Code"
process_foos = function(my_list) {
for (i=0; i<my_list.lengh; i++) {
process_foo(my_list[i]);
}
}
process_foo = function(foo) {
foo.some_method();
}
And foo.some_method (in another file) was similar. What it meant was it was impossible to get a view of what was going on in the system. It took months to accomplish an understanding that should have taken weeks.I really think the original authors heard your advice and decided comprehension didn't matter, only function length.
Function should accomplish a task. Sometimes (very rarely) a task may be two hundred lines; usually, it is much shorter. Sometimes three lines, but often 15-20.
Large methods are only a symptom that this component of your system does too much and probably has too many dependencies. Small methods do nothing for you except add indirection if you've not solved the dependency problem, and adding indirection to an entangled system is even worse than having large methods.
In other words, somehow an aspect of the end result of clear code became common advice, probably because it's so obvious and replicable. "Write decoupled code with focused responsibilities" on the other hand is nebulous.
It's sort of like when dating advice is simplified into "be mean to girls".
I've read that claim. The only time I really had to work with code like that was horrible.
It was like a book where the sentences were in random order, with the next sentence number appended, so you would have to browse to another page every few words. :-(
The context switches didn't make me productive... Sometimes, I had to look 3-4 levels up or down in the hierarchy to find a parameter type (this was in a scripting language). If anyone talked to me, it took a looong time to rebuild the model in my head.
Edit: In short, grandparent++.
The first one is to take logically unrelated operations and combine them into one giant blob via shared/global variables and god objects/methods. This is what commonly known as spaghetti code.
The second one it to take every piece of functionality and shatter it into tiny pieces, so no unit of code represents anything anymore. This can be done with endless callbacks or layers of abstraction, and it can be made worse by complex frameworks with a lot of "magic" taking place or a lot of boilerplate being required. I don't know any common name for this, but let's call it mush coding.
It looks like the post describes how to convert moderately readable spaghetti code into unreadable mush code. (I would claim that a person not familiar with JQuery could easily understand the initial code, while a person not keenly familiar with Backbone would be completely lost in the final version.)
If most of your methods are longer than 100 lines, something is probably wrong. If most of your methods are shorter than 3 lines, something is probably wrong as well.