Is this a bad practice? I've seen few peoples say that constructor should not do the real work.
class FooConfig {
public FooConfig(File file) {
loadFile(file);
}
private void loadFile(File file) {
// do something...
}
}
Or I should do this instead?
class FooConfig {
private final File file;
public FooConfig(File file) {
this.file = file;
}
public void loadFile(File file) {
// do something...
}
}
FooConfig config = new FooConfig(file);
config.loadFile();
Thank you.
Aucun commentaire:
Enregistrer un commentaire