Ognacの雑感

木漏れ日々

目次

Blog 利用状況

書庫

ギャラリ

isError()の戻り値

英語では yes, I Do / NO, I Do'nt   はあるが  No, I do  とは言わないと聞きます。DoならYes、Don't  は No  と考えるそうです。(自分が行う動詞に対しての、Yes/NOですね。聞きかじりですが。)
日本語は、質問に対する はい/いいえです。
  Q:  これはペンではありませんね?
  A:  はい、ペンではありません。
何の話しだと言われそうなのですが、 isError()  のメソッドの戻り値に説明が必要になったのです。
 isError() や hasError() はエラーがあるか? と聞いているので、Errorがあれば  Trueを戻すのだ自然だと考えました。
 ところが、doCheckルーチンは、エラーがあるときは False を戻すのを自然とする文化もあります。
その人たちにとっては、 isError()であってもエラーあれば、Falseを戻すべきで、ErrorがあるのにTrueを戻すと誤読やバグの元になると指摘がありました。
この場合、doCheck() というメソッド名が問題だと思います。メソッド名からは、 エラーのときTrueなのかFalseなのかは仕様書かソースをみないと判断できません。isError(),hasError() のメソッドだと、Errorが在ればTrue なので読みやすいと考えてます。Excelの isError()もそうだったと思います。
 しかし、文化が違うと、逆に受け取られる方もいらっしゃるので,広く理解が得られるソースって書けないものですね。

投稿日時 : 2008年6月11日 0:39

Feedback

# re: isError()の戻り値 2008/06/11 1:19 やじゅ

isDeleteって関数を作った時に同じく
True/Falseをどちらにするかで悩んだことを
思い出しました。
isErrorと同じなんだから 
削除可能:True / 削除不可:False
って事にしました。
なら、canDeleteにすれば良かったかも

# re: isError()の戻り値 2008/06/11 1:47 OtanC

>なら、canDeleteにすれば良かったかも
私の場合は isDeletable()かなぁ。

でも、isError()が真でFalseを返すっちゅうのは<strong>「悪」</strong>だと思います。
Ognacさんは間違っていません。

# re: isError()の戻り値 2008/06/11 5:12 Katsu

"Yes、Noについては日本語と英語は考え方が確かに逆ですね。
You don't like wankuma?(わんくま好きじゃないの?)
って否定形で聞かれたら、日本人的には
No. I like wankuma.(いえいえ。わんくま好きだよ)
って答えちゃいますが、間違いで
Yes. I like wankuma.か
No. I don't like wankuma.
が正しい答えですね

あと英会話でよく出るFAQで、
Do you mind if I smoke?(タバコ吸ってもいい?)
の返答は、
Yesは「タバコ吸っちゃダメ~~」で
Noは「いいよ~」になりますね。
でもCan I smoke?(タバコ吸ってもいい?)の場合は
Yesは「いいよ~」
Noは「吸っちゃダメ~」となり、YES/NOの意味が逆になります。

ExcelのISERRORは試してみたらエラーありはTrueが返ってきました。
戻り値のTrue、Falseの感覚って確かに人によって違ったりしますね。
僕も「どっちだ?」って悩む事がしばしば・・・。"

# re: isError()の戻り値 2008/06/11 9:51 επιστημη

isError が false でエラーとすると、その裏返しの
isOK も false でエラーてことね。

isError が false でエラーとすると、その裏返しの
notError は true でエラーてことね。

サブイボ立つんですけどー

# re: isError()の戻り値 2008/06/11 13:12 trapemiya

英語は整然としている気がしますが、日本語はあいまいですね。そこが文化であり、良い面もあるんでしょうが。
有名な話。
「わたしはうなぎです。」
「わたしもうなぎです。」
これだけ読むと変なんだけど、この状況が食事の注文を取っている場面だと不思議じゃないんですよね。

# re: isError()の戻り値 2008/06/11 14:18 シャノン

「メソッド名が何であれ、エラーは false」なんでしょうね。
だったら isError() とかじゃなくて func00246() でもいいよね、って話になっちゃう。
それでもいいような人が主張するんでしょうね。

> 英会話でよく出るFAQ

「Do you mind if I smoke?」は直訳では「煙草吸ってもいい?」っていうより「煙草吸ったら気にする(mind)?」なので、「Yes」が「ダメ」なのはわかりやすいと思います。
「Can I smoke?」は直訳でも「煙草吸っていい?」ですね。

# re: isError()の戻り値 2008/06/11 17:49 ognac

コメントありがとうございます。
みなさま一様に違和感を持たれるようで、安心しました。
isOK() で 考えれば、おかしさに気付きますね。
自然語は、語句だけの解釈でなく、文脈からの解釈が重要になります。
日本語特有ではなく英語も他も慣用句は、塊で違う意味になるので50歩100歩の気がします。
犬と猫が振る......大雨。
turn on ......点灯....言葉は文化という所以でしょうか.
しかし,表題の isError でErrorありをTrueにする.....も文化になりうるようですよ...orz(^^!汗

# re: isError()の戻り値 2008/06/11 22:14 Pasie.

 個人的にはメソッド名がまずいと思います。>IsError()
 基本的に私はisError()ならばTrueでエラー判定を支持しますが、エラーの戻りはFalseだと言うならば、メソッド名の方をIsNormal()あたりに変えさせますね。私がレビュアならIsError() = false でエラー判定は絶対に許さない。
 もう少し踏み込むと、IsError()にしろIsNormal()にしろ名前の付け方が曖昧だと思います。もうすこし判定内容のわかる名前にしたいですね。
 しかしこのあたりは、好みというか文化というか宗教というか…なんで、不毛な論戦になることが多いです。_| ̄|○

 とりあえず今回のことでIsError()ってメソッド名は禁止することにします。あるひとはエラーでTrue、あるひとはFalse、とかされる可能性があるってことなんで。あるクラスのIsError()はTrueでエラー、あるクラスのIsError()はFalseでエラー… ああ恐ろしい (>_<;

# re: isError()の戻り値 2008/06/12 0:31 Ognac

>個人的にはメソッド名がまずいと思います
その人たちは, isCheck()を用いてました。Errorありはtrueでした。
 私は、ErrorなしでTrueであっても違和感が薄いので、isCheck()という名前は抵抗感がありました。

>メソッド名は禁止することにします
う! そこまで!
isError()でTrueを「なし」と認識するのは、ごく一部の人...というのは共通認識と思うのです。
ごく一部の人を考慮して、禁止するのは.....うーん、例外を無くすのが原則だから、正論なのですが、行き過ぎ感もするし、悩ましいところですね、 isError()やisOK() は気楽に使えそうな名前だけに汎用化で....混乱してきた...禁止はできないですぅ。

# re: isError()の戻り値 2008/06/12 0:47 Pasie.

 いやあ、混乱する、その一点をもってメソッド名としてはだめなのかなと。IsError()だけでなく、"Is否定"はすべて。例えばIsFail()とかIsAbort()とかも。
 とりあえず、ここの話だけだと"Is肯定"にしておけば、両者の主張を通すことができるし、混乱も少ないかなと思ったわけです。
 ただ、IsCheck()はどうなのかな。戻り値の論理以前にやりたい内容が分からない。もっと具体的なメソッド名にしてください。たとえばIsNotIncludeHankakuKana()とかなら許容します。とか言いそうです。
 そしてまた喧嘩に…(泣

 話は変わりますが、私は、If (obj.IsError() = True) Then、と左辺に論理を書く派なんですが、皆さんはどうなんでしょ。主流は書かないんだと思うけど。

# re: isError()の戻り値 2008/06/12 1:29 Ognac

isCheck()...True/Falseの定義は仕様書参照必須という条件下でOKかと。
しかし、Checkは動作なのて doCheck()が妥当かとも思います。doCheck()だと戻り値は、仕様確認するだろうし。


>If (obj.IsError() = True) Then、と左辺に論理を書く派なんですが、
私もそうです。 C/C++ の作法の本などで、間違い防止策として
if(true == xxx()) や if(3 == xxx()) が推奨されたりしてますが、どうも違和感があって、使う気になりません。
それより、C文化のせいかも知れませんが ==TRUE は冗長と感じて if(xx()==TRUE) は if(xx()) と記述しますね。
 「if(xx==true) とするほうが良い」との主張も納得はできますが、使えませんねぇ...これも文化の差でしょうか。

# re: isError()の戻り値 2008/06/12 23:08 Pasie.

if(xx())、は一時期使ってましたが、否定論理の時に困るんですよね。!つければいいじゃんというのは確かにそうなんですが、Not(xx())よりは、xx()がFalse、のほうが気持ちいいというか…。
あとNot()をつけたくない一心で戻り値の論理を呼び出し元のif文に合わせたくなる衝動に駆られたというか、そんな経験もあって必ず比較演算子はつけることにしています。

しかし仕様書参照必須にすると、enum使わずマジックナンバーとか、func00246() でもいいよね、とかにもなりそうなので出来る限り許容したくないなあ。(番号管理はそれはそれで甘美な利点もあるんで。欠点が大きいから使いたくないだけで)コードは出来る限りコードだけで勝負できるようにしておきたいです。

# re: isError()の戻り値 2008/06/13 1:44 Ognac

doCheck()の戻り値を 列挙体にして
enum doCheck_Judge
OK
NG
end enum
とすると、ソースの世界で完結....これは OK!

isError() の戻り値もこれにすると
if( isError()== OK) { xxxx } となる.. xxxxx は 正常処理なのか、エラー処理なのか、判別できない......悩ましいことになってきた..... isError() は Trueがエラー在り...というのが納得できるのだが...(^^!

# BTFFAvLIoqnsx 2012/01/07 13:22 http://www.luckyvitamin.com/p-110235-dynamic-healt

Left on my site a link to this post. I think many people will be interested in it..!

# These are in fact fantastic ideas in on the topic of blogging. You have touched some fastidious factors here. Any way keep up wrinting. 2019/04/09 14:49 These are in fact fantastic ideas in on the topic

These are in fact fantastic ideas in on the topic of blogging.
You have touched some fastidious factors here.
Any way keep up wrinting.

# Fastidious response in return of this question with firm arguments and telling everything regarding that. 2019/05/11 12:53 Fastidious response in return of this question wit

Fastidious response in return of this question with firm arguments and telling everything regarding that.

# Hi there! Someone in my Facebook group shared this website with us so I came to give it a look. I'm definitely loving the information. I'm bookmarking and will be tweeting this to my followers! Outstanding blog and terrific design. 2019/05/12 15:01 Hi there! Someone in my Facebook group shared this

Hi there! Someone in my Facebook group shared this website
with us so I came to give it a look. I'm definitely loving the information.
I'm bookmarking and will be tweeting this to my followers! Outstanding blog and terrific design.

# Heya i am for the first time here. I found this board and I find It truly useful & it helped me out much. I hope to give something back and help others like you aided me. 2019/05/18 12:24 Heya i am for the first time here. I found this b

Heya i am for the first time here. I found this board and I find
It truly useful & it helped me out much. I hope to give something back and help others like you aided me.

# Ahaa, its good dialogue concerning this post at this place at this web site, I have read all that, so now me also commenting at this place. 2019/06/12 13:54 Ahaa, its good dialogue concerning this post at th

Ahaa, its good dialogue concerning this post at this place at this web site,
I have read all that, so now me also commenting at this
place.

# I am in fact thankful to the holder of this website who has shared this great article at at this place. 2025/05/04 23:12 I am in fact thankful to the holder of this websit

I am in fact thankful to the holder of this website who has shared this great article at at this place.

# We are a group of volunteers and opening a new scheme in our community. Your web site provided us with valuable info to work on. You've done a formidable job and our entire community will be thankful to you. 2025/06/28 6:23 We are a group of volunteers and opening a new sc

We are a group of volunteers and opening a new scheme in our community.
Your web site provided us with valuable info to work on. You've done a formidable job and our entire
community will be thankful to you.

# We are a group of volunteers and opening a new scheme in our community. Your web site provided us with valuable info to work on. You've done a formidable job and our entire community will be thankful to you. 2025/06/28 6:23 We are a group of volunteers and opening a new sc

We are a group of volunteers and opening a new scheme in our community.
Your web site provided us with valuable info to work on. You've done a formidable job and our entire
community will be thankful to you.

# When some one searches for his necessary thing, thus he/she needs to be available that in detail, thus that thing is maintained over here. 2025/08/07 4:51 When some one searches for his necessary thing, th

When some one searches for his necessary thing, thus he/she needs to be available that
in detail, thus that thing is maintained over here.

# I've been exploring for a bit for any high quality articles or blog posts on this kind of house . Exploring in Yahoo I finally stumbled upon this web site. Reading this info So i am glad to show that I have an incredibly good uncanny feeling I discovere 2025/09/17 14:35 I've been exploring for a bit for any high qualit

I've been exploring for a bit for any high quality articles
or blog posts on this kind of house . Exploring in Yahoo I finally stumbled upon this web site.

Reading this info So i am glad to show that I have an incredibly good uncanny feeling I discovered just what I needed.

I such a lot no doubt will make certain to
do not put out of your mind this web site and provides it a glance regularly.
Eharmony special coupon code 2025 https://tinyurl.com/ypubsnjg

タイトル
名前
Url
コメント