let's say you're building an application for an airport (just an example). The client tells you that you have an airplane, but an airplan can be started using different techniques. One airplane can have 2 main engines, but another airplane can have 4.
So, how would you go with this example?
2o) you can have an abstract class for an airplane. you know that even if the airplane has 2 or 4 engines, it's got wheels, it's got windows, it's got a cockpit, so on. it's the same. So does it make sense to create 2 classes that have the same attributes? The only thing is that the way to start an engine in a 2-engine plane is different to a 4-engine plane.
So that's the reason this abstract class will have some methods that are not implemented. This is to give you the flexibility to implement these methods in a subclass (more specific) in any way you like.
the abstract class, for instance, can have a method openDoor() which is common to all the planes. So it is implemented in this abstract class, and when you create your particular class extending from this abstract class, you automatically inherit all these methods. You will only need to implement the ones that are different for the plane you are creating.
Now, if a client tells you six months later that a new plane came with 1 engine, what would you do? simple, you know that this new plane is indeed, a plane, so you only need to extend from this class again and implement the method to start the engine. If the way to open a door is different, you simply override the method from the abstract class.
So, instead of duplicating information, you create an abstract class, knowing that all the classes that extend from this class will inherit all the properties that this abstract class has.
my lack of english fluency makes things harder to explain
, but I hope this helps a bit
[ August 13, 2003: Message edited by: Andres Gonzalez ]