metamerist

Wednesday, July 20, 2005

The Measure of Encapsulation

I believe encapsulation is one of the most important principles in system design, and I don't feel it is given enough emphasis in the area of software engineering. These days it seems encapsulation is presented merely as an ancillary benefit of object-oriented programming, as opposed to object-oriented programming being a means of building well-encapsulated systems.

In discussing encapsulation with fellow software engineers, I often use an analog alarm clock as an example. It has three inputs and three outputs: knobs used to set times, a lever to turn the alarm on and off, hands to indicate the time and the alarm time, a bell to sound the alarm.

The vast majority of moving parts are inside the clock; they are inaccessible and hidden inside the black box as they should be, because exposing them can only lead to unnecessary complexity, confusion and trouble. So it is with a clock, so it should be with software components.

The other day I started wondering if there have been any attempts to quantify the degree of encapsulation in a system. I have never heard of anything like this. When considering a system, one might compare the number of external degrees of freedom (inputs and outputs) to some measure of internal complexity. The latter part might be most difficult to quantify. In the case of the clock, it might be the number of individual moving parts. I dunno.

I wonder if any disciplines attempt such quantifications. If you stumble onto this post and you can know of any instances, please make a comment.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home