crella
V2EX  ›  问与答

问个变量命名的问题

  •  
  •   crella · Feb 20, 2020 via Android · 2348 views
    This topic created in 2461 days ago, the information mentioned may be changed or developed.
    一个分布类似矩形的元素集合,要记录其左上角的位置,右上角、左下角、右下角的位置,值都是正整数。该怎么命名这四个变量?

    命名越短越好。我刚才想到一个,就是从右上角开始,按顺时针方向依次是 p45、p135、p225、p315,是四个方向的角度,p 指代 position 位置。

    还有其他好的命名吗?
    6 replies  •  2020-02-20 20:24:43 +08:00
    momocraft
    momocraft
    Feb 20, 2020
    1
    ⌜⌝⌞⌟
    fanqiang07
    fanqiang07
    Feb 20, 2020
    2
    pNE -> NorthEast
    pSE -> SouthEase
    pSW -> SouthWest
    pNW -> NorthWest
    fanqiang07
    fanqiang07
    Feb 20, 2020
    3
    SE -> SouthEast
    CismonX
    CismonX
    Feb 20, 2020
    4
    upperLeft/topLeft upperRight/topRight
    lowerLeft/bottomLeft lowerRight/bottomRight
    xupefei
    xupefei
    Feb 20, 2020
    5
    最常用的命名是
    TopLeft
    TopRight
    LeftBottom
    RightBottom

    顺序是左上角开始逆时针。
    nirvanacqw
    nirvanacqw
    Feb 20, 2020
    6
    一楼的好
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   941 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 22:00 · PVG 06:00 · LAX 14:00 · JFK 17:00
    ♥ Do have faith in what you're doing.