Podstrony
- Strona startowa
- Victor Sperandeo Trader Vic II Principles.of.Professional.Speculation.(1998)
- Dolęga Mostowicz Tadeusz Znachor. Profesor Wilczur
- Szklarski Alfred Sobowtor profesora Rawy (SCAN d
- Professional Feature Writing Bruce Garrison(3)
- Zelazny Roger & Sheckley Robert Przyniescie mi glowe ksiecia
- brantome Żywoty pań swowolnych (2)
- § Thomas Craig Niedzwiedzie lzy
- Czarnecki Piotr Koncepcja umyslu w filozofii De
- Potocki Jan Rekopis znaleziony w Saragossie (2)
- Potocki Jan Rekopis znaleziony w Saragossie
- zanotowane.pl
- doc.pisz.pl
- pdf.pisz.pl
- odbijak.htw.pl
[ Pobierz całość w formacie PDF ]
." broadcasting a message to all nodes in part of a linked structure." distributing a behavior s responsibility throughout a linked structure [41, p.44].It s interesting to note that if we were to limit the applicability to onlythese constraints, the problem would be solvable without using the solutionthat Woolf provided.Specifically, nothing in the applicability addresses therelative intents of the behavior that is distributed or the level of trust thatthe objects can place in each other to perform that behavior.The aboveconstraints, as stated, could just as easily be handled by a chain of unrelatedobjects through uses of Redirection, or, with a bit of creative interpretationof the criteria, Delegation.From the information in the Intent and Motivation sections, we candeduce some other key characteristics of Object Recursion and enhancethis section.For instance, we know that polymorphism will figure promi-nently and that the linked structure described previously likely has somevery specific requirements, primarily that the linked structure is com-posed of objects whose types are related to one another via a commonancestor, as evidenced by the polymorphism mentioned in the Intent sec-tion.This assumption is borne out by the later sections in the originalspecification.This common ancestor clue leads us to expect to see the subtyping-relation form of our Redirection.In other words, we can specify that insteadof a generalized Redirection, we will expect to see Trusted Redirection.Using this information, we can refine the applicability as follows:" A linked structure such as a tree exists, and the elements in thestructure have a shared intent and purpose, each with commondefined behaviors.From the Library of Santiago Itzcoatl Salinas Reyna253Chapter 6: Intermediate Pattern Compositions" A message needs to be sent through this linked structure to invokeone of the common behaviors; the intent of the message needs toremain essentially unaltered in intent during passage." The ultimate destination of the passed message is unknown withinthe linked structure." The message may need to be broadcast to all nodes in just a portionof the linked structure." Responsibility for fulfilling the behavior requested by the message isdistributed throughout the linked structure.Now it is clear that the linked structure does not contain random ele-ments, but each node in the structure is related in nature and intent.Itis also clearly stated that common behaviors can be invoked, that behav-ior can be distributed through objects in the structure, and/or that thebehavior may or may not be applicable to the entire structure.All of thesepoints are important for shaping what the solution will eventually looklike.StructureWe can use these deductions during an inspection of the original UMLdiagram provided by Woolf and annotate it with PINboxes, as shown.TheObjectifier and Trusted Redirection instances do exist, as we surmised.ParticipantsWoolf s original specification lists four participants: Initiator, Handler,Recursor, and Terminator.To these, we can add two more for the struc-ture PIN diagrams and for clarity in the discussion: handleRequest andsuccessor.The participants then can be listed as:Initiator initiates the request. usually not a subtype ofHandler;makeRequest()is a separate messagefromhandleRequest().Handler defines a type that can handle requests that initiators make.Recursor defines thesuccessorlink. handles a request by delegating it to its successors.From the Library of Santiago Itzcoatl Salinas ReynaTerminator Initiator HandlerObject RecursionInitiatorhandlerHandler*makeRequest()handleRequest()successorObjectifierObjectifierTerminator RecursorConcrete Class operationhandleRequest() handleRequest()BackgroundpreHandleRequest()postHandleRequest()this.preHandleRequest();successor.handleRequest();Family Head operationthis.postHandleRequest();Trusted Redirectiontarget RedirectorhandleRequest Recursor successorFrom the Library of Santiago Itzcoatl Salinas Reyna254Chapter 6: Intermediate Pattern Compositions255Chapter 6: Intermediate Pattern CompositionsWe can reduce this down to a much more readable PINbox-only version:Terminator Initiator HandlerObject RecursionObjectifierObjectifierConcrete Class operationBackgroundoperation Family HeadTrusted RedirectionRedirector targethandleRequest Recursor successor successors relevant to a request can vary by request. can perform extra behavior before or after delegating the request. may be a terminator for a different request.Terminator finishes the request by implementing it completely and not delegating any of itsimplementation. may be a recursor for a different request [41, p.44].handleRequestThe method that handles the requested behavior at each stage and isresponsible for passing it along to a successor as necessary.successorThe object that receives thehandleRequestmessage from aninstance ofRecursor;it is of typeHandler.CollaborationsAdding PINboxes to the original UML sequence diagram lets us see theexact demarcation between the responsibilities of Objectifier and TrustedRedirection in implementing the behavior of Object Recursion.Each is tak-ing half of the sequence diagram, and they meet in theaRecursorobject.From the Library of Santiago Itzcoatl Salinas Reyna256Chapter 6: Intermediate Pattern CompositionsConcrete Class operation Family HeadObjectifier Trusted Redirectionoperation Objectifier Redirector targettype of type ofsuccessorhandleranInitiator aRecursor aTerminatormakeRequest()handleRequest()preHandleRequest()handleRequest()postHandleRequest()ConsequencesThe one disadvantage that Woolf lists under Consequences is: Program-ming complexity.Recursion, procedural or object-oriented, is a difficultconcept to grasp.Overuse can make a system more difficult to understandand maintain [41, p.46].While true, the situation can be clarified bydividing the two essential elements of this style of recursion into the struc-ture of the polymorphism via Objectifier and the recursive-style call intothat polymorphic system via Trusted Redirection.Now the two aspects ofthis distributed recursion technique are explicitly shown, aiding compre-hension.ImplementationThe original Object Recursion specification states in its Implementation sec-tion that The Initiator.makeRequest() message must not be polymorphicFrom the Library of Santiago Itzcoatl Salinas Reyna257Chapter 6: Intermediate Pattern Compositionswith the Recursor.handleRequest() message [41, p.47]
[ Pobierz całość w formacie PDF ]