Decoupling and Encapsulation: how do they interplay

Submitted by metaperl on Sat, 08/20/2005 - 6:38am.

I recently found a fascinating job but was dismayed when they said they expected people to use HTML::Mason (a jsp/could-fusion/php-like embedded HTML generator for Perl) and MySQL. Instead of verbalizing my dismay, I decided to finally write the ultimate document on why inline HTML generation and MySQL are Bad Choices ... that's right

In doing so,I had to be tongue in cheek about one thing. I value decoupled program elements and that's why I like Haskell... it gives one maximum ability to define small pieces and maximum operators for flexible composition, allowing one to form complex computation strategies from small, well-tested, well-understood pieces.

Of course, the problem becomes: decoupling means that you have weaker encapsulation.

So we arrive at the battle of the buzzwords... which is better: decoupled program elements or encapsulated ones?

Submitted by Cale Gibbard on Mon, 08/22/2005 - 7:58am.

Perhaps I misunderstand what you mean by "decoupling", but it would seem to me that encapsulation is just a technique to try to achieve decoupling of program elements. Basically, by forcing various parts of the program to use a well-defined interface to a particular component, one is reducing or eliminating the potential for those other parts of the program to depend on the internal implementation of the component.

This means that the internals of an encapsulated component are decoupled from everything outside the component.

So I'm not really sure what you mean when you say that decoupled program elements lead to weaker encapsulation -- perhaps it is just that if program elements are already decoupled for some other reason, less explicit encapsulation is necessary.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.