I am a newbie in design patterns.
I want to create an instance of a class, say ClassA, and set some of its fields to the values read from a config file.
If I keep distinct the code of the class from the code that manages the file with the values then ClassA becomes a pure "businness logic" class.
class ClassA {
boolean config1;
String originDB;
String destDB;
//other fields not initialized at the construction time
}
class ClassAFactory {
boolean config1;
String originDB;
String destDB;
public ClassAFactory {
//constructor of the class factory
//load config values from file
}
public ClassA newInstance() {
//create a new instance of ClassA and config fields config1, originDB, destDB
}
}
I would say that this is a builder pattern because builder seems to take care of "not only instantiation" but initialization too.
But otherwise, builder seems to be focused on breaking the creation process in steps, while in my case I have only one (yet compound) step.
May be considered a builder pattern? Or is it something different?