Dedian  
-- 关注搜索引擎的开发
日历
<2006年4月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456
统计
  • 随笔 - 82
  • 文章 - 2
  • 评论 - 228
  • 引用 - 0

导航

常用链接

留言簿(8)

随笔分类(45)

随笔档案(82)

文章档案(2)

Java Spaces

搜索

  •  

积分与排名

  • 积分 - 64818
  • 排名 - 816

最新评论

阅读排行榜

评论排行榜

 
Here are some hints for difference between abstract classes and interfaces

1. Use Interface if something will change frequently in design
2. If the methods can be determined and implemented, use abstract classes to encapsulate them as methods of base classes and therefore can be inherited by subclasses.
3. If you just want to declare some methods in your design which allows to be devoloped from scratch later into different classes, the interface is best choice.
4. if need provide more common data structure, use abstract classes as base class.
5. if want to add your code to other existing third party class for later potential requirement, interface is good to choose.
6. Interfaces are often used to describe certain functionality of classes, thus one class can get multi-funcationlity from multiple interfaces (multiple inheritance), while an abstract class, try to describe a class's general attributes and functionalities which can be reused or re-implemented by its subclasses.
7. in other word, Abstract class want to say is-a proposition, while Interface want to say -able or can-do proposition.

reference:
http://mindprod.com/jgloss/interfacevsabstract.html
http://www.javaworld.com/javaworld/javaqa/2001-04/03-qa-0420-abstract.html
posted on 2006-04-19 02:15 Dedian 阅读(254) 评论(0)  编辑  收藏 所属分类: Java Glossary

只有注册用户登录后才能发表评论。


网站导航:
 
 
Copyright © Dedian Powered by: 博客园 模板提供:沪江博客