作者popcorny (毕业了..@@")
看板AndroidDev
标题Re: [问题] 程式撰写的括弧
时间Fri May 10 23:52:17 2013
※ 引述《Nestarneal (Nestarneal)》之铭言:
: 最近在学习 Android 程式撰写,突然想到一个问题。
: 比方说刚建立好专案的 onCreate() function,
: 或是看范例程式码中人家撰写的 Code,
: 我都发现到括弧都是这样撰写的:
: void functionName(){
: }
: 也就是左大括弧会跟在参数後方。
: 而我自己的习惯是写成这样:
: void functionName()
: {
: }
: 以前都没特别去想,可是突然就很好奇,
: 为什麽范例的 Code 都是以前者的方式来撰写呢?
: 我是觉得只差在前者会少一行,但後者我觉得会比较好读...?
: 想请教一下前辈们的意见,谢谢。
每个语言都有coding conventions
java的可以参考这里
http://goo.gl/VNDCi
里面有提到
7.2 Compound Statements
The opening brace should be at the end of the line that begins the
compound statement; the closing brace should begin a line and be
indented to the beginning of the compound statement.
你去看java standard library的source code应该也是follow这个rule..
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.137.70.121
1F:推 Nestarneal:了解,感谢各位的解答 :) 05/11 00:00