On design patterns: When should I use the singleton?

后端 未结 20 3037
失恋的感觉
失恋的感觉 2020-11-22 02:45

The glorified global variable - becomes a gloried global class. Some say breaking object-oriented design.

Give me scenarios, other than the good old logger where it

20条回答
  •  臣服心动
    2020-11-22 03:37

    An example with code, perhaps.

    Here, the ConcreteRegistry is a singleton in a poker game that allows the behaviours all the way up the package tree access the few, core interfaces of the game (i.e., the facades for the model, view, controller, environment, etc.):

    http://www.edmundkirwan.com/servlet/fractal/cs1/frac-cs40.html

    Ed.

提交回复
热议问题