There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
fred rosenberger wrote:Why is it a useless function? Sure, you didn't have it do anything, but I wouldn't say that is useless.
Robby Ames wrote:Here the program is small, but think, if it is big then?? There may be a useless coding of many lines. So my question is: Is there any way to avoid these kind of situation? Is it right to say this multiple inheritance because it inherits nothing except the method name? What is the real use of Interface(considering the big picture)?
Robby Ames wrote:
fred rosenberger wrote:Why is it a useless function? Sure, you didn't have it do anything, but I wouldn't say that is useless.
Thanks! Fred.. I just use this program as a model to state the problem(which is the extra/useless code). Here my point is: if we implement an Interface into a class, we must have to give a body to all the functions/methods into that class regardless of their need.
Paul Clapham wrote:I will just repeat what I said before: if you want to know the real use of interfaces, there is no shortage of examples of the real use of interfaces. And I suggest that very little can be learned from examples which aren't based on real-life requirements.
If you want to see examples of "multiple inheritance" via implementing several interfaces, then looking at a Swing program which implements several of the interfaces used to deal with user interaction would be a good start. I would suggest ActionListener and MouseMotionListener as examples.
Jayesh A Lalwani wrote:
Interface should define A behavior. The methods in the interface should be related to that behavior. You shouldn't be putting unrelated methods into an interface. If you have 2 differrent behaviors, define 2 intrfaces. Classes implement only the interfaces that describe their behavior
Robby Ames wrote:
Paul Clapham wrote:I will just repeat what I said before: if you want to know the real use of interfaces, there is no shortage of examples of the real use of interfaces. And I suggest that very little can be learned from examples which aren't based on real-life requirements.
If you want to see examples of "multiple inheritance" via implementing several interfaces, then looking at a Swing program which implements several of the interfaces used to deal with user interaction would be a good start. I would suggest ActionListener and MouseMotionListener as examples.
Thanks! Paul.. Paul, it would be helpful if you provide me a link to the concerned page keeping in mind that I'm a Greenhorn(Beginner). Thanks! again.
Life is full of choices. Sometimes you make the good ones, and sometimes you have to kill all the witnesses.
Robby Ames wrote:Jayesh, do you want to say that I should put the methods window1visual1,window1visual2, window2visual1 in one interface and window2visual1,window2visual2, window1visual2 in other interface?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |