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.

8
  • Unfortunately, as of about a month ago, my team consists solely of me (the lead quit). I didn't think of its relevance to the factory pattern. That's a neat observation, actually. Commented Oct 18, 2012 at 14:27
  • 1
    @KChaloux: Of course, if you were using just the Factory Method pattern, your case 0: quux = new Foo(); break; becomes case 0: return new Foo(); which is frankly as easy to write and much easier to read than { 0, () => new Foo() } Commented Oct 18, 2012 at 16:19
  • @pdr That's shown up a few places in code already. There's probably a good reason to create a factory method on the object that inspired this question, but I figured it was interesting enough to ask on its own. Commented Oct 18, 2012 at 16:21
  • 1
    @KChaloux: I confess I'm not keen on the recent obsession with replacing switch/case with a dictionary. I've not seen a case yet where simplifying and isolating the switch in its own method wouldn't have been more effective. Commented Oct 18, 2012 at 16:31
  • @pdr Obsession is a strong word to use here. More of a consideration when deciding how to deal with one-off mappings between values. I agree that in cases where it's repeated, its best to isolate a creational method. Commented Oct 18, 2012 at 16:50