延伸Singleton类? [英] extending a Singleton class?

查看:150
本文介绍了延伸Singleton类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法,使像一个模板单例类,这样,当你扩展它,扩展类也是一个单例类,这样我就可以迅速做出了新的单例类只是我的扩展模板单身类?我使用ActionScript 3.0,如果它很重要。

Is there a way to make like a template singleton class so that when you extend it, the extended class is also a singleton class, so I can quickly make a new singleton class just my extending the template singleton class? I am using ActionScript 3.0 if it matters.

感谢。

推荐答案

单例模式的设计是这样一种方式,类型不应该被继承。我不熟悉的动作,但有一个单类型也能够延长似乎是一个错误。

The singleton pattern is designed in such a way that the type ought not to be inherited. I am not familiar with ActionScript but having an singleton type that is also able to be extended seems like a mistake.

如果你做到这一点那么这将意味着,父母和孩子的类型可能都有自己单独的实例加载到相同的应用程序。由于类型,多态,类型将在技术上不再是单身。

If you were to do this then that would mean that the parent and child types could both have their single instances loaded into the same application. Since the types are, polymorphically, of type Parent, Parent would technically no longer be a singleton.

这篇关于延伸Singleton类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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