今天被问到为什么我在 asp.net 应用程序中为我的 bll 类使用这样的代码:
public class StudentBll
{
public static DataTable GetStudents()
{
return DBHelper.ExecuteSp("GetStudents");
}
public static DataTable GetStudentById(int studentId)
{
return DBHelper.ExecuteSp("GetStudentById", studentId);
}
}
代替
public class StudentBll
{
public DataTable GetStudents()
{
return DBHelper.ExecuteSp("GetStudents");
}
public DataTable GetStudentById(int studentId)
{
return DBHelper.ExecuteSp("GetStudentById", studentId);
}
}
我唯一能想到的就是
A)性能略有提高(不确定具体情况)
B)可读性
StudentBll.GetStudents();
而不是
StudentBll studentBll = new StudentBll();
studentBll.GetStudents();
然而,我对这些答案并不太自信。有人愿意开导我吗?