Scheduled Tasks- -| 回首页 | 2005年索引 | - -SCBCD Passed

Evil vs Not Evil- -

TagJava    keywords    extends                                          

Extends is evil  VS Extends is not evil

Evil or not evil, it is a question, I think both of the articles want to deliver a information to us NEVER try to do the concrete implementation,  under this rule, If the developer want to use the implemented method of its logical sup-classes, he must use the adapter pattern to make down-the-line changes. I do think such concept is too ideal and pendatic and will never come true.

Consider about the SWING API, there is hundreds of the method within one classes and such class may implement dozens of the interface, then what to do to apply such OO design principle onto the class? you may spend whole day to copy and paste every method even you only need the name. It is definitely error-prone.

Also I do think the first example of the Extends is evil  does not offer enough evidence for the author's assertion, say, the problem is not caused by extends key words, It is because the author use the bugy way to declare the variable. NEVER bind you implementation to the concrete class, that means ArrayList list = new ArrayList() is evil, It will make your code to be rigidity.  that is true, but it is not the business of the extends, he is innocent.


- 作者: 野狗糊糊 访问统计: 2005年09月11日, 星期日 10:44 加入博采

Trackback

你可以使用这个链接引用该篇文章 http://publishblog.blogchina.com/blog/tb.b?diaryID=2884598

博客手拉手

回复

评论内容: