1.What are delegation? Give an example.
2.Whe are constructors not specified as part of an interface?
3.Some are of the view that it would be simpler to abandon the idea of abstract calsses,and instead to use an ordinary class with null or aborting implementations of methods that the user is supposed to override. Is this a good idea?

解决方案 »

  1.   

    Abstract class represents that there is a higher level of  abstracting.
      

  2.   

    1) I'm not sure about the meaning of delegation here,
        maybe I've got confused with delegation in C#, so pass.2)      Interface represents the concept of 'Type' in Java
    while constructor belongs to class which stands for the implementation.
    We're supposed to separate type from implemenation.
             From another perspective, if you provide constructor for
    interfaces, how do you want to use them to instantiate object?
    Writable obj = new Writable(); //? no implementation at all3) This is like saying we need only pure virtual functions for C++,
        why do you need virtual functions in C++? 
        The same reason, that is, using inheritance to enhance reusability.
        If we know that Children would do something different together with
        something consistent in the same method, we're happy to define
        abstract method in parent class to reduce redundant code, and to 
        obtain   better maintanence.
      

  3.   

    Some are of the view that it would be simpler to abandon the idea of abstract calsses,and instead to use an ordinary class with null or aborting implementations of methods that the user is supposed to override. Is this a good idea?
    i think so 
      

  4.   

    Q1:  Proxy, or Delegation? The former is a design pattern. In java Class Refection is a good example. The latter means the same as the former do in java.
    Q3:  Actually a more elegant and effective way to programe contains there lays, that is,Interface, Abstract Class, Class, just as Java API implies. The first one tells the property and action of an objective thing, and second one prescribe how it will be like, and the last one define what it is. Based on this idea, it is not hard for us to understand why abstract class is indispensable. In fact, when programming, we usually reduce the problem to a set of interface, then we use Abstract Classes which implement the interface to descripe possible actions of this kind of problem; each Abstract Class for each possible actions. and finally we define exactly how the problem  is respectively solved.
      

  5.   

    1.不懂,C#?
    2,whe这个单词?
    3.SAX就提供了一个不实现任何功能的DefaultHander,你想要什么覆盖什么,不要就不管.比起抽象类更方便.util的集合类库也是这样实现的,你不想实现的功能就抛异常..好不好不知道,只知道方便
      

  6.   


    We must study english more hardly.
      

  7.   

    谢谢大家,whe 系why拼写错误。delegation好像是java中的委托吧?