开发者

Singleton Class With Protected Constructor

Class was designed with Protected Constructor as a SingleTon Class. It is shipped to Customer. Now need to submit a patch such that thi开发者_JAVA技巧s Protected constructor can be made as a Private.

is it possible?


I am guessing by your user name that your language is java...

A singleton must have a private constructor to be safe - otherwise it's not guaranteed to be a singleton!

You should just make it private. If your customer has subclassed your singleton and used the protected constructor, too bad. You shouldn't break your application design just to provide support for poisoned legacy code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜