logging in or signing up Distributed Design Pattern elfuchs Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINT lite Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 699 Category: Entertainment License: All Rights Reserved Like it (0) Dislike it (0) Added: August 31, 2008 This Presentation is Public Favorites: 0 Presentation Description No description available. Comments Posting comment... Premium member Presentation Transcript Distributed Patterns : Distributed Patterns Slide 2: 2 31/03/03 Factory And Code Generation : 3 31/03/03 Factory And Code Generation Print() Factory And Code Generation : 4 31/03/03 Factory And Code Generation Print() Factory And Code Generation : 5 31/03/03 Factory And Code Generation Print() Factory And Code Generation : 6 31/03/03 Factory And Code Generation Print() Factory And Code Generation : 7 31/03/03 Factory And Code Generation Print() The GOF Abstract Factory Design Pattern : 8 31/03/03 The GOF Abstract Factory Design Pattern *GoF stand for Gang of Four. It refers to the famous books of John Vlissides, Erich Gamma, Richard Helm, Ralph Johnson. Design Patterns: Elements of Reusable Object-Oriented Software. Factory And Code Generation : 9 31/03/03 Factory And Code Generation Create Generated Printer Factory Slide 10: 10 31/03/03 Example 3: The problem is in the User Input : 11 31/03/03 Example 3: The problem is in the User Input Exit Coordination State A: NIL_EXIT_STATE,B: FLIGHT_ACTIVATION_PROPOSAL,C: FLIGHT_ACTIVATION_ALARM,D: FLIGHT_ACTIVATION_CONFIRMED,E: HANDOVER_TRANSFERED,F: COORDINATION_TERMINATED,G: UNKNOWN_EXIT_STATE Enter Exit Coordination State => Replace case and enum by object . : 12 31/03/03 Replace case and enum by object . enum ExitCoordinationState { NIL_EXIT_STATE, FLIGHT_ACTIVATION_PROPOSAL, FLIGHT_ACTIVATION_ALARM, FLIGHT_ACTIVATION_CONFIRMED, HANDOVER_TRANSFERED, COORDINATION_TERMINATED, UNKNOWN_EXIT_STATE } structural switch : 13 31/03/03 structural switch static void printsStatus(int status) { switch(status) { case NIL_EXIT_STATE : processing 1 case FLIGHT_ACTIVATION_PROPOSAL: processing 2 case FLIGHT_ACTIVATION_ALARM: processing 3 case FLIGHT_ACTIVATION_CONFIRMED: processing 4 case HANDOVER_TRANSFERED, processing 5 case COORDINATION_TERMINATED, processing 6 case UNKNOWN_EXIT_STATE processing 7 } } Polymorphism : 14 31/03/03 Polymorphism Print() Polymorphism : 15 31/03/03 Polymorphism Print() Polymorphism : 16 31/03/03 Polymorphism Print() Factory Pattern : 17 31/03/03 Factory Pattern Print() Factory Pattern : 18 31/03/03 Factory Pattern The switch is now hidden in the object state factory. The factory returns a new object of the right derived class by using a switch case on the state integer code. The client always sees the root class object type Status. Each state object knows how to manage client invocation in its own case. Factory pseudo code : 19 31/03/03 Factory pseudo code static Status create(int status) { switch(status) { case NIL_EXIT_STATE : return status = new nil_exit_state(); break; case FLIGHT_ACTIVATION_PROPOSAL: return status = new flight_activation_proposal(); break; case FLIGHT_ACTIVATION_ALARM: return status = new flight_activation_alarm(); break; case FLIGHT_ACTIVATION_CONFIRMED: return status = new flight_activation_confirmed(); break; case HANDOVER_TRANSFERED, return status = new handover_transfered(); break; case COORDINATION_TERMINATED, return status = new coordination_terminated(); break; case UNKNOWN_EXIT_STATE return status = new unknown_exit_state(); } } New Object Factory Singleton : 20 31/03/03 Factory Singleton Print() Static Class Method Factory Finder : 21 31/03/03 Factory Finder In CORBA factory apply the singleton pattern Based on factory finder Factory finder provides named based factory access using naming service. Slide 22: 22 31/03/03 Dynamic Polymorphism : 23 31/03/03 Dynamic Polymorphism Static polymorphism (Factory) State machine Pattern State creates one object for each state and uses polymorphism to enable transparent client invocation. Dynamic Polymorphism State Pattern (from the GoF) : 24 31/03/03 State Pattern (from the GoF) GoF stand for Gang of Four. It refers to the famous books of Vlisside and Co. Design Patterns: Elements of Reusable Object-Oriented Software. State model transformation : 25 31/03/03 State model transformation State diagram : 26 31/03/03 State diagram HelloState A State B HelloState C HelloState D Request() Request() Request() Request() structural switch : 27 31/03/03 structural switch static void printsState(int state) { switch(state) { case stateA : System.out.println( "stateA"); break; case stateB : System.out.println( "stateB"); break; case stateC : System.out.println( "stateC"); break; case stateD : System.out.println( "stateD"); break; } } State model transformation : 28 31/03/03 State model transformation State model transformation : 29 31/03/03 State model transformation State model transformation : 30 31/03/03 State model transformation State model transformation : 31 31/03/03 State model transformation PrintsState() Context Concrete state Dynamic Polymorphism : 32 31/03/03 Dynamic Polymorphism Static polymorphism State machine Dynamic Polymorphism Polymorphism and state patterns : 33 31/03/03 Polymorphism and state patterns If we have an object which state can change during its lifetime and we have to perform different operations according to the object state we use the pattern state. pattern State avoids switch even if the state of the object is changing pattern State creates one object for each state and uses polymorphism to enable transparent client invocation. Objective : 34 31/03/03 Objective State pattern avoid structural switch No enumeration in Java An enumeration may be managed as a state machine. Replace case and enum by object . : 35 31/03/03 Replace case and enum by object . enum ExitCoordinationState { NIL_EXIT_STATE, FLIGHT_ACTIVATION_PROPOSAL, FLIGHT_ACTIVATION_ALARM, FLIGHT_ACTIVATION_CONFIRMED, HANDOVER_TRANSFERED, COORDINATION_TERMINATED, UNKNOWN_EXIT_STATE } structural switch : 36 31/03/03 structural switch static void printsStatus(int status) { switch(status) { case NIL_EXIT_STATE : processing 1 case FLIGHT_ACTIVATION_PROPOSAL: processing 2 case FLIGHT_ACTIVATION_ALARM: processing 3 case FLIGHT_ACTIVATION_CONFIRMED: processing 4 case HANDOVER_TRANSFERED, processing 5 case COORDINATION_TERMINATED, processing 6 case UNKNOWN_EXIT_STATE processing 7 } } Object Programming : 37 31/03/03 Object Programming enum ExitCoordinationState { NIL_EXIT_STATE, FLIGHT_ACTIVATION_PROPOSAL, FLIGHT_ACTIVATION_ALARM, FLIGHT_ACTIVATION_CONFIRMED, HANDOVER_TRANSFERED, COORDINATION_TERMINATED, UNKNOWN_EXIT_STATE } Object Programming : 38 31/03/03 Object Programming enum ExitCoordinationState { NIL_EXIT_STATE, FLIGHT_ACTIVATION_PROPOSAL, FLIGHT_ACTIVATION_ALARM, FLIGHT_ACTIVATION_CONFIRMED, HANDOVER_TRANSFERED, COORDINATION_TERMINATED, UNKNOWN_EXIT_STATE } State Pattern : 39 31/03/03 State Pattern In the state pattern the context object dynamically switches the state object All the state objects exist at the same time, each one knows how to manage its state, and how to react to client invocations. Polymorphism : 40 31/03/03 Polymorphism Print() Polymorphism : 41 31/03/03 Polymorphism Print() Print() Context Concrete state State diagram : 42 31/03/03 State diagram FLIGHT_ACTIVATION _PROPOSAL FLIGHT_ACTIVATION _CONFIRMED, FLIGHT_ACTIVATION _ALARM HANDOVER _TRANSFERED Status() Status() Status() Status() Status() Status() Status() Slide 43: 43 31/03/03 Observer Design Pattern from the GoF* : 44 31/03/03 Observer Design Pattern from the GoF* *GoF stand for Gang of Four. It refers to the famous books of John Vlissides, Erich Gamma, Richard Helm, Ralph Johnson. Design Patterns: Elements of Reusable Object-Oriented Software. Observer and state : 45 31/03/03 Observer and state Update() addObserver() You do not have the permission to view this presentation. In order to view it, please contact the author of the presentation.
Distributed Design Pattern elfuchs Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINT lite Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 699 Category: Entertainment License: All Rights Reserved Like it (0) Dislike it (0) Added: August 31, 2008 This Presentation is Public Favorites: 0 Presentation Description No description available. Comments Posting comment... Premium member Presentation Transcript Distributed Patterns : Distributed Patterns Slide 2: 2 31/03/03 Factory And Code Generation : 3 31/03/03 Factory And Code Generation Print() Factory And Code Generation : 4 31/03/03 Factory And Code Generation Print() Factory And Code Generation : 5 31/03/03 Factory And Code Generation Print() Factory And Code Generation : 6 31/03/03 Factory And Code Generation Print() Factory And Code Generation : 7 31/03/03 Factory And Code Generation Print() The GOF Abstract Factory Design Pattern : 8 31/03/03 The GOF Abstract Factory Design Pattern *GoF stand for Gang of Four. It refers to the famous books of John Vlissides, Erich Gamma, Richard Helm, Ralph Johnson. Design Patterns: Elements of Reusable Object-Oriented Software. Factory And Code Generation : 9 31/03/03 Factory And Code Generation Create Generated Printer Factory Slide 10: 10 31/03/03 Example 3: The problem is in the User Input : 11 31/03/03 Example 3: The problem is in the User Input Exit Coordination State A: NIL_EXIT_STATE,B: FLIGHT_ACTIVATION_PROPOSAL,C: FLIGHT_ACTIVATION_ALARM,D: FLIGHT_ACTIVATION_CONFIRMED,E: HANDOVER_TRANSFERED,F: COORDINATION_TERMINATED,G: UNKNOWN_EXIT_STATE Enter Exit Coordination State => Replace case and enum by object . : 12 31/03/03 Replace case and enum by object . enum ExitCoordinationState { NIL_EXIT_STATE, FLIGHT_ACTIVATION_PROPOSAL, FLIGHT_ACTIVATION_ALARM, FLIGHT_ACTIVATION_CONFIRMED, HANDOVER_TRANSFERED, COORDINATION_TERMINATED, UNKNOWN_EXIT_STATE } structural switch : 13 31/03/03 structural switch static void printsStatus(int status) { switch(status) { case NIL_EXIT_STATE : processing 1 case FLIGHT_ACTIVATION_PROPOSAL: processing 2 case FLIGHT_ACTIVATION_ALARM: processing 3 case FLIGHT_ACTIVATION_CONFIRMED: processing 4 case HANDOVER_TRANSFERED, processing 5 case COORDINATION_TERMINATED, processing 6 case UNKNOWN_EXIT_STATE processing 7 } } Polymorphism : 14 31/03/03 Polymorphism Print() Polymorphism : 15 31/03/03 Polymorphism Print() Polymorphism : 16 31/03/03 Polymorphism Print() Factory Pattern : 17 31/03/03 Factory Pattern Print() Factory Pattern : 18 31/03/03 Factory Pattern The switch is now hidden in the object state factory. The factory returns a new object of the right derived class by using a switch case on the state integer code. The client always sees the root class object type Status. Each state object knows how to manage client invocation in its own case. Factory pseudo code : 19 31/03/03 Factory pseudo code static Status create(int status) { switch(status) { case NIL_EXIT_STATE : return status = new nil_exit_state(); break; case FLIGHT_ACTIVATION_PROPOSAL: return status = new flight_activation_proposal(); break; case FLIGHT_ACTIVATION_ALARM: return status = new flight_activation_alarm(); break; case FLIGHT_ACTIVATION_CONFIRMED: return status = new flight_activation_confirmed(); break; case HANDOVER_TRANSFERED, return status = new handover_transfered(); break; case COORDINATION_TERMINATED, return status = new coordination_terminated(); break; case UNKNOWN_EXIT_STATE return status = new unknown_exit_state(); } } New Object Factory Singleton : 20 31/03/03 Factory Singleton Print() Static Class Method Factory Finder : 21 31/03/03 Factory Finder In CORBA factory apply the singleton pattern Based on factory finder Factory finder provides named based factory access using naming service. Slide 22: 22 31/03/03 Dynamic Polymorphism : 23 31/03/03 Dynamic Polymorphism Static polymorphism (Factory) State machine Pattern State creates one object for each state and uses polymorphism to enable transparent client invocation. Dynamic Polymorphism State Pattern (from the GoF) : 24 31/03/03 State Pattern (from the GoF) GoF stand for Gang of Four. It refers to the famous books of Vlisside and Co. Design Patterns: Elements of Reusable Object-Oriented Software. State model transformation : 25 31/03/03 State model transformation State diagram : 26 31/03/03 State diagram HelloState A State B HelloState C HelloState D Request() Request() Request() Request() structural switch : 27 31/03/03 structural switch static void printsState(int state) { switch(state) { case stateA : System.out.println( "stateA"); break; case stateB : System.out.println( "stateB"); break; case stateC : System.out.println( "stateC"); break; case stateD : System.out.println( "stateD"); break; } } State model transformation : 28 31/03/03 State model transformation State model transformation : 29 31/03/03 State model transformation State model transformation : 30 31/03/03 State model transformation State model transformation : 31 31/03/03 State model transformation PrintsState() Context Concrete state Dynamic Polymorphism : 32 31/03/03 Dynamic Polymorphism Static polymorphism State machine Dynamic Polymorphism Polymorphism and state patterns : 33 31/03/03 Polymorphism and state patterns If we have an object which state can change during its lifetime and we have to perform different operations according to the object state we use the pattern state. pattern State avoids switch even if the state of the object is changing pattern State creates one object for each state and uses polymorphism to enable transparent client invocation. Objective : 34 31/03/03 Objective State pattern avoid structural switch No enumeration in Java An enumeration may be managed as a state machine. Replace case and enum by object . : 35 31/03/03 Replace case and enum by object . enum ExitCoordinationState { NIL_EXIT_STATE, FLIGHT_ACTIVATION_PROPOSAL, FLIGHT_ACTIVATION_ALARM, FLIGHT_ACTIVATION_CONFIRMED, HANDOVER_TRANSFERED, COORDINATION_TERMINATED, UNKNOWN_EXIT_STATE } structural switch : 36 31/03/03 structural switch static void printsStatus(int status) { switch(status) { case NIL_EXIT_STATE : processing 1 case FLIGHT_ACTIVATION_PROPOSAL: processing 2 case FLIGHT_ACTIVATION_ALARM: processing 3 case FLIGHT_ACTIVATION_CONFIRMED: processing 4 case HANDOVER_TRANSFERED, processing 5 case COORDINATION_TERMINATED, processing 6 case UNKNOWN_EXIT_STATE processing 7 } } Object Programming : 37 31/03/03 Object Programming enum ExitCoordinationState { NIL_EXIT_STATE, FLIGHT_ACTIVATION_PROPOSAL, FLIGHT_ACTIVATION_ALARM, FLIGHT_ACTIVATION_CONFIRMED, HANDOVER_TRANSFERED, COORDINATION_TERMINATED, UNKNOWN_EXIT_STATE } Object Programming : 38 31/03/03 Object Programming enum ExitCoordinationState { NIL_EXIT_STATE, FLIGHT_ACTIVATION_PROPOSAL, FLIGHT_ACTIVATION_ALARM, FLIGHT_ACTIVATION_CONFIRMED, HANDOVER_TRANSFERED, COORDINATION_TERMINATED, UNKNOWN_EXIT_STATE } State Pattern : 39 31/03/03 State Pattern In the state pattern the context object dynamically switches the state object All the state objects exist at the same time, each one knows how to manage its state, and how to react to client invocations. Polymorphism : 40 31/03/03 Polymorphism Print() Polymorphism : 41 31/03/03 Polymorphism Print() Print() Context Concrete state State diagram : 42 31/03/03 State diagram FLIGHT_ACTIVATION _PROPOSAL FLIGHT_ACTIVATION _CONFIRMED, FLIGHT_ACTIVATION _ALARM HANDOVER _TRANSFERED Status() Status() Status() Status() Status() Status() Status() Slide 43: 43 31/03/03 Observer Design Pattern from the GoF* : 44 31/03/03 Observer Design Pattern from the GoF* *GoF stand for Gang of Four. It refers to the famous books of John Vlissides, Erich Gamma, Richard Helm, Ralph Johnson. Design Patterns: Elements of Reusable Object-Oriented Software. Observer and state : 45 31/03/03 Observer and state Update() addObserver()