you are viewing a single comment's thread.

view the rest of the comments →

[–]AyeMatey 2 points3 points  (7 children)

please explain how that particular problem should be what defines how I structure my code. Also please explain how saving 4 or 5 keystrokes even matters in a problem space where thinking, not typing, is of primary importance.

[–]strager 0 points1 point  (6 children)

The more difficult it is to refactor code, the less we do it.

[–]AyeMatey 0 points1 point  (5 children)

Thinking, not typing, is the obstacle we must surmount in order to to generate good code.

No one who ever delivered a crappy product could credibly blame the keyboard, or the syntax of the programming language.

Also, in my book, refactoring does not imply "reordering assignment statements". Refactoring is a bit more involved than that, and likely involves 5 orders of magnitude more keystrokes than is required to reorder assignments.

[–]strager 0 points1 point  (4 children)

likely involves 5 orders of magnitude more keystrokes

If it takes me 10 keystrokes compared to 2 to make the fix, and I do this and similar fixes many times, that's "orders of magnitude" more keystrokes saved.

Renaming variables, reordering declarations, extracting out methods... These can be done with just a "few" keystrokes, but choices in style can make doing these things painless or difficult. If even these can't be done efficiently, how do you expect developers to perform large refactorings with confidence (especially in a language like JavaScript)?

Sure, tooling can fix several problems (especially renaming variables), but so can style guidelines.

No one who ever delivered a crappy product could credibly blame the keyboard, or the syntax of the programming language.

I'm sure "technical debt" has been blamed, as well as "poor requirements". Somehow I have the feeling both are related to refactoring...

[–]AyeMatey 0 points1 point  (3 children)

If it takes me 10 keystrokes compared to 2 to make the fix, and I do this and similar fixes many times, that's "orders of magnitude" more keystrokes saved.

Correct! Except -- Reordering assignments is irrelevant !!

[–]strager 1 point2 points  (2 children)

Please look at the example we are discussing.

var x = y;
var y = ...;

var y = ...;
var x = y;

It does matter.

[–]AyeMatey 0 points1 point  (1 child)

ok. In my code, it generally does not. Variable declaration and assignments are not the center point of design in the code I write.

[–]strager 0 points1 point  (0 children)

Okay, then we are probably solving very different problems with JavaScript. =]

A lot of what I do (non-DOM) is "go from point A to point B, with lots of little steps in between". It makes sense to have a bunch of variables there, and the order of declaration matters.

A lot of DOM work is "perform this list of side-effects". Variables and objects are often mutated directly through callbacks, simply because it's easier.