Re: [問題] 程式撰寫的括弧

看板AndroidDev作者 (畢業了..@@")時間12年前 (2013/05/10 23:52), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/3 (看更多)
※ 引述《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

05/11 00:00, , 1F
了解,感謝各位的解答 :)
05/11 00:00, 1F
文章代碼(AID): #1HZHUqjg (AndroidDev)
文章代碼(AID): #1HZHUqjg (AndroidDev)