some help please
A subclass can inherit "interface" or "implementation" from a superclass. How do inheritance hierarchies designed for inheriting interface, differ from those designed for inheriting implementation (behavioral characteristics of a class)?
Have a look at this. Does this clear anything up for you?
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
Your decision in this matter is based upon your implementation of Object Oriented Programming.
In my implementation, the more that a child class "is a" type of the parent, the more I want to use inheritance. I want the child to have many of the fields and methods of the parent (not implementing its own versions) except for those special fields or methods which differentiate the child from the parent. Think of Bird parent and its child classes, or Shape and all of the shape children, or Person and all the types of persons which your program might interact with.
When I use one or more interfaces in my code, it is because I want a user of the class to know that my class is capable of performing a certain task or set of tasks for the calling class. This kind of "performs a" relationship is the separation of concerns part of OOP. I don't have to have all of my classes performing all operations. I can design specialists to perform a task which many classes will need to perform. The many classes can send a message to the class which will perform the task for them, and that class will return the answer or move the system to the next state for them. The calling class does not need to know how the called class does its job, just needs to know how to format the call to the method it wants to implement. On the flip side, I may not want the calling classes to know how I implement the algorithm or method that the called class is executing (trade secret) and I want the flexibility to modify my implementation but I don't want to force the re-write the code of all of the other classes which might call this class. Therefore, I write the interface - which sets out the method calls which the special purpose class will implement - which remains the same, known to all of the potential calling classes, then I implement that interface in one or more called classes. I can "cast" the interface to the implementing class.
Inheritance from a parent = "is a" relationship
Implementing an interface = "performs a" relationship
In Java - single inheritance, multiple implementation
Yes, you can write "is a" type relationships into an implementation of an interface, and child classes perform the same functions as a parent (perhaps in their own way), but it is all a matter of your design choices in your implementation.
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center