dofactory design pattern