表示层和领域模型类命名约定
您对应用程序域模型类和表示层类使用的命名约定是什么?用于从第一眼就区分类的目的的后缀/前缀:
例如,从 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; }
...
}
或可能是您更喜欢的 PersonData
或 PersonInfo
或者更合适的东西?
然后我使用数据绑定来创建适当的演示文稿。例如,SexType
应转换为本地化字符串(Male、Mann、Homme、Hombre,...)Birthdate
转换为适当的日期格式(YYYY.MM.DD、DD. MM.YYYY, ...) 和全名变成 -> Family NP
所以我使用另一层类来进行表示数据绑定。类似
public class PersonDecorator
{
public string Sex { get; set; }
public string Date { get; set; }
public string FullName { get; set; }
}
或可能最好将此类命名为 PersonPresenter
或 PersonView
,或更合适的名称?
先感谢您!
What are the naming conventions you use for application domain model classes and presentation layer classes? Postfixes/Prefixes to distinguish the aim of the class from the first sight:
For example information about the person that is returned from DAL can be
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; }
...
}
or may be you prefer PersonData
or PersonInfo
or something more appropriate?
Than I use databinding to create appropriate presentation. For example SexType
should be converted to localized string (Male, Mann, Homme, Hombre, ...) Birthdate
to appropriate date format (YYYY.MM.DD, DD.MM.YYYY, ...) and full name into -> Family N.P.
So I use another layer of classes for presentation databindings. Something like
public class PersonDecorator
{
public string Sex { get; set; }
public string Date { get; set; }
public string FullName { get; set; }
}
or may it's better to name such class PersonPresenter
, or PersonView
, or something more appropriate?
Thank you in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
类名的
EntityPurpose
约定在很多地方都可以正常工作,特别是当您有多个实体(人、汽车等)和多个层(模型、视图、操作等)时。我将您的类命名为
PersonPresentation
。The
EntityPurpose
convention for class names works just fine in a lot of places, especially if you have several entities (Persons, Cars, etc) and several layers (Model, View, Action, etc).I'd name your class
PersonPresentation
.