【发布时间】:2010-11-16 14:32:39
【问题描述】:
我正在学习一些很好的代码实践,这就是为什么我要通过一些代码,一些我无法理解的东西。它为每个实体在一个单独的类中创建了属性,就像在 userClass 中它具有属性
#region public properties
private int uid;
public int userId
{
get { return uid; }
set { uid = value; }
}
private string uName;
public string userName
{
get { return uName; }
set { uName = value; }
}
private string pwd;
public string password
{
get { return pwd; }
// set { pwd = value; }
}
private string uAddress;
public string userAddress
{
get { return uAddress; }
set { uAddress = value; }
}
private string fName;
public string firstName
{
get { return fName; }
set { fName = value; }
}
private string lName;
public string lastName
{
get { return lName; }
set { lName = value; }
}
private string uPhone;
public string userPhone
{
get { return uPhone; }
set { uPhone = value; }
}
private string uMobile;
public string userMobile
{
get { return uMobile; }
set { uMobile = value; }
}
private int secretQuestion;
public int securityQuestion
{
get { return secretQuestion; }
set { secretQuestion = value; }
}
private string userAnswer;
public string answer
{
get { return userAnswer; }
set { userAnswer = value; }
}
#endregion
从业务逻辑类中,它使用属性而不是直接使用任何实体的属性名称,但我很困惑有什么需要制作这样的属性?
除此之外,它有数据库列名称的枚举,这背后有一个明确的原因,如果在不久的将来我们必须更改数据库表的字段名称,那么我们不必更改整个业务逻辑类我们可以直接对枚举进行更改,但是像这样创建属性有什么用,请详细说明
【问题讨论】:
标签: c#-3.0