http://qs321.pair.com?node_id=84808


in reply to (Software Engr) Encapsulate! No,no,no! Decouple!

I've found that, in general, encapsulation improves decoupling. I don't think your example is exactly the best example of the desire for either, though; it's more about packaging config information. Most of the discussion in SW engineering circles about encapsulation and decoupling has to do with actual program architecture.

Anyway, encapsulation lets us hide the nasty little details inside our modules (or classes, or whatever other mechanisms for encapsulation we have available). By not exposing the nasty little details (like, for instance, object data or internal methods), nothing outside can depend on them. So the coupling between your module and users of that module can be reduced.

The two principles aren't really at odds with each other.

  • Comment on Re: (Software Engr) Encapsulate! No,no,no! Decouple!