you see this same concept in OOP as well.An interface enables you to specify that an object s capable of performing a certain function,but it does not necessarily tell you how the object does so.An interface is a contract between unrelated objects to perform a common function.An object that implements this interface is guaranteeing to its users that it is capable of performing all the functions defined by the interface specification .Bicycle and footballs are totally different things; however ,object representing those items in a sporting goods store inventory system must be capable of interacting with that system.
By declaring an interface and then implementing it in your objects,you can hand completely different classes to common functions.The following example shows the rather prosaic door-and-jar analogy.
By declaring an interface and then implementing it in your objects,you can hand completely different classes to common functions.The following example shows the rather prosaic door-and-jar analogy.
No comments:
Post a Comment