in reply to Does one encapsulate a class from itself?

Howdy!

I think your analysis is pretty well spot on. If you severely limit the place where your code relies on the underlying storage mechanism, you have less code to change when you decide to redo that mechanism. Changing from a "classic" hash-based object to an inside-out object may be a bit contrived, but adding a persistent backing store such as a database would be a plausible case. You might even go so far as to create a class to be the raw object distinct from the main class that is the public interface.

yours,
Michael
  • Comment on Re: Does one encapsulate a class from itself?