我正在通過一本關於面向對象的PHP的書,並且注意到作者在某些情況下使用了複雜的語法。在繼承他用下面的代碼的章節: // Declare the getSummaryLine() method
function getSummaryLine() {
// Define what the getSummaryLine() method does
$base = "$this->title
Java編程語言中是否接受過使用簡短解釋大括號關閉代碼塊的註釋來結束代碼塊大括號的做法?我個人會認爲這些代碼是無用的評論,這些評論混淆了代碼的可讀性,但也許我可能是錯的。例如: public void myMethod(int foo) {
// some code
if (foo == 2) {
for (int i = 0; i < myMax; i++) {
比方說,我有下面的代碼塊: int version;
String content;
synchronized (foo) {
version = foo.getVersion();
content = foo.getContent();
}
// Do something with version and content
其目的是抓住了一些對象foo的版本和內容的