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*

12
  • 1
    Why not use a class with static methods? Inheritance for example... Commented Jan 4, 2013 at 11:07
  • 3
    @m3th0dman: Doesn't sound like a good place for inheritance. Commented Jan 4, 2013 at 15:10
  • @BillyONeal You can say that something is good or bad for inheritance if you know the domain model, what is to be modeled in that way... Commented Jan 5, 2013 at 12:18
  • 2
    @m3th0dman: Erm, no. I can be pretty positive without knowing anything about the domain model. Inheritance is for polymorphic behavior. But as a singleton, you aren't going to have polymorphic behavior. Commented Jan 6, 2013 at 1:49
  • 1
    @m3th0dman: Because to get the singleton object requires specifying the name of the singleton at the call site. Which means that you aren't using polymorphic behavior. Which means that composition is far more flexible than inheritance. Commented Jan 6, 2013 at 19:29