Read Latex

Monday, September 13, 2010

Design Patterns vs. Components in Software Resuse

I have been pondering the dichotomy of Design Patterns vs. Reusable Software Components (RSC's). Are they they same thing, or are they opposites? RSC's are the integrated circuits of software while design patterns are reusable chunks of observable interactions that appear repeatedly. A design pattern is not an algorithm for performing some calculation. It is a higher level aggregation, often with less specificity. Thus design patterns are not themselves implementations of solutions to computational problems, or interaction scenarios. Similarity vs. Uniqueness is a controlling idea here.
- Agile Modeling

A key idea in clarifying this is to consider the difference between functional blocks of capability versus the interconnections between functional blocks. Another useful idea is that of process.  Functional blocks, at any level of aggregation can be reduced to a single idea. One has inputs to the block that produce outputs from the block. Ensembles of functional blocks can always be replaced by a single equivalent functional block that abstracts away the internal complexity of the contents. Functional blocks make mathematical and algorithmic descriptions look like circuits. In fact, a software functional block can always be replaced by an equivalent piece of hardware and vica versa. This fact has not yet been fully exploited in the current software revolution, otherwise you could buy Microsoft Word on a chip.


Imagine taking the 23 design patterns, overlaying them on each other in the 253 possible ways and asking what are the similarities and differences between them and their subsets?


These differences are largely the interconnects that glue together portions of the patterns, as opposed to the blocks of UML themselves. UML is a useless modeling language and violates my own notions of how graphical depictions of things should work, but I digress.


Resolution of the aforementioned dichotomy takes place when we look at any printed circuit board (PCB) of reasonable complexity.
- develec.com
Every PCB has the need for power, input/output channels, cooling, but these are all just functional relationships which can be and are represented as functional blocks with signals flowing between them. Some are signals we care about, some are just housekeeping, like power.


In a PCB, islands of reuseable components (IC's) are connected in higher level idioms to accomplish some design objective. If an aggreation of chips (blocks) occurs frequently enough, the ensemble is turned into a single chip, just as the abstraction of many functional blocks can be replaced by a single block.


For a given PCB, the overall pattern is unique to the purpose of the PCB, yet it is composed of functional blocks which take on familiar and reusable patterns. These patterns repeat themselves and are therefore factorable into recognizable idioms, much like the letters, words, sentences and paragraphs of what I am typing just now.


The resolution of the similarity versus uniqueness question is given by the latter analogy. This note I am writing is a unique combination of reusable letters, words and sometimes sentences. But as the specific purpose of this note is articulated in increasing detail, it becomes increasingly unique. DNA is the same way. Four reusable symbols, CTAG, code for 64 possible sets of three (CCC, CCT, CCA, etc.) to specify 20 amino acids which polymerize (yes, people ARE plastic) to form proteins, which fold into useful configurations.
- Current Protocols


At increasing levels of complexity there seems less and less likelihood of reuseability. But in biological systems this is not necessarily true. For example a complex organ like the heart can be transplanted into another individual and work well enough to sustain life.
- ScienceDaily.com


Letters and words are reusable by necessity, lest we have the burden of continually reinventing writing and therefore communicating at the letter, word and sentence level and never end up getting anything useful done. It would be interesting to devise a language in which each idea is represented as a succession of new letters. But I will leave that glorious exercise to another.

- think smart designs blog



Something like a word processing program lives at the level of a PCB, while a font chooser lives at the level of a design pattern. But we need more than font choosers to make the world go 'round!


Design patterns are reusable, but at a meta-level, since they are not concrete. When we design a GUI certain patterns have emerged. The menu's are at the top, output and status information appear at the bottom. All languages read from top to bottom so this is quite natural. Is this because we look at the face before the feet of someone who greets us?


Consider the wonderful design documentary, "Objectified" which features Machines That Make Machines (MTMM). People by the way do this, as do all living things. A beautiful design is one that can be transparent in all its aspects and still be clearly discerned. The sheet rock in most homes, hides a network of two by fours, conduits, pipes, debris behind a facade of paint and crumbling gypsum. If a design is transparent then the machines that make machines should be just as beautiful and functional as the things they are used to make. Note that machines that make machines don't do so without first being created by their creator. In the "end game" only one level of machines that make machines are necessary because, like the functional blocks abstracted, the expression ((MTMM)TMM)TMM can be rewritten as MTMM.

- Science Clarified: AI and Robotics

Consider the assembly line staffed by pick and place robots. These are MTMM's. The CNC machines that work in concert to produce pistons, connecting rods and wheels are also MTMM's. The make technical artifacts like cars, washing machines, PCB's, etc.


Sections of assembly lines which bear a similarity to each other across technical artifacts are analogous to the design patterns of software identified by the Gang of Four. The parts they create are the reusable (think green) components, which can be recycled without further dis-assembly.


A principle emerges that at low levels of complexity everything looks reusable. A molecule, a resistor, an op-amp, a nut or a bolt. As complexity escalates, uniqueness increases. Thus reuse-ability of the aggregation becomes less and less, but not always, as in the case of DNA, where long strands are evolutionarily conserved, because that is the only way that the problem could be solved.


Two categories of tasks emerge: those that are reducible to repetition and those that are not.

- world of molecules.com


- whyfiles.org