0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

naming | API > 考察 > { StringReplace() | IncSecond() } | { SecondsBetween() | SecondSpan() } > まぎらわしい

Last updated at Posted at 2016-01-11

StringReplace()とIncSecond()

C++ BuilderでStringReplace()をいつもReplaceString()と思ってしまう。

IncSecond()という関数があり、こちらは[動詞]+[名詞]の組み合わせ
一方で、StringReplace()は[名詞]+[動詞]の組み合わせ。

本当はReplaceString()という関数名が望ましい。

SecondsBetween()とSecondSpan()

この2つは

  • 片方は複数形 > SecondsBetween()
  • もう一方は単数形 > SecondSpan()

入力補完があるので何とかなるが、紛らわしい。

また、上記は[名詞]始まり。[動詞]始まりの関数と異なる命名規則。

関数名の考察

自分が実装を進めるものについては上記のようにならないようにルールをきちんとしておくことが望ましい。

APIは特に使い始めると容易に変更できない(ラッパーを作るのも可能だが)ので、きちんとした設計は重要。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?