Since the Factory method calls the connstructor call, you must pass all the necessary parasites to the Factory method. Consider the following:
class Foo {
}
class Boo {
public Boo(Foo foo) {}
}
static class BooFactory {
public static Boo CreateBoo(Foo foo) {
return new Boo(foo);
}
}
Another alternative, as aaronls suggests, you can use Inversion of Control to reduce such dependencies.
source
share