Hacker News new | past | comments | ask | show | jobs | submit login

I was introduced to the concept of "Dont' hide power" by Tanenbaum OS book (although it seems that Lampson is actually the original source [1]).

It always seemed to me a good design rule, but, even after 10 years of professional programming, it never actually clicked until last year.

I had always rigorously applied encapsulation, decoupling and information hiding, exposing only the minimal interface necessary to do the job [2].

While this lead to elegant designs which might be even efficient, from experience is makes them hard to extend. You might need access to some implementation detail of a lower level layer to either simplify the system or improve performance but you either violate encapsulation, break existing interfaces (violating the open-close principle), implement the higher level directly inside the lower level (this is very common), or simply leave with the inferior implementation.

I've now given up on complete encapsulation, I expose as much implementation details as possible, hiding only what's necessary to preserve basic invariants, and pushing abstractions only on the consumer side of interfaces.

Paraphrasing Knuth, premature generalization is the root of all evil.

[1] http://www.vendian.org/mncharity/dir3/hints_lampson/

[2] these are common rules for OO designs, but by no mean restricted to it. In fact very little of what I've worked on could be called OO.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: