Skip to main content
1 of 1
kevin cline
  • 33.8k
  • 3
  • 73
  • 143

Is there real value in hiding the details?

Yes. By presenting abstractions we can think and program at a higher level.

Imagine modeling physical systems without calculus or matrix algebra. It's completely impractical. Similarly, if we can only program at a scalar level, we will be unable to solve interesting problems. Even relatively simple web applications can benefit greatly from abstractions like tag libs. It is much easier to insert a tag that means "address entry fields" than to repeatedly create four text fields and a select box. And if you decide to expand overseas, you can just modify the tag definition, rather than fixing every form to handle international addresses. Effective use of abstraction is what makes some programmers ten times as effective as others.

Humans have a limited working memory. Abstraction allows us to reason about large systems.

Aren't we sacrificing transparency? 

No. If abstractions are not used, then the purpose of a software component is buried in repeated details. Developers spend their days wading through code like this:

for (i = 0; i < pilgrim.wives.size(); ++i) { wife = pilgrim.wives[i]; for (j = 0; j < wife.sacks.size(); ++j) { sack = wife.sacks[i]; for (k = 0; j < sack.cats.size(); ++j) { cat = sack.cats[k]; for (m = 0; m < cat.kits.size(); ++m) { ++count; } } } } 

and thinking "oh yes another four-level loop over the kits", instead of seeing

pilgrim.kits.each { ++count; } 

Isn't this transparency valuable?

As you pointed out, there is a cost to indirection. There is no point in creating layers "just in case". Use abstraction to reduce duplication and clarify code.

kevin cline
  • 33.8k
  • 3
  • 73
  • 143