English 中文(简体)
在GetCountOfObjects、GetNumberOfObjects和GetObjectCount,哪些是最好的?
原标题:Which is the best among GetCountOfObjects, GetNumberOfObjects, and GetObjectCount?

我是来自非英语国家的C++方案管理员。 我总是对如何选择以下职务之一感到困惑:

GetCountOfObjects

GetNumberOfObjects

GetObjectCount

谁能告诉我他们之间的微妙差异是什么?

最佳回答

GetNumberOfObjects可能最接近自然英语。 GetCountOfObjects sounds small awkward. 除此之外,几乎没有区别。

我的个人风格或许是使用“GetNumberOfObjects”的方法,这种方法只能归还已知的数字,但“Objects”采用一种实际进行计算的方法。

EDIT:造成这一差异的原因,至少对我来说,是,在计算时,字数通常被用作公证人,而计数则比较常用。

实际上,这是一种风格的选择。 不管你选择什么,都会被罚款。

问题回答

我也是来自非英语国家的一位方案家,但我认为选择名称的最佳方式是

  1. use the name that is the most clear
  2. use the shortest name enough to understand easily
  3. Also, english language suppose that it s better to swap the order than use Of .

因此,国际水道测量组织的最佳变量是GetObjectCount,当然是如果它能够归还物体的数量。

利用你们所希望的一切,但始终使用。

如果是这样的话,我将谈一下最简短的:size(>。 也就是说,如果你试图将成员职能添加到某种类似于集装箱的类别中,则使用现有图书馆所用的相同名称,使代码更加简单易读。

即使没有意义,但在 Java的采集器和设计器中,许多C++图书馆的相同功能名称将下降get/code> part,并提供更短的名称:GetNumberOfObjects =>NumberOfObjects,GetObjectCount/code> =>ObjectCount。 如果你想要使物体不同于集装箱(因此你明确希望避免<条码>大小()。 或许请上<条码>。 虽然numObjects不是合适的,但很容易阅读和解释,而且很短。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?