[Groonga-mysql-commit] mroonga/mroonga [master] doc coding-style: add about naming rule for writer

Back to archive index

null+****@clear***** null+****@clear*****
2012年 3月 15日 (木) 15:59:09 JST


Kouhei Sutou	2012-03-15 15:59:09 +0900 (Thu, 15 Mar 2012)

  New Revision: bdc052afb360360b173d9ac509cdc811bc55b891

  Log:
    doc coding-style: add about naming rule for writer

  Modified files:
    doc/source/developer/coding_style.rst

  Modified: doc/source/developer/coding_style.rst (+38 -0)
===================================================================
--- doc/source/developer/coding_style.rst    2012-03-15 15:49:04 +0900 (e2eb159)
+++ doc/source/developer/coding_style.rst    2012-03-15 15:59:09 +0900 (f85d1d8)
@@ -226,3 +226,41 @@ TODO: ちゃんと考える。
       const char *_my_name() {return my_name_;};
     }
 
+書き込み用アクセサ名
+^^^^^^^^^^^^^^^^^^^^
+
+メンバー変数の値を設定するメソッドの名前は、メンバー変数名の末尾のアンダースコアを除き、先頭に ``set_`` を加えたものにする。
+
+よい例:
+
+    class MyClass
+    {
+      unsigned int age_;
+      void set_age(unsigned int age)
+      {
+        age_ = age;
+      };
+    }
+
+悪い例(末尾にアンダースコアが残っている):
+
+    class MyClass
+    {
+      unsigned int age_;
+      void set_age_(unsigned int age)
+      {
+        age_ = age;
+      };
+    }
+
+悪い例(先頭に ``set_`` ではなく ``update_`` を付けている):
+
+    class MyClass
+    {
+      unsigned int age_;
+      void update_age(unsigned int age)
+      {
+        age_ = age;
+      };
+    }
+




Groonga-mysql-commit メーリングリストの案内
Back to archive index