【问题标题】:Is it better to alphabetize or group similar property names?将相似的属性名称按字母顺序排列或分组更好吗?
【发布时间】:2011-03-18 02:58:47
【问题描述】:

我要问的是您是否按字母顺序排列您的属性或将它们分组。示例:

分组

Public Property ID As Integer
Public Property CustomerID As Integer
Public Property Address As Address
Public Property Name As Integer

阿尔法

Public Property Address As Address
Public Property CustomerID As Integer
Public Property ID As Integer
Public Property Name As Integer

【问题讨论】:

  • 您能否尝试进一步澄清您的问题?您的意思是如何检索对象的属性并按字母顺序排列?

标签: .net code-formatting code-organization


【解决方案1】:

就它们在代码文件中的物理位置而言?我更喜欢字母排序,但大多数时候这几乎不是问题,因为代码编辑器中有一个方便的成员下拉列表。

【讨论】:

  • 是的,在实际的代码文件中,我正在考虑按字母顺序排列,因为如果您有很多属性,它会更容易找到。只是想知道......
【解决方案2】:

我通常按组排列房产,而不是按字母顺序排列。例如:

Contact
    ID
    FirstName
    LastName
    Address
    City
    State
    CountryID
    PostalCode

【讨论】:

  • 不过没关系!
【解决方案3】:

希望你的班级不会大到足以关心任何一种方式。但是,我会按组排列它们(在每个部分中评论分组的原因,然后在每个组中按字母顺序排列。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多