dependency injection vs factory pattern