DEV Community

Discussion on: Explain Abstractions like I'm five

Collapse
 
jvanbruegge profile image
Jan van Brügge

Imagine you build a shelf for your toys. You draw a sketch that leaves exactly enough space for each toy, measure the size you need and start building.
But now you realize that you can also use the Shelf for something different if you remove the vertical spacers. Now you have a more general thing. You can put anything on it without having to redesign a new shelf each time.
This can even go deeper: One day you recognize that a shelf and a box are basicly the same thing (stuff for storing other stuff). So now you can few them as a storage. You do not care how it looks like, just what it can do. But down at the bottom it is still a shelf or a Box.
This also can have disadvantages: Each Storing container lets you access its contents, but while you can just pick the stuff from a shelf, you may have to empty the box to get to the toy at the bottom. From the outer persective this is not visible and may be difficult to track down. This is called a leaky abstraction.