What is abstract leakage

This concept comes from The blog of Joel Spolsky (The Law of Leaky Abstractions — Joel on Software). The article goes from the TCP encapsulation that makes IP stable and reliable, to the “abstract encapsulation that makes good design”, to the fact that if the data transmission is no longer stable, the user has to go deep down (even down to the physical layer to check if a pet snake has bitten through the network cable) to fix the problem. “Abstract encapsulation will always leak, we have to spend more effort and learn more knowledge to eliminate the problem.”

Let’s take a simpler example, if we’re going on a long trip, the bottom line is to use your feet. At this point, we came up with a great abstraction — a BMW car, which encapsulates the concepts of wheels, seats, engine, etc., and gives us simple ways to use them (driving, turning, parking, etc.) to make the journey fast and comfortable. But at some point there will be an abstract leak — a broken part that will break down, and we’ll have to find an engineer who knows the entire system to fix it. Because we have no knowledge of this high-level abstraction, although the solution is simply to “replace a (b) (4) part.”

The modern world operates on abstraction, and abstraction makes our lives extremely convenient. In the case of “Going to Work,” the subway company encapsulates the journey and the plan so that you only need to swipe the card twice and you don’t need to know how it works. But once there is a problem with the abstraction, and the subway stops running one day for some reason, solving the problem requires a lot of systematic knowledge to go through all the details.

Programming impact

One of the biggest misconceptions about the front end is that understanding an MVC framework, such as Vue, is all you need to do. Vue encapsulates HTML, JS and CSS into files with fixed structure, and the complicated DOM binding and operation are abstracted into simple data assignment. Does that mean, look at the documentation and run the TodoList demo to get to work?

Of course not. As mentioned earlier, there must be leakage in the abstraction. Buttons need to be debuffed, components nested without bubbling, and when that happens, we have to go back to the low-level knowledge of timer threads and event mechanisms. Even the principles of Vue, such as the array binding is not updated, and how to implement the long-press instruction scenario, force us to learn its system mechanism.

As a result, even as abstract encapsulation becomes more advanced, learning to program is not necessarily easier.

Inspired by the

  • Abstract can make our life convenient.
  • More and more advanced tools will be available that will save the laborious detail and make development faster. At the same time, we must master the internal mechanism of abstraction, and the underlying principles of knowledge, in order to deal with abstract leakage. This makes debugging and maintenance difficult.
  • Abstraction makes the division of labor clear. The front and back ends are hard to interchangeable, and full-stack engineers become scarce.
  • Abstract leaks make programming easier to learn but harder to master.