0

まず、私はこの質問に気付いています: Are there standard formats for comments within code?良いコード形式は何ですか?

しかし、私は答えませんでした。私がコードを書くときはいつでも、私はいつもコメントが一貫していることを保証する習慣を形作ろうとしますが、それは私のコードフォーマットの規約について決して曖昧なところです。私のコードは80行程度にしたいので特にそうです。言うまでもなく

は、コード形式の規則は次のようになります。

  • 簡単
  • 簡単に読み取ることが

を変更すると、コードのさまざまな部分で異なるコメント形式があるかもしれません、一貫性と可読性を確保することが重要です。ここで

はいくつかの例です:

シングルライン

// simple comment in lowercase 
do_something(); 

// longer comment in lowercase. but now it doesn't seem like a proper sentence. 
do_something(); 

// Longer comment in sentence case. But should we use sentence case for short comments too? 
do_something(); 
// Like this one? 
do_something_else(); // Or even this one. 

マルチライン

// This code is very detailed and so I must continue further. 
// Every time you start a new line you need to ensure you add //. 
// If you finish your comment and forget to add something, you're screwed. 
// You'll have to add your something and then make sure all the lines are 80 characters or less, 
// and if they aren't you need to restructure all the lines below it. 

/* This is better but you need to make sure it's properly indented each line. 
    Although you have to worry about those comment delimiters getting in the way. 
    At least it's compact. */ 

/* This comment seems better. 
    No need to worry about that last delimiter being inside your comment block. 
*/ 

/* 
    Or maybe this is better? 
    At least it looks clean. 
*/ 

/* GOOD FOR FUNCTION DEFINITIONS 
    Or maybe this is even better? 
    Who knows? 
*/ 

答えて

1

回答1 - ない、かっこについてargueing無駄な任意の時間があります時間の無駄。

回答2 - 必要がある場合は、ただ1つを選択してください。 http://www.possibility.com/Cpp/CppCodingStandard.html

+0

IMO、ただ投票して終了してください。 –

+0

リンクありがとう –

関連する問題