Spot a leaky abstraction

stereobooster - Jan 12 '19 - - Dev Community

Let's play a game. Who will find more leaky abstractions? I wrote about abstractions recently. To recap leaky abstraction is the one which exposes implementation details.

I will start - indexes in relational databases. The abstraction consists of relational algebra (in form of SQL), entity relational diagrams (as a way to model), normal forms, right? You modeled your database, got it to 3rd normal form, you wrote some queries - everything works ok; then it appears that some queries are slow, and you need to use EXPLAIN. It can happen that the implementation of query analyzer not ideal and you need to tweak your query a bit to make it happy, or you need to add indexes (anв you can do it without understanding what is it and how it works - some magic which makes your selects faster and inserts slower). Ok. Then you need to implement text search and you have indexes and you use LIKE "abc%" and it works fast, but LIKE "%abc%" is slow? And your reaction WTF. You start to read and it appears that indexes are BTrees data structure (typically for string columns), so you can traverse tree fast from top to bottom e.g. optimize text searches "starts with", but not "contains". At this point implementation is exposed, I need to understand how it is implemented to understand why it works the way it works. Luckily I don't need to understand how it handles concurrency or works with the file system, so it's not that bad.

Don't confuse leaky abstractions with the wrong abstraction. To recap the wrong abstraction, when you can't precisely state your problem in terms of abstraction, it means that abstraction doesn't fit, it was written with different use cases in mind or it is outdated, or requirements changed etc. For example, SQL is not suitable to store graphs (doable) and traverse graphs (really bad idea), SQL is simply the wrong abstraction for this task. Use graph database, like Neo4j; use Gremlin or Graphit instead of SQL.

It's your turn. One example per comment. Use open source projects or publicly available things as examples.

Photo by Nine Köpfer on Unsplash

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .