DOC PREVIEW
SJSU CMPE 196G - CmpE196G-G4DP-L8P1-Bhvr1
Pages 39

This preview shows page 1-2-3-18-19-37-38-39 out of 39 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 39 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 39 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 39 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 39 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 39 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 39 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 39 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 39 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 39 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

PowerPoint PresentationLesson ObjectivesBehavioral PatternsSlide 4Command Pattern: DefinitionCommand Pattern: StructureMenu ExampleMore Menu ExampleSlide 9Slide 10Command Pattern: When & Where to UseCommand FunctionsCommand Pattern: ExtensibilityCommand Pattern: ParticipantsCommand Pattern: CollaborationsCommand Pattern: Interaction DiagramCommand Pattern: BenefitsCommand Pattern: Related PatternsSlide 19Iterator Pattern: DefinitionIteration: Basic IdeaIterator Pattern: When to Use ItIterator Pattern: StructureIterator Pattern: ParticipantsIterator Pattern: CollaborationsIterator Pattern: Alternative ImplementationsIterator Pattern: Client RequirementsIterator Pattern: Developer RequirementsSlide 29Slide 30Slide 31Slide 32Slide 33Slide 34Slide 35Slide 36Slide 37Iterator Pattern: Related PatternsDiscussion QuestionsCopyright © 1995 –2004 Active Frameworks Inc. - All Rights Reserved - V2.0 Behavioral Patterns - Page L8-1PS95&96-MEF-L15-1Dr. M.E. FayadCreationalParadigm Shift, Inc.Software FactoryBehavioralStructuralLesson 8:Behavioral PatternsLesson 8:Behavioral PatternsObject-Object-OrientedOrientedDesignDesignPatternPatternssCopyright © 1995 –2004 Active Frameworks Inc. - All Rights Reserved - V2.0 Behavioral Patterns - Page L8-2PS95&96-MEF-L15-2Dr. M.E. FayadLesson ObjectivesLesson ObjectivesObjectivesDiscuss the philosophy behind behavioral patternsExplore the world of behavioral patternsPresent the following Patterns:CommandIteratorCopyright © 1995 –2004 Active Frameworks Inc. - All Rights Reserved - V2.0 Behavioral Patterns - Page L8-3PS95&96-MEF-L15-3Dr. M.E. FayadBehavioral Patterns•Behavioral patterns characterize the ways in which classes and objects interact and distribute responsibilities•Behavioral class patterns capture how classes cooperate with their subclasses to fulfill their semantics–Example: Template Method pattern•Behavioral object patterns describe how a group of peer objects cooperate to perform a task that no single object can carry out by itself–Examples: Mediator, Observer, Command, and Strategy•Behavioral compound patterns deal with behavior in recursive object structures–Examples: IteratorCopyright © 1995 –2004 Active Frameworks Inc. - All Rights Reserved - V2.0 Behavioral Patterns - Page L8-4PS95&96-MEF-L15-4Dr. M.E. FayadBehavioral PatternsCommand Pattern•Topics–Command Definition–Structure–Menu-Command Example–Problems it Solves–Participants & Collaborations–Benefits–Related PatternsCopyright © 1995 –2004 Active Frameworks Inc. - All Rights Reserved - V2.0 Behavioral Patterns - Page L8-5PS95&96-MEF-L15-5Dr. M.E. FayadCommand Pattern: Definition•Define an object that encapsulates a request. This is useful for:–Configuring objects with different requests–Implementing undoable operations–Queuing or logging requests•The requestor should not be required to:–Have specific knowledge of the request–Handle any dependencies that may be required to execute the request–May or may not specify the target of the request•Command pattern is also known as Action or TransactionCopyright © 1995 –2004 Active Frameworks Inc. - All Rights Reserved - V2.0 Behavioral Patterns - Page L8-6PS95&96-MEF-L15-6Dr. M.E. FayadCommand Pattern: Structuretarget->Action();TargetAction()ConcreteCommandExecute()CommandExecute()ClientInvokerstatetargetCopyright © 1995 –2004 Active Frameworks Inc. - All Rights Reserved - V2.0 Behavioral Patterns - Page L8-7PS95&96-MEF-L15-7Dr. M.E. FayadMenu Examplecommand->Execute();MenuAdd(MenuItem)DocumentOpen()Close()Cut()Copy()Paste()CommandExecute()commandMenuItemClicked()ApplicationAdd(Document)Document(Current)• Manus can be implemented easily with Command objects• Each choice in a Menu is an instance of a MenuItem class• An Application class creates these menus and their menu items along with the rest of the user interfaceThe Application class also keeps track of Document objects that a user has opened• Manus can be implemented easily with Command objects• Each choice in a Menu is an instance of a MenuItem class• An Application class creates these menus and their menu items along with the rest of the user interfaceThe Application class also keeps track of Document objects that a user has openedCopyright © 1995 –2004 Active Frameworks Inc. - All Rights Reserved - V2.0 Behavioral Patterns - Page L8-8PS95&96-MEF-L15-8Dr. M.E. FayadMore Menu Exampledocument->Paste();PasteCommandExecute()DocumentOpen()Close()Cut()Copy()Paste()CommandExecute()document• Command subclasses store the target of the request and invoke one or more specific requests on the target. For example, PasteCommand supports pasting text from the clipboard into a Document• PasteCommand’s target is the Document object it is supplied upon instantiation• The execute operation invokes Paste on the target Document• Command subclasses store the target of the request and invoke one or more specific requests on the target. For example, PasteCommand supports pasting text from the clipboard into a Document• PasteCommand’s target is the Document object it is supplied upon instantiation• The execute operation invokes Paste on the target DocumentCopyright © 1995 –2004 Active Frameworks Inc. - All Rights Reserved - V2.0 Behavioral Patterns - Page L8-9PS95&96-MEF-L15-9Dr. M.E. FayadMore Menu Examplename = AskUse()doc = new Document(name)application->Add(doc)doc->Open()OpenCommandExecute()AskUse()CommandExecute()applicationOpenCommand’s Execute operation: • Prompts the user for document name• Creates a corresponding Document’s object• Adds the document to the target application• Opens the documentOpenCommand’s Execute operation: • Prompts the user for document name• Creates a corresponding Document’s object• Adds the document to the target application• Opens the documentApplicationAdd(Document)Document(Current)Copyright © 1995 –2004 Active Frameworks Inc. - All Rights Reserved - V2.0 Behavioral Patterns - Page L8-10PS95&96-MEF-L15-10Dr. M.E. FayadMore Menu Examplefor all c in commandsc->Execute();MacroCommandExecute()CommandExecute()commands• MacroCommand is a concrete command subclass that simply executes a sequence of commands• MacroCommand has no explicit target, because the commands it sequences define their own target• MacroCommand is a concrete command subclass that simply executes a


View Full Document

SJSU CMPE 196G - CmpE196G-G4DP-L8P1-Bhvr1

Download CmpE196G-G4DP-L8P1-Bhvr1
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view CmpE196G-G4DP-L8P1-Bhvr1 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view CmpE196G-G4DP-L8P1-Bhvr1 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?