[cap-talk] "Composite", was "Same" key

James A. Donald jamesd at echeque.com
Fri Feb 16 13:00:07 CST 2007


David Hopwood wrote:
 > Anecdotally, there does seem to a class of bugs
 > involving aliasing that are avoided by writing in a
 > purely functional language or by minimizing the use of
 > mutable state, but I'm not aware of any published
 > studies on the frequency of such bugs.

If what is pointed to by pointer A can effect the
behavior of what is pointed to by pointer B, and both B
and A are active at the same time in widely separate
code, you are generally badly hosed.

 > However, this is a separate question to whether we
 > need an agreed terminology for describing abstractions
 > made up of multiple objects that share state. We
 > clearly do need this.

No we don't.

Repeating in different words:  We do not need a word for
the general pattern, for the general pattern is not
useful.  We need, and have, words for particular cases
of this pattern that *are* useful.

One such, the most common such, is "aggregation" and
"aggregate": For example one might have an object

class CBicycle {
	CHandlebar m_handlebar;
  	CWheel     m_wheels[2];
	public:
	CHandlebar& GetHandlebar(void) {
		return m_handlebar;
		}
	CWheel& GetFrontWheel(void)(
		return m_wheels[0];
		}
	CWheel& GetBackWheel(void)(
		return m_wheels[1];
		}
	 };

"Inheritance" and "aggregation", "Is a", and "has a",
are two useful patterns.  I do not see any value in
having a more general terminology that refers to both
useful patterns and dangerously bad programming the same
word.


More information about the cap-talk mailing list