Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

14
  • 2
    Ack... Really? .... Commented Jun 21, 2017 at 22:06
  • 4
    Follows single responsibility principle. A class shouldn't know how to instantiate itself -- That's not what SRP means. This is probably where your answer runs off the rails. Commented Jun 21, 2017 at 22:16
  • 1
    Abstracts the construction of Foo. You can change how you instantiate Foo by implementing new FooFactorys -- Again, why would you need this? A dictionary provides more than sufficient abstraction for a general-purpose configuration mechanism. Commented Jun 21, 2017 at 22:18
  • 1
    All in all, it seems like a lot of boilerplate for dubious benefits. Commented Jun 21, 2017 at 22:21
  • 2
    " SRP says that a class should only have one reason to change. If Foo knows how to instantiate itself then it will have two reasons to change-- 1. if Foo's logic changes and 2. if Foo's instantiation changes." sweet jesus, by that logic every single class needs a factory, every factory needs a factoryfactory, etc. Commented Jun 21, 2017 at 23:55