I have designed the application in the following ways:
Form
UserManager manager = new UserManager();
bool result= manager.AddUser(txtName.text,txtPassword.text,txtEmail.text);
<App_Code>\BusinessLogic
Public Class UserManager
{
public UserManager()
{
}
public bool AddUser(string name,string password, string email)
{
UserDB.AddUser(name,password,email);
}
}
<App_Code>\BusinessObject
public class User
{
private string _name;
private string _pass;
private string _email;
public string Name
{
get { return _name;}
set { _name;= value; }
}
public string Pass
{
get { return _pass;}
set { _name= value; }
}
public string Email
{
get { return _email };
set { _email=value; }
}
}
<App_Code>\BusinessObject\Collections
public class UserList : List<User>
{
}
<App_Code>\DataAccess
public class UserDB
{
public static bool AddUser(string name,string password, string email)
{
//stored procedure call
}
}
According to this design, please suggest is it correct way of doing it and something is wrong. If it is wrong please suggest me how can i improve it.
I particularly want to ask, making the data access class static is good practice or not?
Thanks in advance
Well, I miss here the interfaces that define the operations on BusinessLogic that will allow you to unit test the code.
public interface IUserManager{
bool AddUser(string name,string password, string email);
}
About making the data access static, if it's a multithreaded environment like Asp.Net, you better don't, and follow the session per request strategy .
I have designed the application in the following ways:
Form
UserManager manager = new UserManager();
bool result= manager.AddUser(txtName.text,txtPassword.text,txtEmail.text);
<App_Code>\BusinessLogic
Public Class UserManager
{
public UserManager()
{
}
public bool AddUser(string name,string password, string email)
{
UserDB.AddUser(name,password,email);
}
}
<App_Code>\BusinessObject
public class User
{
private string _name;
private string _pass;
private string _email;
public string Name
{
get { return _name;}
set { _name;= value; }
}
public string Pass
{
get { return _pass;}
set { _name= value; }
}
public string Email
{
get { return _email };
set { _email=value; }
}
}
<App_Code>\BusinessObject\Collections
public class UserList : List<User>
{
}
<App_Code>\DataAccess
public class UserDB
{
public static bool AddUser(string name,string password, string email)
{
//stored procedure call
}
}
According to this design, please suggest is it correct way of doing it and something is wrong. If it is wrong please suggest me how can i improve it.
I particularly want to ask, making the data access class static is good practice or not?
Thanks in advance
Well, I miss here the interfaces that define the operations on BusinessLogic that will allow you to unit test the code.
public interface IUserManager{
bool AddUser(string name,string password, string email);
}
About making the data access static, if it's a multithreaded environment like Asp.Net, you better don't, and follow the session per request strategy .
0 commentaires:
Enregistrer un commentaire