【问题标题】:Presentation layer and domain model classes naming conventions表示层和域模型类命名约定
【发布时间】:2010-08-01 10:13:41
【问题描述】:

您对应用程序域模型类和表示层类使用的命名约定是什么?后缀/前缀,用于区分类的第一眼目标:

例如,从 DAL 返回的有关人员的信息可以是

public class PersonEntity 
{
  public Guid Id { get; set; }
  public SexType Sex { get; set; }
  public Date Birthdate { get; set; }
  public string Name { get; set; }
  public string Family { get; set; }
  public string Patronymic { get; set; }
  ...
}

或者您可能更喜欢PersonDataPersonInfo 或更合适的名称?

比我使用数据绑定来创建适当的演示文稿。例如 SexType 应转换为本地化字符串 (Male, Mann, Homme, Hombre, ...) Birthdate 以适当的日期格式 (YYYY.MM.DD, DD.MM.YYYY, ...) 和完整命名为 -> Family N.P.

所以我使用另一层类来进行表示数据绑定。像

public class PersonDecorator
{
  public string Sex { get; set; }
  public string Date { get; set; }
  public string FullName { get; set; }
}

或者最好将此类命名为PersonPresenter,或PersonView,或更合适的名称?

提前感谢您!

【问题讨论】:

    标签: naming-conventions data-access-layer presentation


    【解决方案1】:

    EntityPurpose 类名称约定在很多地方都可以正常工作,尤其是当您有多个实体(Persons、Cars 等)和多个层(Model、View、Action 等)时。

    我会把你的班级命名为PersonPresentation

    【讨论】:

    • 谢谢你的回答,帕维尔。等别人怎么说
    猜你喜欢
    • 2015-07-17
    • 1970-01-01
    • 2021-05-15
    • 2010-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多