Are there any viable alternatives to the GOF Singleton Pattern?

后端 未结 16 1490
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-29 16:58

Let\'s face it. The Singleton Pattern is highly controversial topic with hordes programmers on both sides of the fence. There are those who feel like the Singleto

16条回答
  •  萌比男神i
    2020-11-29 17:51

    If your issue is that you want to keep state, you want a MumbleManager class. Before you start working with a system, your client creates a MumbleManager, where Mumble is the name of the system. State is retained through that. Chances are your MumbleManager will contain a property bag which holds your state.

    This type of style feels very C-like and not very object like - you'll find that objects that define your system will all have a reference to the same MumbleManager.

提交回复
热议问题