首选编码风格 [英] Preferred coding style

查看:96
本文介绍了首选编码风格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇你们中有多少人喜欢风格1和风格2,以及为什么。

有这些风格的名字吗?


风格1:


方法{


}

样式2:


方法

{


}

I am curious about how many of you prefer style 1 vs. style 2, and why. Are
there names for these style?

style 1:

method {

}
style 2:

method
{

}

推荐答案

我会全心全意地同意!!


-Noah Coad

Microsoft MVP& MCP(.NET / C#)


Nicholas Paldino [.NET / C#MVP]" < NI ************** @ exisconsulting.com>在消息新闻中写了

:Od ************** @ TK2MSFTNGP10.phx.gbl ...
I would wholeheartedly agree!!

-Noah Coad
Microsoft MVP & MCP (.NET/C#)

"Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com> wrote
in message news:Od**************@TK2MSFTNGP10.phx.gbl...
Craig,
就个人而言,我使用的是风格2.这只是一种偏好。我不知道是否有这些款式的名称,但我更喜欢称款式1丑陋。并且
风格2漂亮。 =)

尽管如此,我发现通过使用样式2来区分代码块对我来说更容易


-
- ni **** **********@exisconsulting.com

克雷格 < e@mail.com>在消息中写道
新闻:et ************** @ tk2msftngp13.phx.gbl ...
Craig,

Personally, I use style 2. It''s just a preference. I don''t know if
there is a name for those styles, but I prefer to call style 1 "ugly" and
style 2 "pretty". =)

In all seriousness though, I find for myself that it is easier for me to distinguish code blocks by using style 2.
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com

"craig" <e@mail.com> wrote in message
news:et**************@tk2msftngp13.phx.gbl...
我很好奇你们有多少人喜欢风格1与风格2,以及为什么。
I am curious about how many of you prefer style 1 vs. style 2, and why.


这些风格的名称是什么?

风格1:

}

样式2:

方法
{

}
there names for these style?

style 1:

method {

}
style 2:

method
{

}




#2 - 将大括号放在同一垂直轴上有助于我视觉上
确定起始和结束的支撑对。


它还使您无法识别声明

作为''嵌入''(即在一个范围的声明之后的一行)

没有大括号)当它不是。


最后的原因,在VS.NET中使用大括号匹配或

在其他地方,光标没有跳到右边(这就是

很烦人的情况下,我有一个长行滚动

前几行o关闭屏幕的方法。


Richard
#2 - Keeping the braces on the same vertical axis helps me
visually identify starting and ending brace pairs.

It also precludes you from identifying a statement
as ''embedded'' (i.e. one line after a scoped statement with
no braces) when it is not.

And final reason, when using brace-matching in VS.NET or
elsewhere, the cursor does not jump to the right (which is
annoying in cases where I have a long line that scrolls
the first few lines of a method off the screen.

Richard
-----原始消息-----
我很好奇关于你们中有多少人喜欢风格1和
风格2,以及为什么。这些风格的名称是什么?

风格1:

方法{

}

风格2:
方法
{

}

-----Original Message-----
I am curious about how many of you prefer style 1 vs. style 2, and why. Arethere names for these style?

style 1:

method {

}
style 2:

method
{

}
.



craig< ; e@mail.com>写道:
craig <e@mail.com> wrote:
我很好奇你们中有多少人喜欢风格1和风格2,以及为什么。是否有这些风格的名称?

风格1:

方法{

}


这通常被称为K& R支撑。 (Kernighan和Ritchie)。

就个人而言,我无法忍受。

风格2:

方法
{

}
I am curious about how many of you prefer style 1 vs. style 2, and why. Are
there names for these style?

style 1:

method {

}
This is usually called "K&R bracing" (Kernighan and Ritchie).
Personally I can''t stand it.
style 2:

method
{

}




这就是我一直用的东西。它被称为Allman风格,我相信

它使事情比K& R更清晰。


http://www.science.uva.nl/~mes/jargo .. .dentstyle.html 了解更多

信息。另一方面,我认为在
倒数第二段中它实际上是错误的,它声称大多数Java程序员使用

K& R - 我会说最多使用奥尔曼。


-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet/

如果回复对于小组,请不要给我发邮件



This is what I always use. It''s called the Allman style, and I believe
it makes things much clearer than K&R.

See http://www.science.uva.nl/~mes/jargo...dentstyle.html for more
information. On the other hand, I believe it''s actually wrong in the
penultimate paragraph, where it claims that most Java programmers use
K&R - I would say most use Allman.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too


这篇关于首选编码风格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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