Is Monostate the good cousin of the evil Singleton?

前端 未结 8 1644
梦如初夏
梦如初夏 2021-02-08 23:21

Singleton is definitely one of the most misused and abused patterns out there. Many of us have been infected with Singletonitis at one point or another. Curiously, its close c

8条回答
  •  别跟我提以往
    2021-02-08 23:41

    how about not using patterns just because?

    update: abuse of singleton occurs because people add the pattern w/o justification. It often adds arbitrary constraint to no benefit. using monostate w/o justification is perhaps less harmful, but no more justified. if the universe won't collapse if there's more than one instance, than don't enforce it with a pattern - just create only one instance.

提交回复
热议问题