如何命名一个既代表大小又代表位置的结构体?
我有一个名为 WaveSize 的结构来表示样本量或时间量,但我也使用此结构来表示波内的位置或偏移量。
虽然用 Vector2d 类型表示坐标系中的大小和位置很常见,但我无法找到一个足够抽象的好名称来表示波长和波位置/偏移。
我发现看到这样的东西很奇怪:
public WaveSize Size { get; }
public WaveSize Offset { get; }
我宁愿想出一个好名字,也不愿创建空类或使用“using”。
任何建议将不胜感激。 提前致谢。
编辑:作为里德·科普西和 Marc Gravel 认为拥有两个不同的类很有意义,因为它们是两个不同的概念,因此,代码中的任何相似之处都应被视为纯粹的巧合。
I have a structure named WaveSize to represent both an amount of samples or an amount of time, but I'm also using this structure to represent a position or an offset within a wave.
While it's pretty common to represent both sizes and positions within a coordinate system with a Vector2d type, I'm unable to find a good name abstract enough to represent wave lengths and wave positions/offsets.
I find odd to see something like:
public WaveSize Size { get; }
public WaveSize Offset { get; }
I'd rather come up with a good name than creating empty classes or using 'using'.
Any suggestions will be much appreciated. Thanks in advance.
EDIT: As Reed Copsey & Marc Gravel suggested it makes a lot of sense to have two different classes since they are two different concepts, so, any similarities in code should be seen as mere coincidences.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
“偏移”的通常名称不是相移吗?
我可能会选择 WaveProperties,真的。
Isn't the usual name for the 'offset' the phase shift?
I'd probably go with WaveProperties, really.
我将有两个独立的结构,并使它们之间的转换变得容易。
您试图在这里表示两个概念,一个是位置,另一个是大小。 由于这是两个概念上不同的想法,因此我将它们设为两个结构。
我也同意 Marc Gravell 关于 BCL 的 Point/Size 结构的回答。 我认为他们是一个值得效仿的好榜样。
I would have two separate structs, and make conversions easy between them.
You're trying to represent two concepts here, one for position, and one for size. Since these are two conceptually distinct ideas, I'd make them two structs.
I also agree with Marc Gravell's answer regarding the BCL's Point/Size structs. I think they're a good model to follow.
你能有一个简单地称为 Wave 的结构,然后大小和偏移量可以很好地适应更通用的名称吗? 我希望你还没有 Wave 结构:)
Could you have a struct called simply Wave and then size and offset would fit snugly into the more general name? I hope you dont have a Wave struct already :)
波矢?
WaveVector?
您可以与 winforms
Point
和Size
结构进行比较...他们决定即使它们相似,也要将它们分开。 这在代数意义上是有意义的:等等
You could compare to the winforms
Point
andSize
structures... they decided that even if they are similar, to keep them separate. It makes sense at the algebraic sense:etc