How to look at encapsulation
Eber Irigoyen has a post about what should I hide?, based on advice from Code Complete 2. Eber is making the statement that the question should be reversed. What should I expose?
On the face of it, it looks like a reasonable suggestion, after all, I assume that we all accept that encapsulation is a good thing. The problem is that this completely ignore the notion of extensibility. It only give you the extensibility that you think of ahead of time. For examples of where this approach fail, just look at caching & batching in .Net. In both cases, the approach of show just what you must is used, and this make both completely useless for any scenario that you didn't think when creating the code.
Comments
Comment preview