Let's first discuss Class and Interface in object oriented programming term.
Class :
The class defines the object's internal state and the implementation of it's operations. An object's class defines how the object is implemented.
Interface :
In contrast, an object's type only refers to its interface that is the set of requests to which it can respond or we can say set of operation that object support.
Here, it is important to understand the difference between an object's class and it's type. An object can have many types, and objects of different classes can have the same type.
There is a close relationship between class and type. Because a class defines the operations an object can perform, it also defines the object's type. When we say that an object is a instance of a class, we imply that the object supports the interface defined by the class.
Now lets talk about Class inheritance and interface inheritance.
Class inheritance :
Class inheritance defines an object's implementation in terms of another object's implementation. In short, it's a mechanism for code and representation sharing.
Interface inheritance :
In contrast, interface inheritance ( or subtyping ) describes when an object can be used in place of another.
Reference:
1. Design Patterns, Elements of Reusable Object-Oriented Software. Author : Gang of Four ( Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides )
Class :
The class defines the object's internal state and the implementation of it's operations. An object's class defines how the object is implemented.
Interface :
In contrast, an object's type only refers to its interface that is the set of requests to which it can respond or we can say set of operation that object support.
Here, it is important to understand the difference between an object's class and it's type. An object can have many types, and objects of different classes can have the same type.
There is a close relationship between class and type. Because a class defines the operations an object can perform, it also defines the object's type. When we say that an object is a instance of a class, we imply that the object supports the interface defined by the class.
Now lets talk about Class inheritance and interface inheritance.
Class inheritance :
Class inheritance defines an object's implementation in terms of another object's implementation. In short, it's a mechanism for code and representation sharing.
Interface inheritance :
In contrast, interface inheritance ( or subtyping ) describes when an object can be used in place of another.
Reference:
1. Design Patterns, Elements of Reusable Object-Oriented Software. Author : Gang of Four ( Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides )
Comments
Post a Comment