From: David Masover Date: 2010-07-25T06:32:36+09:00 Subject: Re: ruby abstraction On Tuesday, July 20, 2010 12:25:03 am Robert Klemme wrote: > On 20.07.2010 06:03, David Masover wrote: > > In fact, IIRC, this is how C++ does it -- it's just made much easier due > > to multiple inheritance. I never quite understood why Java allows > > multiple interfaces to be applied to the same object, and even to the > > same interface, but not multiple inheritance. > > State. I guess they were afraid of the way C++ makes inheritance > complicated because of virtual and non virtual inheritance and the > consequences for the visibility of state ("diamond problem"). It seems like this exact problem exists just as much in an interface, though -- the only difference is that interfaces force implementations to explicitly implement each of their methods. The simple solution, then, would be to force the inheriting class to explicitly override those methods. Actual, direct state -- as in, instance variables -- I don't see any reason for an instance variable to be anything other than private, except for the fact that Java makes setters and getters ridiculously verbose. > I would > also add that "interface" is a cleaner concept because it stresses the > fact that not behavior or state is shared but only the interface. I agree that it's cleaner, but it's also something which could easily be done by convention, as you suggest: > Granted, you can achieve similar goals with abstract classes that > contain only abstract methods A Java Interface is essentially an abstract class, which contains only abstract methods, but which can be multiply inherited from.