Thinking in Patterns with Java V0.9: Chapter 11: Flexible structure: TIPatterns.htm#_Toc41169735
1, Sections:
Composite
2, The main content and feeling:
At first, the meaning of "Composite" has confused me a little. There is a
"Composition" and "Aggregation" terms in UML. And, I thought "Composite" in
GoF's design patterns as the "Composition" in UML. At last, I have known these
two terms are all totally different.
Here, I don't give the explaination of "Composition" term in UML, you can get
it at our site:
http://java.learndiary.com/disDiaryContentAction.do?goalID=1345
I understood the meaning of "Compostion" after reading the example://:
composite:CompositeStructure.java. The key is: The node and its child node has
the same operations, "and that performing an operation on a node/composite
also performs that operation on any children of that node/composite."
Just like an orgernization, there are some partions under this orgernization,
and alse maybe there are lower partions under the orgernization's partion.
When the leader of orgernization say: do(it), the entire orgernization start a
mission just "do(it)". Then, every partions of
orgernization and the lower partions of the orgernization's partion will also
perform this "do(it)" mission. But, the detail of "do(it)" in all these level
isn't same.
And, there is a point about "passing parameter to a java method" need be
noted.
See the code part below:
|
At Step 2, a duplicated copy of the address of object created at Step 1 passed
into method add(); and, the reference "c2" point to a new object, again,
another object's address be duplicated into the method add() at Step 4. Note,
the object pointed by "c2" at Step 2 will can't be changed by a new object to be
pointed by "c2".
If you are confused with the "passing parameter into a java method" like
above, maybe, an article of mine titled with "Understanding Assignment and
Passing Parameters in Java with Term 'Stack Date Copy'" posted at:
http://java.learndiary.com/disDiaryContentAction.do?goalID=2716 can help you to understand it.
3, Questions about programming:
4, Questions about english language:
1), Strange words:
part-whole, containment, visitation,
2), Difficult sentences:
1>, The important thing here is that all elements in the part-whole have
operations, and that performing an operation on a node/composite also performs
that operation on any children of that node/composite.
incomplete