Skip to main content

Timeline for Why are interfaces useful?

Current License: CC BY-SA 3.0

10 events
when toggle format what by license comment
Oct 5, 2021 at 12:48 comment added carloswm85 I can think of another visual example (let me know if it makes sense to you or it doesn't). Let's say we have a theatrical play in which all personages are played by actors using masks. Now, an interface, is like those masks. I really don't care who's the actor or actual person playing the role, as long as he can use the mask an make his part in the play, know what he is doing, he'll make a good job. The interface, like the masks, hides the implementation, and only cares about the actual outcome.
Oct 10, 2019 at 9:27 comment added Ekaitz Hernandez Troyas In my opinion this response mixed with this one softwareengineering.stackexchange.com/a/145481/322231 is the best explanation of a interface. High-level modules (the electrical grid) should not depend on low-level modules (the appliances). Both should depend on abstractions (e.g. interfaces).
Sep 26, 2019 at 5:48 comment added ingredient_15939 Just pointing out this answer doesn't say - in this particular example - why using an interface would be preferable over inheritance. Someone new to interfaces might ask why they don't all just inherit from e.g. MainsPoweredDevice that provides all the plug functionality, with the socket accepting anything derived from MainsPoweredDevice.
Feb 22, 2018 at 11:29 comment added Mario Garcia This answer is just amazing...
Aug 11, 2015 at 14:28 comment added YoungJohn Jerry-rigging a device to work around the interface is not safe (but some people still do it often citing performance as an untested excuse), and likely to lead to fires.
Sep 20, 2011 at 22:17 comment added Steven Jeuris Damn, but we'll have to use an Adapter pattern in order to use the IPowerPlug in different countries!
Sep 20, 2011 at 20:21 comment added Anonymous Apple The bottom left object doesn't look like it implements IPowerPlug =)
Sep 16, 2011 at 0:54 history edited ocodo CC BY-SA 3.0
added 241 characters in body
S Sep 16, 2011 at 0:38 history answered ocodo CC BY-SA 3.0
S Sep 16, 2011 at 0:38 history made wiki Post Made Community Wiki by ocodo