什么是矩形的好变量名称描述对象的位置和大小?

时间:2022-03-28 05:37:02

The title is fairly self-explanatory, but I'll reiterate: What would be a good variable name for a rectangle that describes an objects position and size.

标题是相当不言自明的,但我会重申:对于描述对象位置和大小的矩形,什么是一个好的变量名称。

EDIT - The object is a paddle for a Pong-like game, and there is already a rectangle named 'bounds' to restrict where the paddle can be moved to.

编辑 - 对象是类似Pong的游戏的桨,并且已经有一个名为“bounds”的矩形来限制桨可以移动到的位置。

I ended up going with 'bounds' for the paddles position and size, and 'movableArea' to restricted where the paddle can be moved.

我最终选择了'padsles'位置和尺寸的'bounds',并且'movableArea'限制了桨可以移动的位置。

9 个解决方案

#1


If it's a paddle, then why not paddleBound? That's not rocket science, it describes the object and its property and should be enough to distinguish it from anything else, except maybe the other paddle (then you can just use paddel1Bound or userPaddleBound for further distinction).

如果它是一个桨,那么为什么不paddleBound?这不是火箭科学,它描述了对象及其属性,应该足以将其与其他任何东西区分开来,除了可能是另一个桨(然后你可以使用paddel1Bound或userPaddleBound进一步区分)。

#2


Given the context of your question, why not Paddle?

鉴于你的问题的背景,为什么不Paddle?

#3


BoundingBox might be good.

BoundingBox可能不错。

#4


How about boundingBox or boundsRect?

boundingBox或boundsRect怎么样?

#5


Apple's Cocoa framework uses frame and bounds (with slightly different meanings) for this kind of variable. I've always found them to be good. If you need just one, I vote for frame.

Apple的Cocoa框架对这种变量使用了框架和边界(含义略有不同)。我总是发现它们很好。如果你只需要一个,我投票支持框架。

#6


Well, if the variable is of type Foo I would choose

好吧,如果变量是Foo类型,我会选择

fooRectangle

Or something similar to that. It also depends on the language and what the conventions are and perhaps the context.

或类似的东西。它还取决于语言和惯例以及可能的背景。

#7


I prefer short. How about xyBox?

我更喜欢短。 xyBox怎么样?

#8


How about perimeter?

外围怎么样?

#9


what about this ?

那这个呢 ?

Rectangle nextBounds; // bounds where the paddle can be moved to

矩形nextBounds; //可以将球拍移动到的边界

Rectangle bounds; // current bounds

矩形边界; //当前界限

#1


If it's a paddle, then why not paddleBound? That's not rocket science, it describes the object and its property and should be enough to distinguish it from anything else, except maybe the other paddle (then you can just use paddel1Bound or userPaddleBound for further distinction).

如果它是一个桨,那么为什么不paddleBound?这不是火箭科学,它描述了对象及其属性,应该足以将其与其他任何东西区分开来,除了可能是另一个桨(然后你可以使用paddel1Bound或userPaddleBound进一步区分)。

#2


Given the context of your question, why not Paddle?

鉴于你的问题的背景,为什么不Paddle?

#3


BoundingBox might be good.

BoundingBox可能不错。

#4


How about boundingBox or boundsRect?

boundingBox或boundsRect怎么样?

#5


Apple's Cocoa framework uses frame and bounds (with slightly different meanings) for this kind of variable. I've always found them to be good. If you need just one, I vote for frame.

Apple的Cocoa框架对这种变量使用了框架和边界(含义略有不同)。我总是发现它们很好。如果你只需要一个,我投票支持框架。

#6


Well, if the variable is of type Foo I would choose

好吧,如果变量是Foo类型,我会选择

fooRectangle

Or something similar to that. It also depends on the language and what the conventions are and perhaps the context.

或类似的东西。它还取决于语言和惯例以及可能的背景。

#7


I prefer short. How about xyBox?

我更喜欢短。 xyBox怎么样?

#8


How about perimeter?

外围怎么样?

#9


what about this ?

那这个呢 ?

Rectangle nextBounds; // bounds where the paddle can be moved to

矩形nextBounds; //可以将球拍移动到的边界

Rectangle bounds; // current bounds

矩形边界; //当前界限