I was wondering what the purpose of separating the instantiation logic and the data loading logic of a class that loads data into memory if the class is a one time use.
Here is an example of what I mean.
DataLoader loader = new DataLoader("serverName", "databaseName");
loader.LoadData();
//Do Something with the loader never calling the LoadData function again
The loader itself is used once as the data is loaded into the global variables in the class.
class DataLoader {
private DataSet _data;
public DataLoader(string server, string database){}
public void LoadData(){
//load _data with sql data.
}
//Other functions that allow controlled access to the _data variable
}
Is there a valid reason for doing this or is it just flawed design?