4 ms·
I disagree with the point about 80 chars limit. If the line consists of boilerplate code, I will allow it to go over 120-160 chars most of times. The idea is t
by watt 14y ago
I disagree with the point about 80 chars limit.
If the line consists of boilerplate code, I will allow it to go over 120-160 chars most of times. The idea is to just get that code out of sight, as nobody should have to read it anyway. If it's important, I will break the line up. If not - like a long exception message that gets constructed with bunch of context information - I'll let it grow out of window. It's not something you will need to look at, read and grok every day. And I am happy to have it out of sight most of time.
I break up lines when thinking about stepping through them in debugger (though javascript debuggers seem to be able to step statement by statement, not line by line).
- mattdeboard 14y agoWe're so different, you and I. "Getting code out of sight because it's ugly" is such a foreign concept. If a code block is that ugly, it either needs to be made not ugly or put directly in the line of sight with plentiful comments. "Shouldn't have to read it" !== "won't ever have to read it."
- ThePherocity 14y agoI agree completely with this, all code should be visible, but I still go well over 80 personally because I'm don't, nor will anyone likely edit my code on a 80 char terminal. When I was hacking on an IBM mainframe through a 3270 terminal, the 80 character limit made a lot of sense. Why use the 80 char rule because of an edge case of some throwback editing javascript in a term that only allows for 80 characters? I mean, who does that?
- mattdeboard 14y agoI mean even reviewing code on Github... if you go over 80 (or close to it, not sure the exact column count) it forces scroll. I dunno, it's just convention. I break at 80 cols.
- Roboprog 14y agoMe. When I bring up the Netbeans editor, there is a red line down the right margin at column 80, and I'm not inclined to change that setting, although I sometimes type a few characters past it. This is a wise tradition, handed down from the tribal elders :-) I sometimes need to see at least a little bit of something else on screen besides your hideously wide code. If you ever have to print out code, it makes a nice line size convention as well. Printing is becoming less common, unless you publish books, but it's still worth considering that it might be easier for the reader if the lines aren't mind-numbingly long. Why do newspapers have multiple columns of text, when clearly they have space to go 14 inches or more across?
- Roboprog 14y agoAlmost forgot: if you need more than 80 columns, your routine is probably too long. Indicated by deep nesting, and/or variable names that need to be more than one or two English words because the scope and intent of the variables is not obvious.
- ThePherocity 14y agoYou don't write in Objective-C for an Apple then, eh?
- Roboprog 14y agoNot much, no. (for a few weeks, 2 years ago, so literally, some, but not bloody much) Can the args to messages not be put on a continuation line?
- ThePherocity 14y agoYea, they can, but some of the names are overly verbose.
- deleted 14y ago[deleted]
- muriithi 14y agoThe only way I can know that the code is boilerplate and "nobody should have to read it anyway" is by reading it. Why make me scroll horizontally?
- techdmn 14y agoI had a manager once who would seriously write 250-500 character lines of VB6. When I see code disappear off the right margin I get very nervous. You can hide a lot of functionality that way, especially if your language supports multiple statements on a single line.