Timeline for Understanding "programming to an interface"
Current License: CC BY-SA 3.0
4 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 4, 2016 at 18:47 | history | edited | Encaitar | CC BY-SA 3.0 | added 8 characters in body |
| Mar 14, 2014 at 13:14 | history | edited | Encaitar | CC BY-SA 3.0 | added 253 characters in body |
| Mar 14, 2014 at 12:20 | comment | added | Doval | A benefit that's usually overlooked is locality of errors. Say you need a Map, and you implement it using a binary tree. In order for this to work, the keys need to have some ordering, and you need to maintain the invariant that keys that are "less than" the current node's key are on the left subtree, while those that are "greater than" are on the right subtree. When you hide the implementation of the Map behind an interface, if a Map lookup goes wrong you know the bug must be in the Map module. If it's exposed, the bug could be anywhere in the program. To me, this is the main benefit. | |
| Mar 14, 2014 at 11:58 | history | answered | Encaitar | CC BY-SA 3.0 |