There are different views on the subject of using an interface versus abstract class. An interface, though, should express the behavior of an object (what it can do) and the abstract class should define what it is. Basically "I can" versus "I am" from the object's persepective So, if we have a Person, that is a noun and so we'll use an abstract class to define it.
Any thing that "is a" Person will inherit from that class. If we want to define some behaviour that describes some behavior that the Person is capable of that doesn't extend to all Persons, we should put that into an interface Using the relationship that you defined (Person -> Employee -> Manager), we can say that the Employee implements IFirable and the Manager implements IFirer. The employee can be fired, and the manager can fire an employee.
There are different views on the subject of using an interface versus abstract class. An interface, though, should express the behavior of an object (what it can do) and the abstract class should define what it is. Basically "I can" versus "I am" from the object's persepective.So, if we have a Person, that is a noun and so we'll use an abstract class to define it.
Any thing that "is a" Person will inherit from that class. If we want to define some behaviour that describes some behavior that the Person is capable of that doesn't extend to all Persons, we should put that into an interface. Using the relationship that you defined (Person -> Employee -> Manager), we can say that the Employee implements IFirable and the Manager implements IFirer.
The employee can be fired, and the manager can fire an employee.
Good analogy. Are you saying the Person is an abstract class? – DotNetCookie Nov 3 at 14:52 1 @DotNetCookie - I don't really want to say yes or no to that.It all depends on context of what problem you're trying to solve.
If you need to be able to instantiate a "plain" Person object, then that wouldn't make much sense. In this case (Person -> Employee -> Manager) it might make sense to make the base class, Person, abstract. – James D'Angelo Nov 3 at 14:54 1 The behaviour I'd use for an interface with Person is IEat, which could declare a Feed method.
The point is that interfaces cut across, so Mammal : IEat > Person > etc. And PlantLife : IEat > Cactus, so a Person is not a PlantLife (some act like it) but they all eat in some way. – Luke Puplett Nov 3 at 15:34.
OK, let's see if I understood your question... I think your conceptaully unsure of the differences and/or similarities between the use of interfaces and abstract classes. If thats the issue then heres my "starter for 10" summary; Abstract classes cant be instantiated, but can contain implementation details, so when deriving a class from one you get the contract and any default behavior you put in the abstract class. For example your Person class (I'll assume its an abstract class for this example) would define the contract a derived Employee or Manager class must (at least) have, but can also provide some default behaviour.
Interfaces on the other hand only specify the contract; what implementing classes must do, they cannot provide any manner of implementation. For example if the "Person" in your example was infact an interface it wohuld define what classes implementing it (the Employee and Manager) must do, but cannot provide any default implementation for that contract. Also note that in many languages (Java, C#, Delphi) you can inherit from only one parent class, but can implement many interfaces.
I apologize that I am not using your person example, please take this as an extended comment only. I find it easiest to explain the concepts, to people with no programming background, using an analogy to something most people already understand: Plastic molding! Lets say we are making plastic fruit for instance: An interface is like the mold, it has the shape of the final product, but you can fill it with all kinds of different colors and materials.
They will all have the same shape in the end, even if they are completely different in color and texture. An abstract class would be more like something that needs an extra step, like painting. You create the basic plastic fruit, then sent it off to get some painting or fur glued on or something.
The unfinished fruit is like an abstract class in that is has more definition of the final product then the mold does, but it in itself is not complete. It needs more work to be completed, and the end products could be completely different colors, but they are still basically the same. I hope that helps!
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.