<thinking in java>
尽量使用interfaces,不要使用abstract类。若已知某样东西准备成为一个基础类,那么第一个选择应是将其变成一个interface(接口)。只有在不得不使用方法定义或者成员变量的时候,才需要将其变成一个abstract(抽象)类。接口主要描述了客户希望做什么事情,而一个类则致力于(或允许)具体的实施细节。

解决方案 »

  1.   

    abstract类还是有实现代码的,当你明确部分细节时,就可以用它,可以方便很多。
    interfaces用来描述问题。比如所有的实现细节你都不清楚或还不想关心的时候,就用它。(主要用于模块件的接口或扩展性要求很强的地方)
      

  2.   

    An interface in Java is like an abstract class in which all methods are also abstract:Methods declared in an interface are implicitly public and abstractFields declared in an interface are implicitly public, static, and finalThe interface represents a special syntax for a special kind of abstract classClasses and interfaces are types. 
      

  3.   

    public abstract class FrameProcess
    {
        public void doProcess()
        {
           init();
           step1();
           step2();
           ....
           closeOut();
        }
        protected abstract void step1();
        protected abstract void step2();
    }public class CustomProcess
    extends FrameProcess
    {
        protected void step1()
        {
            ....
        }
        protected void step2()
        {
            ....
        }
    }