﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-pastelife-最新评论</title><link>http://www.blogjava.net/pastelife/CommentsRSS.aspx</link><description>The best way to predict the future is to invent it.</description><language>zh-cn</language><pubDate>Thu, 16 Mar 2006 09:43:50 GMT</pubDate><lastBuildDate>Thu, 16 Mar 2006 09:43:50 GMT</lastBuildDate><generator>cnblogs</generator><item><title>re: 避免在构造函数中使用多态</title><link>http://www.blogjava.net/pastelife/archive/2006/05/12/8904.html#45802</link><dc:creator>zk</dc:creator><author>zk</author><pubDate>Fri, 12 May 2006 03:21:00 GMT</pubDate><guid>http://www.blogjava.net/pastelife/archive/2006/05/12/8904.html#45802</guid><description><![CDATA[# re: 避免在构造函数中使用多态 2005-08-01 14:12 | emu<br><br>我觉得楼主的例子不恰当。 <br><br>真的“运行的时候可能没有预想的结果”吗？其实没有什么不可预见的，只是个对语言的理解程度的问题。 <br><br>-----------------------------------<br><br>如果我发布一个这样的包,你敢用吗?难道我可以用文档约束这个包的使用者:你要当心,在初始化完成你自己的类之前,我还调用了你的某一个方法.<br><br>还有你对模板模式的理解也有一定的不准确.<img src ="http://www.blogjava.net/pastelife/aggbug/45802.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/pastelife/" target="_blank">zk</a> 2006-05-12 11:21 <a href="http://www.blogjava.net/pastelife/archive/2006/05/12/8904.html#45802#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 避免在构造函数中使用多态</title><link>http://www.blogjava.net/pastelife/archive/2005/08/01/8904.html#8919</link><dc:creator>emu</dc:creator><author>emu</author><pubDate>Mon, 01 Aug 2005 06:12:00 GMT</pubDate><guid>http://www.blogjava.net/pastelife/archive/2005/08/01/8904.html#8919</guid><description><![CDATA[我觉得楼主的例子不恰当。<br><br>真的“运行的时候可能没有预想的结果”吗？其实没有什么不可预见的，只是个对语言的理解程度的问题。<br><br>“在构造函数利用到多态”指的是在抽象的超类的构造方法中调用抽象方法吗？在超类中调用抽象方法之后再在子类中具体实现的做法叫template method ，可以google一下看看，或者看看这里有一点简单的介绍：<br><a target="_new" href="http://www.cnblogs.com/zhenyulu/articles/79894.html">http://www.cnblogs.com/zhenyulu/articles/79894.html</a><br>作为一个设计模式，这是一个非常通用的做法，虽然这个做法好不好还存有争议（被认为违反依赖倒易原则DIP）。有的时候我们也会在构造方法中使用模版方法，但是确实要注意楼主提出的问题。<img src ="http://www.blogjava.net/pastelife/aggbug/8919.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/pastelife/" target="_blank">emu</a> 2005-08-01 14:12 <a href="http://www.blogjava.net/pastelife/archive/2005/08/01/8904.html#8919#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>