Re: understand the concept of interfaces



Prejith wrote:
if interface is just emply methods then what is
the point of having those empty method names under one tag..

Because an interface is kind of like a contract about the contents of the implementing classes. That is, the classes implementing a particular interface can be relied on to have at least the methods defined in the interface. For example, all ActionListeners have the ActionPerformed(ActionEvent e) method, which makes it possible to handle them all in the same way by invoking the said method. What the ActionListener is supposed to actually do when the method is invoked is left for the programmer to decide.

--
-Aki Laukkanen
.



Relevant Pages

  • Re: creaping coupling......
    ... but it is a more strict contract than required. ... Then its interface becomes decoupled from B's interface. ... >> efficient code the compiler should know the size of the objects in advance. ... the shop chickens need to get a method "sell", ...
    (comp.object)
  • Re: creaping coupling......
    ... but it is a more strict contract than required. ... I.e. whether private ... >> the compiler very complicated and the code very inefficient. ... > interface itself, its not its business to do this. ...
    (comp.object)
  • Re: [ckrm-tech] [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
    ... make good use of a file system like hierarchy for their interface. ... It probably doesn't benefit all metered classes, ... based on the skbuf's tag. ...
    (Linux-Kernel)
  • Re: [DISCUSSION] Die richtige Verwendung von Compareable ist... !?
    ... Der Contract legt explizit fest, ... Interface der Form ... implementieren ist, dass es sehr selten angebracht ist, und dass ... Subklassen dabei eine hervorragende Moeglichkeit bilden, ...
    (de.comp.lang.java)
  • Re: implementing roles in OOP......
    ... > That's why large portions of the computing space (e.g., linkers, ... it is also quite complex so automation takes awhile. ... The state pattern defines how an object will implement it's contract ... i.e. each state implements the same interface. ...
    (comp.object)