L
Luis Esteban Valencia
Please everybody participate in this question.
Hello my applicacion has many layers and classes and I think its well
structured. PLease let me know if you disagree and why.
1. I have the user Interface (webforms)
2. I have a class Called Customer Class (it only has private fields,
properties). Those properties connecto a Class called
CustomerDALC (Customer Data Access Logic Component). this one must be the
only responsible to access data. the acess of the data must be transparent
to the customerclass.
3. This last class is the one that actually retrieves or sets the
information from the database.
So here is the code.
public class Customer
{
// Private fields, to hold the state of the Product entity
private int customerId;
private string firstname;
private string lastname;
CustomerDALC objcustomerDalc;
// Public properties, to expose the state of the entity
public int getName
{
get { return objcustomerDalc.getFirstName(customerId); }
set { objCustomerDALC.setFistName(value, customerId); }
}
CustomerClass.Cs
public class CustomerDALC
{
private string conn_string;
public CustomerDALC()
{
// Acquire the connection string from a secure or encrypted location
// and assign to conn_string
}
public int getName(int id)
{
return sqlhelper.executereader("blablabla"); ///Resuming of course
}
public void setName(string name, int id)
{
return sqlhelper.executereader("blablabla"); ///Resuming of course
}
}
Suppose that in my webform I want to retrieve all the customers and bind to
a datagrid? what is the best way to do it?
Create an array of CustomerObjects? or create a dataset? where would I put
that dataset.
I took the code from this page
http://msdn.microsoft.com/practices/ArchDes/default.aspx?pull=/library/en-us/dnbda/html/boagag.asp
If you have other techniques to program with layers and objects and passing
info between layers please let me know. I am trying to modelate a generic
way to make this but I havent done it before.
Hello my applicacion has many layers and classes and I think its well
structured. PLease let me know if you disagree and why.
1. I have the user Interface (webforms)
2. I have a class Called Customer Class (it only has private fields,
properties). Those properties connecto a Class called
CustomerDALC (Customer Data Access Logic Component). this one must be the
only responsible to access data. the acess of the data must be transparent
to the customerclass.
3. This last class is the one that actually retrieves or sets the
information from the database.
So here is the code.
public class Customer
{
// Private fields, to hold the state of the Product entity
private int customerId;
private string firstname;
private string lastname;
CustomerDALC objcustomerDalc;
// Public properties, to expose the state of the entity
public int getName
{
get { return objcustomerDalc.getFirstName(customerId); }
set { objCustomerDALC.setFistName(value, customerId); }
}
CustomerClass.Cs
public class CustomerDALC
{
private string conn_string;
public CustomerDALC()
{
// Acquire the connection string from a secure or encrypted location
// and assign to conn_string
}
public int getName(int id)
{
return sqlhelper.executereader("blablabla"); ///Resuming of course
}
public void setName(string name, int id)
{
return sqlhelper.executereader("blablabla"); ///Resuming of course
}
}
Suppose that in my webform I want to retrieve all the customers and bind to
a datagrid? what is the best way to do it?
Create an array of CustomerObjects? or create a dataset? where would I put
that dataset.
I took the code from this page
http://msdn.microsoft.com/practices/ArchDes/default.aspx?pull=/library/en-us/dnbda/html/boagag.asp
If you have other techniques to program with layers and objects and passing
info between layers please let me know. I am trying to modelate a generic
way to make this but I havent done it before.