title: Builder pattern vs. Dependency Injection (for instance via Guice)
body: <p>I'm developing a simple tree-structured database and I'm usually setting dependencies or optional settings via a Builder (Builder pattern). Now I'm not sure when to use for instance Guice, when to use the Builder pattern and when to use a static factory method instead of the constructor itself. I've read Effective Java several times and I think it mentions at least a lot of advantages for not exposing the constructor. It's time to reread ;-)</p>
  
  <p>So, do you know of cases which are clearly distinguishable? And shouldn't I expose the constructor? Thus for instance in every case write <code>public static Foo getInstance(...) { return new Foo(...)}</code>?</p>