是单调邪恶的单身人士的好表哥吗? [英] Is Monostate the good cousin of the evil Singleton?

查看:100
本文介绍了是单调邪恶的单身人士的好表哥吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

单身人士绝对是在这里被滥用和滥用最多的模式之一。我们中的许多人已经在一点或另一个感染了单身性炎症。奇怪的是,其亲密的表弟 Monostate 不那么有名,更少使用。你对Monostate有什么看法?好还是就是邪恶?这是使用Singleton更好的选择吗?你还会像Singleton一样阻止它的使用吗?

解决方案

Um,monostate Singleton。 ..所以它有完全相同的问题。




  • 测试

  • 隐藏依赖

  • 不灵活

  • 线程安全

  • 全局状态难以确保正确性


    • 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 cousin Monostate is less famous and less used. What is your opinion of Monostate? Good or just as evil? Is it a better alternative to using Singleton? Would you also discourage its use as you would with Singleton?

      解决方案

      Um, monostate is Singleton... so it has the exact same problems.

      • testing
      • hiding dependencies
      • inflexible
      • thread safety
      • global state makes it difficult to ensure correctness

      这篇关于是单调邪恶的单身人士的好表哥吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆