Earlier quoted context omitted.
Please take the time to review and correct this sentence next time you copy-paste. This is a painful read.
Missing the occasional definite article out is something that seems to be fairly common with second language english speakers. I decided some time ago that it was worthwhile forcing myself to adjust until it wasn't noticeably painful; there are too many people out there I want to communicate with who do it.
Line length in programming
51–60 of 74 posts
Re: Line length in programming
#52Earlier quoted context omitted.
Or python if you're already in a function in a function in a class (so 68 chars left). If you also standardised on importing modules, not classes things can get silly. My favourite counter-example to the 80 char limit was a line in openstack which was: return some_loaded_module.fairly_descriptive_but_necessarily_long_name(not_very_long_argument) The way applied to fit it without forced line breaking? fdbnln = some_lo…
In perl I'd just write - return $some_loaded_thing->fairly_descriptive_but_necessarily_long_name( $not_very_long_argument ); Surely python has something approximating an equivalent?
Re: Line length in programming
#53Never ending stories - tab vs spaces - line length - republican vs democrats - favorite colors
Re: Line length in programming
#54I'm glad we talk about this. Once we have solved this question we can move on to really important stuff, like tabs vs spaces.
Code is read far more than it is written. Therefore code legibility is important. Line length affects code legibility. Therefore line length is important.
Re: Line length in programming
#55In my opinion the 80 character limit is mostly for better presentability. If the code appears in a blog post or a book, it is better to read and typeset if it is less than 80 characters. Though there are several articles[1] which explain other reasons for this legacy limitation. I would be happy to read code more than 80 characters, if it doesn't have to be artificially cut into multiple lines (the screenshot in the…
IMO, given that most blog templates include copious margins, many don't allow readers to resize the text, and some don't even allow readers to scroll horizontally, 80 characters is far too long for a line of code in a blog post.
Re: Line length in programming
#56Earlier quoted context omitted.
Really? class Engineer(Person): __tablename__ = 'engineers' __mapper_args__ = {'polymorphic_identity': 'engineer'} engineer_id = Column('id', Integer, ForeignKey('people.id'), primary_key=True) primary_language = Column(String(50)) 12345678901234567890123456789012345678901234567890123456789012345678901234567890 ^^ Line length marker Woops. 2 characters over. Do we really need a line break there? Guess perhaps I shoul…
> Really? Yes, really. > Woops. 2 characters over. Do we really need a line break there? You do what you want. > I don't think 'you can just refactor that to be shorter' is really a solution in all circumstances. You don't think the solution I didn't advocate as a cure-all in the first place is a cure-all? Am I supposed to be surprised at this finding?
Anyway, that example is straight from the sqlalchemy examples, which is arguably (other than the extremely wordy Zope) most commonly used python orm around.
Wordy database interaction is really common point this sort of thing, and it's hard to refactor/rewrite your way out of it; that's the only real point I'm making.
I personally think strict adherence to line length limits reduces code quality; you've got to use common sense for it.
Re: Line length in programming
#57Here is what I've said about 80 char in the past. "If the argument for expanding to 100 or more is that screen is getting wider, then the benefit of wide screen is the ability to fit multiple terminals in one window. For normal workflow, I'd split my windows into two or terminals, depending on what I am doing, so I don't see any benefit in increasing the limit."
Touche. Multiple monitors and more screen real estate has been proven to increase productivity. It's an easy win. If the lines come out too long too often, it may be a symptom of other problems. if ((browser.OS == 'win') && (browser.userAgent == 'IE')) { is often better written as: isIE = (browser.userAgent == 'IE'); isWindows = (browser.OS == 'win'); if (isIE && isWindows) { It's self-documenting and reads like natu…
Re: Line length in programming
#5880 chars is a useful rule of thumb, so long as it's tempered by practicality. I've worked on projects where the limit was taken far too literally, which results in code that's harder to read. This is especially true if you're using something verbose (Java, Objective-C) or whitespace-sensitive (Python).
For what it's worth, in my opinion, if you need more than an 80 character line in Python, you're doing it wrong. I currently maintain a large Python codebase where the original authors /needed/ big long lines. Anytime I see one of these big wads of bubble gum, I know I can rewrite it to be simpler, clearer and shorter (I've done it enough now). Fortunately, there are increasingly fewer of them... It's important to re…
Re: Line length in programming
#5980 is too few. The old reason for it (what if you get stuck doing an emergency bugfix using vi on an 80 char display?!?) no longer holds. It's not massively too few, and most lines never get close to the limit anyway, but the odd line of 100-120 thrown in really isn't a problem on a modern display.
That is a straw man. No one actually thinks 80 character displays are the reason to use 80 characters. I think 80-100 is fine. More than 100 and you probably need to refactor the line some, because you probably have too much logic on a single line (or you need to choose names that aren't hugely long).
Re: Line length in programming
#60Earlier quoted context omitted.
Or python if you're already in a function in a function in a class (so 68 chars left). If you also standardised on importing modules, not classes things can get silly. My favourite counter-example to the 80 char limit was a line in openstack which was: return some_loaded_module.fairly_descriptive_but_necessarily_long_name(not_very_long_argument) The way applied to fit it without forced line breaking? fdbnln = some_lo…
In perl I'd just write - return $some_loaded_thing->fairly_descriptive_but_necessarily_long_name( $not_very_long_argument ); Surely python has something approximating an equivalent?