When programming some tasks require changing an implementations, whereas others require using an interface. While they are related, the differences are presented below:
| Implementation | Interface |
| How something works | How something is used |
| E.g., add a method to push an element onto a stack | E.g., use a method to push an element onto a stack |
Example implementation
// implement the push method
Stack.prototype.push = function(elt) {
this.items.push(elt);
}
|
Example interface use
var stack = new Stack(); // use the push method stack.push(13); |
| Concrete | Abstract |
| Details exposed | Details are hidden |
| Usually difficult | Usually easier |