您的最大线路尺寸偏好是多少? [英] What's your maximum line size preference?

查看:84
本文介绍了您的最大线路尺寸偏好是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



您对C ++代码的最大行宽有偏好吗?


我看过关于这个最愚蠢的主题的最激烈的辩论。


我目睹了工程师花费大量时间摆弄线路

休息只是为了让它正确。我发现一般来说是一个规定性的规则

会产生明显不太可读的代码,不幸的是这是一个主观论证,但是,当它代码时,浪费时间修改代码>
不需要。


我很想知道你们都做了什么。


G


Do you have a preference on maximum line width for C++ code?

I''ve seen the craziest debates on this most silly of topic.

I have witnessed engineers spent oodles of time fiddling with line
breaks just to get it right. I find in general a prescriptive rule
makes for markedly less readable code, which unfortunately is a
subjective argument, however, the waste of time modifying code when it
does not need to is not.

I''m interested in knowing what you''all do.

G

推荐答案

Gianni Mariani写道:
Gianni Mariani wrote:

>

你对C ++代码的最大线宽有偏好吗?
>
Do you have a preference on maximum line width for C++ code?



大约80.我发现我很少写出比这更长的行,我更喜欢

有几个文件并排打开。


-

Ian Collins。

About 80. I find I seldom write lines longer than this and I prefer to
have several files open side by side.

--
Ian Collins.


Gianni Mariani写道:
Gianni Mariani wrote:

您对C ++代码的最大行宽有偏好吗?
Do you have a preference on maximum line width for C++ code?



历史上80个字符一直是建议的最大值,因为

文本终端是那么多字符宽,并试图编辑代码

行的长度要比水平滚动要长

(假设你的文本编辑器支持)或丑陋的换行。


现在有80个字符全程终端很少用于编程

而是使用高分辨率的b $ b b监视器上的可自由调整大小的图形编辑器,因此没有实际或技术限制。


但是,我个人仍然保持我的emacs为80个字符并避免比编程时更长的b $ b行。 IMO代码行太长了有点像文本行太长了:难以阅读。

非常糟糕的情况是当代码行太长以至于它们不符合显示器宽度的b $ b你需要水平滚动

看到整行(非常糟糕的可用性)或行被包裹,

这使代码更难阅读。我看过那里的代码

严重破坏了这个概念并且使用了很长的线条,这是一个很棒的想法。


我认为80个字符的宽度很好,虽然我不反对

略大的东西,例如。 100个字符。

Historically 80 characters has been the recommended maximum because
text terminals were that many character wide, and trying to edit code
lines longer than that would require either scrolling horizontally
(assuming your text editor supported that) or ugly line wraps.

Nowadays 80-character-wide terminals are seldom used for programming
and instead freely-resizeable graphical editors on high-resolution
monitors are used instead, so there''s no practical or technical limit.

However, personally I still keep my emacs at 80 characters and avoid
lines longer than that when programming. IMO code lines which are too
long are a bit like text lines which are too long: Hard to read. The
very worst case scenario is when code lines are so long that they won''t
fit the width of your monitor and you either need to scroll horizontally
to see the entire line (very bad usability) or the lines are wrapped,
which makes the code even harder to read. I have seen code out there
which badly break this concept and use humongously long lines, which is
a braindead idea.

I think the 80 characters is a good width, although I wouldn''t oppose
something slightly larger, eg. 100 characters.


Gianni Mariani写道:
Gianni Mariani wrote:

您对C ++代码的最大行宽有偏好吗? ?


我在这个最愚蠢的话题上看过最疯狂的辩论。


我目睹了工程师花费大量时间摆弄线路

打破只是为了正确。我发现一般来说是一个规定性的规则

会产生明显不太可读的代码,不幸的是这是一个主观论证,但是,当它代码时,浪费时间修改代码>
不需要。


我很想知道你们都做了什么。
Do you have a preference on maximum line width for C++ code?

I''ve seen the craziest debates on this most silly of topic.

I have witnessed engineers spent oodles of time fiddling with line
breaks just to get it right. I find in general a prescriptive rule
makes for markedly less readable code, which unfortunately is a
subjective argument, however, the waste of time modifying code when it
does not need to is not.

I''m interested in knowing what you''all do.



可读性是我们团队关注的一个因素,因为它有几百强。

每次编写代码时,都必须考虑(a)它不会被你读取,而b(b)如果它会被你读,它可以是一个

年或更晚。所以,基于此,我认为如果行

完全适合我的编辑器的代码窗口,那么我不必滚动

窗口水平地读取整行,宽度是可以接受的。

现在,这可能意味着在另一个男人的监视器上它可能太长了

长(如果代码窗口并不像我的那么宽,不幸的是那里没有治愈价格。希望显示器能够升级,如果

线路长度不变,最终所有线路都适合。 < weakG>


就像任何其他样式元素一样,行长度参与

折衷。例如,你可以通过使用较短的变量和函数来缩短你的行数,但是它会降低你自己的可读性,可能更令人不愉快。


空格(包含换行符)在代码中具有重要作用

可读性,但我可能会说,不要挂断它 ;。

能够阅读和理解任何代码而不会浪费太多时间

重新格式化是每个程序员*需要开发的技能。


只是我的

Readability is a concern in our team because it''s a few hundred strong.
Any time you write code, you have to consider that (a) it''s not going
to be read by you and (b) if it''s going to be read by you, it can be a
year or more later. So, based on that, I would think that if the line
fully fits in my editor''s code window, so I don''t have to scroll the
window horizontally to read the entire line, the width is acceptable.
Now, it probably means that on the other man''s monitor it could be too
long (if the code window isn''t as wide as mine), and unfortunately there
is no cure for that. Hopefully, the monitors do get upgraded and if the
line lengths don''t change, eventually all lines will fit. <weakG>

Just like any other style element, the line length participates in a
compromise. For example, you can shorten your lines by using shorter
names for variables and functions, but it detracts from readability in
its own, possibly more unpleasant, way.

Whitespace (line breaks included) has an important role in the code
readability, but I would probably say, "don''t get hung up on it". The
ability to read and understand any code without wasting too much time on
reformatting is a skill *every programmer* needs to develop.

Just my


这篇关于您的最大线路尺寸偏好是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆