Friday, December 10, 2004

Returning class object or the DataSet

Suppose you have a class:

public class Person
{
private string _name;
private string _code;

public Person()
{
_name = null;
_code = null;

}

public string Name
{

get { return _name; }

}


}

Now there is another class which use the Person class:

public class getDetails
{

Person person = new Person();
getPhoneNumber(person.Name); // This will return the person name
.
.
.
return person // returns the whole Person object

}

Another way of returning the data can be of using DataSet. We query in the database and populate the dataset using the result of that query.

The question is when to use what approach. When we simple want to display the data on the client side we should use dataSet, having said so also remember that dataset can also be traversed but its a tiring process.
On the other hand if we would like to make some calculations on the returned data we can use the return object type approach.


No comments: