Re:Treating JavaScript like a 30 year old language
by greggman on Wednesday July 04, 2012 @02:57PM
(#4200477)
>> I find that naming things descriptively and an 80 character limit are at odds.
> I don't. I use descriptive names for functions and short, concise words for variables (sometimes clear abbreviations)
That might work. Unfortunately abbreviations are forbidden by the Google Style Guide.
> As for lining up
my point still holds. Either lining up helps or it doesn't. If it doesn't help then lining up comments should not be allowed. If it does help, then it helps every where.
var infos = [
{ name: "red", value: [255, 0, 0, 255], },
{ name: "green", value: [ 0, 255, 0, 255], },
{ name: "blue", value: [ 0, 0, 255, 255], }
];
Is vastly easier to read and find errors in IMO than this var infos = [
{ name: "red", value: [255, 0, 0, 255], },
{ name: "green", value: [ 0, 255, 0, 255], },
{ name: "blue", value: [ 0, 0, 255, 255], }
];
The first is not allowed by the Google Style guide. It requires the 2nd.
Re:Treating JavaScript like a 30 year old language
by mundizzle on Wednesday July 04, 2012 @04:02PM
(#4200696)
i generally avoid putting all properties of an object in one the same line in the name of readability and also to avoid the 80 char limit.
instead i do something like this. (incorrect trailing commas removed from the previous example)
var infos = [
{
name: "red",
value: [255, 0, 0, 255]
},
{
name: "green",
value: [0, 255, 0, 255]
},
{
name: "blue",
value: [0, 0, 255, 255]
}
];
Re:Treating JavaScript like a 30 year old language
by jacobolus on Wednesday July 04, 2012 @08:49PM
(#4201308)
How’s this then, for another example:
M_CAT02 = new Matrix3([
.7328, .4296, -.1624,
-.7036, 1.6975, .0061,
.0030, .0136, .9834])
M_HPE = new Matrix3([
.38971, .68898, -.07868,
-.22981, 1.18340, .04641,
.00000, .00000, 1.00000])
Without lining those all up, it becomes a real pain in the butt to read the matrix.
Re:Treating JavaScript like a 30 year old language
by mhansen on Wednesday July 04, 2012 @11:49PM
(#4201667)
Nowhere are abbreviations forbidden by the Google Style Guide.
Re:Treating JavaScript like a 30 year old language
by binarysoul on Wednesday July 04, 2012 @04:14PM
(#4200726)
its not difficult to maintain. Emacs in particular has M-x align-regexp = (which does the alignment for you)
I don't. I use descriptive names for functions and short, concise words for variables (sometimes clear abbreviations).
> Another nit, Google Style guides disallow formatting for readability except for comments?!?!
> Allowed
> [regularly formatted variable declarations]
> Not allowed
> ["pretty" formatted variable declarations with indentation]
Code Complete 2 explicitly discourages the latter style, and I tend to agree. It's too difficult to maintain.