News for hackers. Stuff that matters.
Re:Writing Eloquent JavaScript Without CoffeeScript by mattmanser on Friday December 09, 2011 @10:17AM (#3333955)
I don't want to sound like an asshole and I'm saying nothing about the author, but in my personal experience I found lining up variables or =s was something I worried about when I first started programming.

Now my mind's eye just totally skips variable declaration when visually code parsing, variable declaration is meaningless drivel that exists only to stop typos (a good purpose).

I had an opinion on the layout of them back then because I wasn't a good enough programmer yet to have an opinion on anything else, I had opinions on things that didn't matter because those were the only things I actually understood well.

Also, again in my personal experience, it's much better to declare them just before you use them for future maintenance, having 4 or 5 declarations at the same time is something I do so rarely now. If you start faffing around laying them out, you're going to be tempted to put them all together.

Re:Writing Eloquent JavaScript Without CoffeeScript by dspillett on Friday December 09, 2011 @11:44AM (#3334370)
You should remember that you are not the only person that is going to be trying to read that code (unless it is a personal project, of course). Good layout helps other people read, understand and debug your code at a later date (as well as you at a later date, when you've long since moved on to other pojects in terms of active development work).

Also with Javascript's function-scoped variables and the fact it will let you declare them more than once in a given scope (the second and subsequent decleration being taken as either a NOOP or a basic assignemtn (if there is assignment with the decleration), declaring variables at the point of first use can be dangerous as it is easy, especially if you are messing around in global scope (which is to be availaded generally, but can't always be), to create hard to diagnose bugs due to variable values being clobbered because the same name is used elsewhere.

Re:Writing Eloquent JavaScript Without CoffeeScript by jakejake on Friday December 09, 2011 @02:26PM (#3335163)
Same here - I used to line up variables with tabs and such to try to make things look neat and put in lots of dashed lines to separate groups of functionality. I don't know if it's experience or just preference but I don't like doing that anymore.

I find it much more important to put in javadoc style comments to make the code understandable for other users rather than lining things up nicely.

If you're using an IDE you can view all of the variables and methods sorted however you like anyway with a class or outline view.