From: Leo I. <leo...@gm...> - 2010-09-11 14:44:47
|
Java doesn't support multiple inheritance the way C++ does. This means that If you want your class to extend multiple types, you have to use interfaces. On Sat, Sep 11, 2010 at 8:17 AM, Panayotis Katsaloulis < pan...@pa...> wrote: > For quite some time there is no decision whether it is preferable to > use abstract classes or interfaces. > With this email I'd propose to use only abstract classes instead of > interfaces and I hope I will convince you :) > > First of all I know the disadvantages. By using interfaces we can not > reuse the same objects and thus we usually create inner classes (so we > create one class more). > A second problem has to do with concept: in ObjC there is a use of > protocols and not interfaces. > > The problem is, although it looks like we make economy by reusing the > same object, in reality under the current xmlvm implementation, this > is not the case. In order to properly support java interfaces, a > "secret" glue object is used in every case (in which object we have > absolutely no control upon). > > When using abstract classes there is 1-1 correspondence. Even if we > use inner classes (which is a common and well known technique), we > have absolute control on this object. In any case, worst case > scenario, we have to define/use one (an only one) object of this > abstract class. > > Back to the interface implementation, the minimum number of objects is > one: the glue object. Though, in the case of an inner object (or any > time we don't reuse a given object) , the number of objects rises to > two! > > In all cases, interface implementation is more demanding than abstract > classes, and more complex. For this reason I propose to use everywhere > in XMLVM compatibility library abstract classes instead of interfaces > - even for trivial cases. > > -- > Panayotis > > > ------------------------------------------------------------------------------ > Start uncovering the many advantages of virtual appliances > and start using them to simplify application deployment and > accelerate your shift to cloud computing > http://p.sf.net/sfu/novell-sfdev2dev > _______________________________________________ > xmlvm-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmlvm-users > |