So, Component Is-A Container. This would be a significant differentiation feature...
Yes Jim, I think we need to find "differentiation features" between the different constructs to enable us to create better models. I don't have the attributed quote with me at present, but it goes along the lines of:
"All models are wrong, but some are useful..." We should therefore strive to produce more useful models.
Container objects are designed to hold other objects, including other containers, without concern for the types of objects being contained.
Just so... In general at least, but there are some conditions, from time to time... A colander isn't much use for holding liquids. Sometimes the nature of what you wish to hold imposes constraints on the container. For example, a Source (logical) Component doesn't hold binaries. I have found a way to handle these constraints between the container and contained by means of Policies and Policy Implementations that act as "enforcers" of stereotypical behaviour.
Other objects may access the contained objects freely. Contained objects are not hidden.
Here, my view is that both these behavioural aspects are managed by the types of policies that may be applied to the container and contained. One could certainly argue that (by default) contained objects are public, but I don't think there is a requirement of it to be so.
A composite is composed of other objects, but the typing of those objects is restricted specific types and outside objects normally do not have access to them. Component objects are normally private.
Now this is where things get interesting, in my view. From meronymy we learn that the "composition" works both ways... The set of types of the composition is governed by the composed object (parent). But also the type of the composed object is determined by the types of the composing objects. In my recent musing on this subject, when we look at a composed objects, we need to distinguish between those components that are essential to the composition and those that are just optional adornments. Over twenty years ago I created the problem of the yellow Rolls Royce: "I have before me a red Mini, I change one panel/part. Do I still have a Mini? I keep changing panels/parts until I have before me what looks like a yellow Rolls Royce. At what point did I stop being a Mini and become a Roller?" Answering that question often provides an insight into what is actually going on.
In other words, look at what is essential and what is adornment, for determining the composition.
Containers (ergo, components) hold collections, composites own their parts.
Am I getting closer?
Since you seem to like my shorthand, here's some ideas:
Containers hold things. They have to be able to hold the kinds of items you need to put in them.
The types of things held in containers are usually (but certainly not exclusively) not of the same type as the container.
The types of the contained items do not define the container.
Each item can be on only one container at a time. (The item can only be inside the innermost container)
The item needs to know which container it's in.
The container may hide (some or all) the items.
Destroying the container doesn't necessarily destroy the contained items (but often may).
Destroying the contained items never destroys the container.
All containers define collections (even if only implicitly - the objects contained)
Not all collections are containers.
Collections collect(group) things. They have to be able to collect the kinds of items you need to add to them.
The types of things held in collections are not of the same type as the collection.
The types of the collected items do not define the collection.
An item can be in more than one collection at the same time.
Often the item knows which collections it's in, but sometimes it doesn't.
The collection can never hide the item.
Destroying the collection never destroys the items.
Destroying the items doesn't necessarily destroy the collection, but may.
Composite objects define the types of the components.
The types of the components define the composite (some types are there for adornment and are not intrinsically part of the composite).
A component can only be in one composition at a time.
The composite may hide (some or all) the components.
Destroying the composite always destroys the components.
Destroying the components destroys the composite.NOTE: in all cases, the items can be removed from the container/collection/composite. It may be a policy to allow an item to self-remove.
Does that help things? You should find a clear set of differentiators to allow you to work out which kind of thing you are dealing with.
NOTE; this is still a work-in-progress. Feedback most welcome - especially where mistakes have been made. I'm just as eager to get this right as the next...
Cheerz,
Paolo
[size=0]©2005 Paolo Cantoni, -Semantica-[/size]