别的不说,singleton 没答好,有点儿说不过去。

来源: mdq100 2009-03-04 20:39:56 [] [博客] [旧帖] [给我悄悄话] 本文已被阅读: 次 (434 bytes)
In Java, the latest Singleton pattern, use enum instead of a regular class. It's that simple.

The reasoning based on Joshua's is that serialization can cause issues. If a class implements Serializable, then after serialized and deserialized, a new instance can be created if the instance variables are not transient.

If you can answer the above, you will be guaranteed to pass the Singleton question.

Good luck.

所有跟帖: 

谢师祖教诲。 -吴用先生- 给 吴用先生 发送悄悄话 (0 bytes) () 03/04/2009 postreply 22:09:19

回复:别的不说,singleton 没答好,有点儿说不过去。 -ncpga- 给 ncpga 发送悄悄话 (158 bytes) () 03/05/2009 postreply 09:26:00

It was a C++ interview, -吴用先生- 给 吴用先生 发送悄悄话 (467 bytes) () 03/05/2009 postreply 10:44:10

why it needs a copy ctor? why make copy constructor "protected" -戏雨飞鹰- 给 戏雨飞鹰 发送悄悄话 戏雨飞鹰 的博客首页 (356 bytes) () 03/05/2009 postreply 11:50:35

the interviewer said -吴用先生- 给 吴用先生 发送悄悄话 (186 bytes) () 03/05/2009 postreply 12:31:48

ok. -戏雨飞鹰- 给 戏雨飞鹰 发送悄悄话 戏雨飞鹰 的博客首页 (0 bytes) () 03/05/2009 postreply 12:40:14

师祖爷呀,你的singleton说得也忒深奥了。够俺回味好几年得了。。 ~~~ -戏雨飞鹰- 给 戏雨飞鹰 发送悄悄话 戏雨飞鹰 的博客首页 (26 bytes) () 03/05/2009 postreply 12:18:58

是啊是啊,也很高兴飞鹰姐姐亲临指导,没想到 -吴用先生- 给 吴用先生 发送悄悄话 (48 bytes) () 03/05/2009 postreply 12:34:56

看似容易,其实还是有点学问的。 -mdq100- 给 mdq100 发送悄悄话 mdq100 的博客首页 (170 bytes) () 03/05/2009 postreply 20:21:33

噢,谢谢。我还真没用过serialization /deserialization -戏雨飞鹰- 给 戏雨飞鹰 发送悄悄话 戏雨飞鹰 的博客首页 (762 bytes) () 03/05/2009 postreply 20:43:54

basiaclly yes. -mdq100- 给 mdq100 发送悄悄话 mdq100 的博客首页 (237 bytes) () 03/05/2009 postreply 20:55:48

Thanks, 100... -戏雨飞鹰- 给 戏雨飞鹰 发送悄悄话 戏雨飞鹰 的博客首页 (0 bytes) () 03/05/2009 postreply 20:58:13

nonsense, 又不用你发明singleton. 知道singleton是什么意思,会COPY$PASTE 就行. -bluemont- 给 bluemont 发送悄悄话 (0 bytes) () 03/05/2009 postreply 19:28:02

这么复杂?那COPY$PASTE是8是很难?哈哈。。 -戏雨飞鹰- 给 戏雨飞鹰 发送悄悄话 戏雨飞鹰 的博客首页 (69 bytes) () 03/05/2009 postreply 20:00:33

只要不谩骂,欢迎交流。换马甲也没关系。 -mdq100- 给 mdq100 发送悄悄话 mdq100 的博客首页 (0 bytes) () 03/05/2009 postreply 20:17:12

请您先登陆,再发跟帖!

发现Adblock插件

如要继续浏览
请支持本站 请务必在本站关闭/移除任何Adblock

关闭Adblock后 请点击

请参考如何关闭Adblock/Adblock plus

安装Adblock plus用户请点击浏览器图标
选择“Disable on www.wenxuecity.com”

安装Adblock用户请点击图标
选择“don't run on pages on this domain”