This page contains a Flash digital edition of a book.
       


CompositeAsset>>containsSecurity: aSecurity "See superimplementor."


"See if one of the assets is aSecutiry." self assets


detect: [ :asset | asset containsSecurity: aSecurity] ifNone: [^false].


^true


This improved implementation of containsSecurity: is an example of Chain of Responsibility, as is the implementation of value. Notice that implementors in Com- posite should use Chain of Responsibility, that the problem with the original implemen- tation of containsSecurity: is that it used includes: and so did not use Chain of Responsibility.


Known Smalltalk Uses Collection


Collection itself is the ultimate example of the Composite pattern in Smalltalk, and also the least useful. It implements the pattern with the Component class (Object), the Composite class (Collection), and numerous Leaf classes (all other subclasses of Object). An element in a Collection can be another Collection.


Object defines operations that Collection reimplements as composite operations. For example, Object defines printString to display the receiver’s class. Collection reimplements it to display not just the Collection’s class, but also the printStrings of the elements in the Collection. However, Object does not have a very customized interface, so neither does Collection. This


is the least


domain specific example of the Composite pattern. Visuals


The major Smalltalk dialects use the Composite pattern to implement their windowing systems, as discussed earlier. Field Format Descriptions


The File Reader (Woolf, 1997) reads record-oriented flat files by reading each record one field at a time, as discussed earlier. The ability of a group of fields to act like a sin- gle field is an example of the Composite pattern. It is implemented with three classes: FieldFormatDescription (Component)


and two subclasses, LeafField-


Format (Leaf) and CompositeFieldFormat (Composite). Media Elements


The Composite pattern is used in EFX, a digital video editing and special effects envi- ronment (Alpert et al., 1995), to uniformly represent aggregate and primitive media elements. EFX’s user interface incorporates a horizontal timeline for specifying the


16 04/23/97 08:53





Page 1  |  Page 2  |  Page 3  |  Page 4  |  Page 5  |  Page 6  |  Page 7  |  Page 8  |  Page 9  |  Page 10  |  Page 11  |  Page 12  |  Page 13  |  Page 14  |  Page 15  |  Page 16  |  Page 17  |  Page 18  |  Page 19  |  Page 20  |  Page 21  |  Page 22  |  Page 23  |  Page 24  |  Page 25  |  Page 26  |  Page 27  |  Page 28  |  Page 29  |  Page 30  |  Page 31  |  Page 32  |  Page 33  |  Page 34  |  Page 35  |  Page 36  |  Page 37  |  Page 38  |  Page 39  |  Page 40  |  Page 41  |  Page 42  |  Page 43  |  Page 44  |  Page 45  |  Page 46  |  Page 47  |  Page 48  |  Page 49  |  Page 50  |  Page 51  |  Page 52  |  Page 53  |  Page 54  |  Page 55  |  Page 56  |  Page 57  |  Page 58  |  Page 59  |  Page 60  |  Page 61  |  Page 62  |  Page 63  |  Page 64  |  Page 65  |  Page 66  |  Page 67  |  Page 68  |  Page 69  |  Page 70  |  Page 71  |  Page 72  |  Page 73  |  Page 74  |  Page 75  |  Page 76  |  Page 77  |  Page 78  |  Page 79  |  Page 80  |  Page 81  |  Page 82  |  Page 83  |  Page 84  |  Page 85  |  Page 86  |  Page 87  |  Page 88  |  Page 89  |  Page 90  |  Page 91  |  Page 92  |  Page 93  |  Page 94  |  Page 95  |  Page 96  |  Page 97  |  Page 98  |  Page 99  |  Page 100  |  Page 101  |  Page 102  |  Page 103  |  Page 104  |  Page 105  |  Page 106  |  Page 107  |  Page 108  |  Page 109  |  Page 110  |  Page 111  |  Page 112  |  Page 113  |  Page 114  |  Page 115  |  Page 116  |  Page 117
Produced with Yudu - www.yudu.com