注釋
- 生澀的代碼就 沒有必要 添加注釋了,首先您需要 重寫 它們。
- 所有的注釋請(qǐng)使用英文。
- 從已解決的方案到未開發(fā)的功能,注釋 必須 與代碼相關(guān)。
- 大量的變量申明后 必須 跟隨一段注釋。
- 注釋需要說明的是代碼段的用處,尤其是接下來的代碼段。
- 注釋 沒有必要 每行都添加。
文檔
下面提供了一些基本的函數(shù)或者對(duì)象的描述方法:
- 總結(jié)(summary): 簡(jiǎn)短的表述此函數(shù)或者對(duì)象實(shí)現(xiàn)的目的
- 描述(description): 對(duì)于此函數(shù)或者類的簡(jiǎn)短的描述
- 返回(return): 描述此函數(shù)返回什么(并不包括返回類型)
基本函數(shù)信息
function(){ // summary: Soon we will have enough treasure to rule all of New Jersey. // description: Or we could just get a new roomate. // Look, you go find him. He don't yell at you. // All I ever try to do is make him smile and sing around // him and dance around him and he just lays into me. // He told me to get in the freezer 'cause there was a carnival in there. // returns: Look, a Bananarama tape! }
對(duì)象函數(shù)信息
沒有返回值描述
{ // summary: Dingle, engage the rainbow machine! // description: // Tell you what, I wish I was--oh my g--that beam, // coming up like that, the speed, you might wanna adjust that. // It really did a number on my back, there. I mean, and I don't // wanna say whiplash, just yet, cause that's a little too far, // but, you're insured, right? }
函數(shù)的聲明
在有的情況下,對(duì)于函數(shù)的調(diào)用和聲明是隱義(invisible)的。在這種情況下,我們沒有辦法在函數(shù)中加入說明等(供程序調(diào)用)。如果您遭遇了這種情況,您可以使用一個(gè)類來封裝函數(shù)。
注:此此方法只能在函數(shù)沒有初始化的參數(shù)情況下。如過不是,則它們會(huì)被忽略。
dojo.declare( "foo", null, { // summary: Phew, this sure is relaxing, Frylock. // description: // Thousands of years ago, before the dawn of // man as we knew him, there was Sir Santa of Claus: an // ape-like creature making crude and pointless toys out // of dino-bones, hurling them at chimp-like creatures with // crinkled hands regardless of how they behaved the // previous year. // returns: Unless Carl pays tribute to the Elfin Elders in space. } );
出處:藍(lán)色理想
責(zé)任編輯:moby
上一頁 Dojo Javascript 編程規(guī)范 [3] 下一頁 Dojo Javascript 編程規(guī)范 [5]
◎進(jìn)入論壇網(wǎng)絡(luò)編程版塊參加討論
|