Podobne
- Strona startowa
- McGraw.Hill,.Digital.Animation.Bible.Creating.Professional.Animation.with.3ds.Max.Lightwave.and.Maya.(2004).LiB
- Dołęga Mostowicz Tadeusz Znachor. Profesor Wilczur
- Professional Feature Writing Bruce Garrison(2)
- Professional Feature Writing Bruce Garrison(6)
- Professional Feature Writing Bruce Garrison(3)
- Configuring And Troubleshooting Windows XP Professional
- Professional Feature Writing Bruce Garrison(5)
- Tey Josephine Córka czasu
- Tolkien J.R.R Wyprawa (3)
- Corel DRAW (3)
- zanotowane.pl
- doc.pisz.pl
- pdf.pisz.pl
- asfklan.htw.pl
Cytat
Do celu tam się wysiada. Lec Stanisław Jerzy (pierw. de Tusch-Letz, 1909-1966)
A bogowie grają w kości i nie pytają wcale czy chcesz przyłączyć się do gry (. . . ) Bogowie kpią sobie z twojego poukładanego życia (. . . ) nie przejmują się zbytnio ani naszymi planami na przyszłość ani oczekiwaniami. Gdzieś we wszechświecie rzucają kości i przypadkiem wypada twoja kolej. I odtąd zwyciężyć lub przegrać - to tylko kwestia szczęścia. Borys Pasternak
Idąc po kurzych jajach nie podskakuj. Przysłowie szkockie
I Herkules nie poradzi przeciwko wielu.
Dialog półinteligentów równa się monologowi ćwierćinteligenta. Stanisław Jerzy Lec (pierw. de Tusch - Letz, 1909-1966)
[ Pobierz całość w formacie PDF ]
.10 andour UML version of Fulfill Method in Figure 4.11.Looking again at Decorator (Figure 4.10), we can see where the structure fromFulfill Method is found, in two places, with the Component class acting as theAbstractor role in both.On second thought, this is looking quite like our Objec-tifier pattern from Figure 2.2, isn t it? Good eye.This is exactly what Objectifieris the expansion of a single Fulfill Method across several concrete subclasses, as inFigure 4.12.Again, we re using the PIN for Fulfill Method, shown here in its stackedform (see Section 3.2.4) to indicate how the underlying concepts fit together.Wejust defined a design pattern that already existed in the literature, but from firstprinciples, by building it out of smaller, well-understood pieces.In Figures 4.2through 4.5, we wrapped Fulfill Method in a PINbox.We do the same wrapping ofFrom the Library of Santiago Itzcoatl Salinas ReynaComponentoperation()componentConcreteComponent Decoratoroperation() operation() component.operation()ConcreteDecoratorA ConcreteDecoratorBDecorator::operation();operation() operation()addedBehavior();addedBehavior()Figure 4.10 Decorator s usual example UML.From the Library of Santiago Itzcoatl Salinas Reyna78Chapter 4: Working with EDPs794.2 Recreating DecoratorAbstractorAbstractClassFulfill Methodoperation()operation FulfillerConcreteClassoperation()Figure 4.11 Fulfill Method definition as annotated UML.Objectifier using Figure 4.12 as the internals but omitting the diagrams in between.This gives us a PINbox for Objectifier.Taking this a step further, we can define Object Recursion as well.Recall thatwe said in Section 2.2.1 that Objectifier is a component of Object Recursion, butwe did not address what the remaining part was.We can now identify it as theTrusted Redirection EDP.Figure 4.13 shows the two patterns as UML.In combiningto form Object Recursion,FamilyHeadandObjectifierwill merge, as willConcreteObjectifierBandRedirector.Figure 4.14 shows Object Recursion in a slightly cleaner form than as introducedin the original Figure 2.3, now annotated with the PINboxes for Objectifier andTrusted Redirection.The Objectifier role from the Objectifier pattern and the FamilyHead role from Trusted Redirection are now being fulfilled by the same entity, theclass namedHandler.Likewise,ConcreteObjectifierBandRedirectorhave merged intoRecursor.This is shown more succinctly by the PIN diagramin Figure 4.15.We can now discuss Object Recursion in terms of smaller patterns and in a muchmore precise way than we could before. Object Recursion uses polymorphism,through the Objectifier pattern, to determine at runtime which type in a relatedfamily of types will handle a specific call.By applying Trusted Redirection to at leastone of the possible implementations, it also chains together two or more objectsfrom that family such that they can handle that same call in turn and bring their ownimplementation to bear. This statement is precise, it is direct, and it avoids havingto discuss the pattern in structural terms.Furthermore, if someone is unclear on theunderlying concepts, he or she can study the full pattern specifications of each ofthe subpatterns.We can leverage those specifications and definitions from the pat-terns literature to make our descriptions of higher-level abstractions and patternsmuch easier to comprehend.From the Library of Santiago Itzcoatl Salinas ReynaAbstractorClientFulfill Methodref ObjectifierFulfiller operationOperationA()OperationB()ConcreteObjectifierA ConcreteObjectifierBOperationA() OperationA()OperationB() OperationB()Figure 4.12 Objectifier UML annotated with PIN.From the Library of Santiago Itzcoatl Salinas Reyna80Chapter 4: Working with EDPsClientFamilyHeadObjectifier Objectifierrefoperation Family HeadObjectifier operation()OperationA()Trusted RedirectionConcrete Class operation OperationB()targettarget RedirectorConcreteObjectifierA ConcreteObjectifierBRedirectorOperationA() OperationA()operation() target.operation();OperationB() OperationB()Figure 4.13 Objectifier and Trusted Redirection.From the Library of Santiago Itzcoatl Salinas Reyna4.2RecreatingDecorator81handlerInitiator HandlerFamily Head operation*Trusted RedirectionmakeRequest() handleRequest()successortarget RedirectorObjectifierObjectifierTerminator RecursorConcrete Class operationhandleRequest() handleRequest()preHandleRequest()postHandleRequest()this.preHandleRequest();successor.handleRequest();this.postHandleRequest();Figure 4.14 Object Recursion annotated with PIN.From the Library of Santiago Itzcoatl Salinas Reyna82Chapter 4: Working with EDPs834.2 Recreating DecoratorObjectifier FamilyHead targetObjectifier Trusted RedirectionConcrete Class operationoperation Redirector.Figure 4.15 Object Recursion as just PIN.We composed the top half of the Decorator pattern and have just one pieceleft to go to finish our definition.The remaining concept is Extend Method, whichfills out the bottom of Decorator by extending Trusted Redirection, as shown inFigures 4.16 and 4.17.Extend Method s original behavior and recursor from ObjectRecursion merge into Decorator, tying these two smaller patterns together.4We can simplify this by reducing it again to just the PINboxes, as in Figure 4.18.Furthermore, we can always wrap and reduce this to a single PINbox indicating aninstance of Decorator, as in Figure 4.19.The role names here are taken directly fromthe participants section of the Decorator specification in the Gang of Four (GoF)text [21], with two additions: operation and componentObj.These are implicitlydiscussed in the participants section, but we make them explicit here to clarify thepieces involved.Now we have a simple, concise notation for the Decorator pattern.At thispoint, however, we can go the other way as well.We can use expanded PINboxesto increasingly expose finer granularity in Decorator by showing the underlyinghierarchy of concepts.Figure 4.20 shows Decorator as an expanded PINbox, reveal-ing its direct internal wiring.Figures 4.21 and 4.22 drill into Object Recursion andObjectifier, respectively, and finally Figure 4.23 expands Fulfill Method to the EDPlevel, at which point we can decompose no further.Decorator is now fully revealed.Each of these diagrams is equivalent to the others.So that s Decorator, and we built it with just four EDPs: Abstract Interface,Inheritance, Trusted Redirection, and Extend Method.Each is a simple concept,but together, linked in a very specific combination, they describe a fairly high-levelabstraction that is commonly found in software systems
[ Pobierz całość w formacie PDF ]