東方算程譚

Oriental Code Talk ── επιστημηが与太をこく、弾幕とは無縁のシロモノ。

目次

Blog 利用状況

ニュース

著作とお薦めの品々は

著作とお薦めの品々は
東方熱帯林へ。

あわせて読みたい

わんくま

  1. 東京勉強会#2
    C++/CLI カクテル・レシピ
  2. 東京勉強会#3
    template vs. generics
  3. 大阪勉強会#6
    C++むかしばなし
  4. 東京勉強会#7
    C++むかしばなし
  5. 東京勉強会#8
    STL/CLRによるGeneric Programming
  6. TechEd 2007 @YOKOHAMA
    C++・C++/CLI・C# 適材適所
  7. 東京勉強会#14
    Making of BOF
  8. 東京勉強会#15
    状態遷移
  9. 名古屋勉強会#2
    WinUnit - お気楽お手軽UnitTest

CodeZine

  1. Cで実現する「ぷちオブジェクト指向」
  2. CUnitによるテスト駆動開発
  3. SQLiteで組み込みDB体験(2007年版)
  4. C++/CLIによるCライブラリの.NET化
  5. C# 1.1からC# 3.0まで~言語仕様の進化
  6. BoostでC++0xのライブラリ「TR1」を先取りしよう (1)
  7. BoostでC++0xのライブラリ「TR1」を先取りしよう (2)
  8. BoostでC++0xのライブラリ「TR1」を先取りしよう (3)
  9. BoostでC++0xのライブラリ「TR1」を先取りしよう (4)
  10. BoostでC++0xのライブラリ「TR1」を先取りしよう (5)
  11. C/C++に対応した、もうひとつのUnitTestFramework ─ WinUnit
  12. SQLiteで"おこづかいちょう"
  13. STL/CLRツアーガイド
  14. マージ・ソート : 巨大データのソート法
  15. ヒープソートのアルゴリズム
  16. C++0xの新機能「ラムダ式」を次期Visual Studioでいち早く試す
  17. .NETでマンデルブロ集合を描く
  18. .NETでマンデルブロ集合を描く(後日談)
  19. C++/CLI : とある文字列の相互変換(コンバージョン)
  20. インテルTBBによる選択ソートの高速化
  21. インテルTBB3.0 によるパイプライン処理
  22. Visual C++ 2010に追加されたSTLアルゴリズム
  23. Visual C++ 2010に追加されたSTLコンテナ「forward_list」
  24. shared_ptrによるObserverパターンの実装
  25. .NETでマンデルブロ集合を描く(番外編) ── OpenCLで超並列コンピューティング
  26. StateパターンでCSVを読む
  27. 状態遷移表からStateパターンを自動生成する
  28. 「ソートも、サーチも、あるんだよ」~標準C++ライブラリにみるアルゴリズムの面白さ
  29. インテルTBBの同期メカニズム
  30. なぜsetを使っちゃいけないの?
  31. WPFアプリケーションで腕試し ~C++でもWPFアプリを
  32. C++11 : スレッド・ライブラリひとめぐり
  33. Google製のC++ Unit Test Framework「Google Test」を使ってみる
  34. メールでデータベースを更新するココロミ
  35. Visitorパターンで遊んでみたよ
  36. Collection 2題:「WPFにバインドできる辞書」と「重複を許す検索set」
  37. Visual C++ 2012:stateless-lambdaとSQLiteのぷち拡張
  38. 「Visual C++ Compiler November 2012 CTP」で追加された6つの新機能

@IT

  1. Vista時代のVisual C++の流儀(前編)Vista到来。既存C/C++資産の.NET化を始めよう!
  2. Vista時代のVisual C++の流儀(中編)MFCから.NETへの実践的移行計画
  3. Vista時代のVisual C++の流儀(後編) STL/CLRによるDocument/Viewアーキテクチャ
  4. C++開発者のための単体テスト入門 第1回 C++開発者の皆さん。テスト、ちゃんとしていますか?
  5. C++開発者のための単体テスト入門 第2回 C++アプリケーションの効率的なテスト手法(CppUnit編)
  6. C++開発者のための単体テスト入門 第3回 C++アプリケーションの効率的なテスト手法(NUnit編)

AWARDS


Microsoft MVP
for Visual Developer - Visual C++


Wankuma MVP
for いぢわる C++


Nyantora MVP
for こくまろ中国茶

Xbox

Links

記事カテゴリ

書庫

日記カテゴリ

げったーせったー

プロパティね。VB/C#はともかく、C++にはそんなもんないの。
しょせんsyntax-sugarに過ぎんのだけれども。

で、値の読み書きメソッドの命名法、みなさんどぉすんのかな?

class ParsonPerson {
private:
  int age_;
public:
  // [壱式]
  int getAge() const { return age_; }
  void setAge(int value) { age_ = value; }
  // [弐式]
  int Age() const { return age_; }
  void Age(int value) { age_ = value; }
  // [参式]
  int Age() const { return age_; }
  void setAge(int value) { age_ = value; }
  // [四式]
  int Age() const { return age_; }
  int& Age() { return age_; }
};

壱: まぁフツー。Javaはこの流儀かな。
弐: 引数の有無でset/getを切り替える式。
参: setterにだけ"set"を付ける式。対称性がなくてキモい。
  getterに比べsetterの呼びだし頻度は小さいだろうし、
  わざと違和感を与えることで"setしてっぞ!"てことを喚起させる。
四:インスタンスがconstならgetter, non-constならgetter/setterとなる。
  かなり危険と言わざるを得ないけどもっともプロパティっぽいといえなくもなくもなくも。

...僕ですか? 意外にも[参式]が気に入ってます。
ウケが宜しくないので渋々[壱式]使うことが多いけれども。

投稿日時 : 2007年12月19日 9:40

コメントを追加

# re: げったーせったー 2007/12/19 9:49 囚人

[五式]
private:
int age_;



public:
int Age;

ぐわははは。

# re: げったーせったー 2007/12/19 9:55 通りすがり

多分ParsonじゃなくてPersonだと思うけど、Personに年を持たせたとしても、Personならイミュータブルオブジェクトにするかな。ケースバイケースだけど。
それか、setterじゃなくてincAgeとかもっと高レベルなAPIを用意すると思う。

# re: げったーせったー 2007/12/19 9:58 774RR

データベースに age を保持しちゃダメと教わったです

# re: げったーせったー 2007/12/19 9:59 επιστημη

> 多分ParsonじゃなくてPersonだと思うけど
はづかちー

てゆっかあたしゃ"名前付け"の話しかしてねーんだってば。

# re: げったーせったー 2007/12/19 10:05 凪瀬

setもしくはgetの接頭辞がついていない場合、名詞か動詞かでsetter,getterなのか関数なのかを区別することになりますよね?
そのへんがなんとなく気持ち悪く感じてしまう。
別にドキュメントに明記されていればいいんだけど、
ドキュメントでフォローというのがうまく運用できるかという別の話題が…

# re: げったーせったー 2007/12/19 10:20 επιστημη

> setもしくはgetの接頭辞がついていない場合、名詞か動詞かでsetter,getterなのか関数なのかを区別することになりますよね?

ですよねー。
あるいはたとえば"empty" には"空の(形容詞)"と"空にする(動詞)"の両方の意味があって、getterだかsetterだかわかりゃしねぇ。
# なので[弐式],[四式]は避けてます

# re: げったーせったー 2007/12/19 10:34 囚人

C++ にあるか知らんのですけど、「set~」「get~」という命名規則が前提のフレームワークとかありますよね(特に Java)。この命名ルールを使っていないライブラリが「ホゲホゲフレームワークに使えねぇっ」って心配がなきにしもあらず。

# re: げったーせったー 2007/12/19 10:38 επιστημη

リフレクションでメソッド名引っこ抜いて
ごにょごにょする奴だとそぉですよねー

# re: げったーせったー 2007/12/19 10:44 渋木宏明(ひどり)

VC++ にはあるますよね>プロパティ

# re: げったーせったー 2007/12/19 10:50 επιστημη

あるますねー。VC++6の頃からだっけ。
# そらVC++であってC++ぢゃねーし。

# re: げったーせったー 2007/12/19 10:50 Chuki

人にかかすとき壱式、自分で書くとき弐式。VBからのクセですな。
あ、C#とかじゃなくて、C++書くときですか? 壱式です。理由は...「そう教わったから^^;」。我ながら、なんというゆとり。
#でも、COM書くときは、やっぱり弐式^^;

理由は、私がVBから小文字のgetとsetが見えると虫唾の走る体質だからです(オィ。
#プロパティは変数みたいに扱えないとヤだ。

# re: げったーせったー 2007/12/19 11:18 通りすがり

C++だったら
class person
{
struct impl;
boost::shared_ptr<impl> pimpl;
public:
int age() const;
void set_age(int);
};

ですかね。参式+Pimpl的な。

# re: げったーせったー 2007/12/19 11:45 シャノン

__declspec( property ).

大嫌い。

# re: げったーせったー 2007/12/19 12:10 とっちゃん

おいらは、壱式派。
ちなみに、COM(というより、IDispatch)の推奨?ルールでは、
getAge() ではなくて、get_Age()
setAge() ではなくて、put_Age()
です。
使ってねーですけどねw

__declspec( property ) は場所によっては使います...
けど、条件式に使うと判断間違うんだよね...orz
#今はどうなんだろ?

# re: げったーせったー 2007/12/19 13:18 がる

は~い。名付けとしては…

変数の後ろにアンスコは好み
メソッド名は蛇(get_age)のほうが好み
です。

以上純粋に個人的な発言でした(笑

# re: げったーせったー 2007/12/19 13:37 επιστημη

メンバ変数のケツにアンスコは僕の昔からのクセ。
ptr_->f() とか tbl_[n] なんかが
文字通り"間抜け"なのがァレですが ^^;

# re: げったーせったー 2007/12/19 14:01 まつあに

επιさん、昔、DDJ(なつかすい)の記事で
property 用のtemplateクラス書いてなかったっけ?
operator=(const T&)とoperator const& T()なやつ。

# re: げったーせったー 2007/12/19 14:17 επιστημη

書いてますよ、日本海がまだ湖だった頃ですねー

# re: げったーせったー 2007/12/19 15:25 ゆーち

あちきは、BCBなので(w

相変わらず下駄、雪駄って言ってます。

# re: げったーせったー 2007/12/19 17:06 えムナウ

C#でもありますよ。
壱式

詳しくは12/22勉強会にて。

# re: げったーせったー 2007/12/20 17:23 babydaemons

微妙に遠い昔の学生時代は、研究テーマが画像処理だったので、四式でした。

最近はめっきりC++で書かなくなりましたねー
Win32だとC++で書くのはカラダに毒な気がしますw
unixでgccで作るのは楽しいのになー。

# Thanks for another great article. Where else may anybody get that kind of information in such an ideal means of writing? I have a presentation subsequent week, and I'm at the search for such information. 2021/08/31 18:50 Thanks for another great article. Where else may

Thanks for another great article. Where else may anybody get
that kind of information in such an ideal means of writing?
I have a presentation subsequent week, and I'm at the search for such information.

# Thanks for another great article. Where else may anybody get that kind of information in such an ideal means of writing? I have a presentation subsequent week, and I'm at the search for such information. 2021/08/31 18:51 Thanks for another great article. Where else may

Thanks for another great article. Where else may anybody get
that kind of information in such an ideal means of writing?
I have a presentation subsequent week, and I'm at the search for such information.

# Thanks for another great article. Where else may anybody get that kind of information in such an ideal means of writing? I have a presentation subsequent week, and I'm at the search for such information. 2021/08/31 18:52 Thanks for another great article. Where else may

Thanks for another great article. Where else may anybody get
that kind of information in such an ideal means of writing?
I have a presentation subsequent week, and I'm at the search for such information.

# Thanks for another great article. Where else may anybody get that kind of information in such an ideal means of writing? I have a presentation subsequent week, and I'm at the search for such information. 2021/08/31 18:53 Thanks for another great article. Where else may

Thanks for another great article. Where else may anybody get
that kind of information in such an ideal means of writing?
I have a presentation subsequent week, and I'm at the search for such information.

# My developer is trying to persuade me to move to .net from PHP. I have always disliked the idea because of the costs. But he's tryiong none the less. I've been using Movable-type on several websites for about a year and am nervous about switching to ano 2021/09/03 13:41 My developer is trying to persuade me to move to

My developer is trying to persuade me to move to .net from PHP.
I have always disliked the idea because of the costs.
But he's tryiong none the less. I've been using Movable-type on several websites for about a year
and am nervous about switching to another platform.
I have heard excellent things about blogengine.net. Is there a way I can transfer all my wordpress content into it?
Any help would be really appreciated!

# No matter if some one searches for his essential thing, therefore he/she wishes to be available that in detail, thus that thing is maintained over here. 2021/09/04 15:46 No matter if some one searches for his essential t

No matter if some one searches for his essential thing, therefore he/she wishes to be available
that in detail, thus that thing is maintained over here.

# Awesome blog! Do you have any tips and hints for aspiring writers? I'm planning to start my own website soon but I'm a little lost on everything. Would you advise starting with a free platform like Wordpress or go for a paid option? There are so many opt 2021/11/14 7:31 Awesome blog! Do you have any tips and hints for a

Awesome blog! Do you have any tips and hints for aspiring writers?
I'm planning to start my own website soon but I'm a little lost
on everything. Would you advise starting with a free platform like Wordpress or go for a paid option?
There are so many options out there that I'm completely overwhelmed
.. Any ideas? Thanks a lot!

# Awesome blog! Do you have any tips and hints for aspiring writers? I'm planning to start my own website soon but I'm a little lost on everything. Would you advise starting with a free platform like Wordpress or go for a paid option? There are so many opt 2021/11/14 7:32 Awesome blog! Do you have any tips and hints for a

Awesome blog! Do you have any tips and hints for aspiring writers?
I'm planning to start my own website soon but I'm a little lost
on everything. Would you advise starting with a free platform like Wordpress or go for a paid option?
There are so many options out there that I'm completely overwhelmed
.. Any ideas? Thanks a lot!

# Awesome blog! Do you have any tips and hints for aspiring writers? I'm planning to start my own website soon but I'm a little lost on everything. Would you advise starting with a free platform like Wordpress or go for a paid option? There are so many opt 2021/11/14 7:33 Awesome blog! Do you have any tips and hints for a

Awesome blog! Do you have any tips and hints for aspiring writers?
I'm planning to start my own website soon but I'm a little lost
on everything. Would you advise starting with a free platform like Wordpress or go for a paid option?
There are so many options out there that I'm completely overwhelmed
.. Any ideas? Thanks a lot!

# Awesome blog! Do you have any tips and hints for aspiring writers? I'm planning to start my own website soon but I'm a little lost on everything. Would you advise starting with a free platform like Wordpress or go for a paid option? There are so many opt 2021/11/14 7:34 Awesome blog! Do you have any tips and hints for a

Awesome blog! Do you have any tips and hints for aspiring writers?
I'm planning to start my own website soon but I'm a little lost
on everything. Would you advise starting with a free platform like Wordpress or go for a paid option?
There are so many options out there that I'm completely overwhelmed
.. Any ideas? Thanks a lot!

タイトル
名前
URL
コメント