logging in or signing up Intercepting Filters Design Pattern ProdigyView 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: 47 Category: Entertainment License: All Rights Reserved Like it (0) Dislike it (0) Added: December 02, 2011 This Presentation is Public Favorites: 0 Presentation Description Learn how to implement the intercepting filters design pattern. Comments Posting comment... Premium member Presentation Transcript Intercepting Filters Design Pattern: Intercepting Filters Design PatternOverview: Overview Objective Learn how to use the intercepting filter design pattern. Requirements Array Extending an Object Estimated Time 10 minutes www.prodigyview.comFollow Along With Code Example: Follow Along With Code Example Download a copy of the example code at www.prodigyview.com/source . Install the system in an environment you feel comfortable testing in. Proceed to examples /design/ Filters.phpWhat are Filters?: What are Filters? Intercepting Filters is a design pattern that wraps execution and intercepts the transmissions and/or request of response. Intercepting filters can be stacked in a chain and alter execution without changing the source code. A simpler explanation would be modifying the data that is passed into or returned from a method. This may also possibly affect the execution of that method without directly altering the source code.Intercepting Filters Visual: Intercepting Filters Visual Filter is reached Continue Execution Filter Data Filter passes data to another object to filter Filtered data is passed back, normal execution continues MyObject :: doSomething ($ mydata ); My Filter Object OutputPVPatterns and PVStaticPatterns: PVPatterns and PVStaticPatterns The classes that contain the functions for using filters is the PVPatterns and PVStaticPatterns classes. PVPatterns is for instances and PVStaticPatterns is for static methods. Both PVObject and PVStaticObject extend the pattern classes.Vending Machine Example: Vending Machine Example We are going to start off with a vending machine example. Our VendingMachine extends PVObject . PVObject extends PVPatterns which has the filter methods we need. Extending PVObject Compile the data to filter Make the method filterable by adding the filtersAdding A Filter: Adding A Filter If you noticed in our filter class, we had an explicit section where the filters are were defined. Filters are suppose to be tied to a specific function in a specific class. We can simply use get_class and __Function__ to get the current class and function. The method _ hasFitler first determines if they method has any filters. If true, lets execute them. The function has two different filters because there are two different events being performed, a check and a selection. The filter is being applied by passing in the class name, the function name, the data to be filtered, and options. Keep in mind that the filter can only filter one piece of data. Checks if there is a filter for this class and this method Apply the filter for this class and this method Executes only if the event type has been setItem Check: Item Check Now for our vending we have items like beer which need to be checked before buying. Lets add in a class that handles that. Data passed from the filter Options passed about the filter Return the dataItem Chooser: Item Chooser Soda sounds generic. What kind of soda? Next we are going to add a class to handle what kind of item we are picking. Data passed from the filter Options passed about the filter Return the dataVend! Round 1: Vend! Round 1 So we have our vending machine set up. Lets run the function with some data and look at the results. Remember the parameters was item, money and age.Round 1 Results: Round 1 Results Oh man, that ’ s not good. We are having minors getting beer and anyone putting any price and getting what they want. And all the items are generic! Let’s fix this.Round 2- Add Some filters: Round 2- Add Some filters So let’s add some filters in. The first two arguments is the class and method to tie the filter too. The second two arguments is the class and method that will do the filtering. The last in the options in which you can tie the filter being called to a particular event. Let’s give this a try. The class to attach the filter to The method to filter The class that will filter the data The method in the class to filter the data Filter works only on this eventRound 2 Results: Round 2 Results Ok a little better, at least we are getting some none generic items back. But we still need to verify the age and amount tendered.Round 3 – Verification Filters: Round 3 – Verification Filters Now we are going to add the last set filters on, the same way we added the previous filters. Calls an instanceRound 3 Result: Round 3 Result Finally, the results we need. So that is filters in a nutshell. We modified the data in the method without ever modifying the method.Challenge!: Challenge! Below is an optional challenge designed to help you gain a better understanding of the design pattern. Create 3 classes with 2 methods each. Make sure each method accepts 2 parameters and has at least one filter. Attach a filter to each method that filters out by calling a filter from another class. Design the filters in a way THAT DOES NOT CAUSE AN INFINITE LOOP. Execute code.Summary: Summary Apply a filter using the _ applyFilter method. The name of the class and the name of the function calling the filter should be used. The function only accepts 1 parameter for data to be filters. Add a filter before execution using the _ addFilter method. Specify the class and method to be filter and the class and method to run the filter through.API Reference: API Reference For a better understanding of the Collections and the Iterator, check out the api at the two links below. PVStaticPatterns PVPatterns www.prodigyview.com More Tutorials For more tutorials, please visit: http:// www.prodigyview.com /tutorials You do not have the permission to view this presentation. In order to view it, please contact the author of the presentation.
Intercepting Filters Design Pattern ProdigyView 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: 47 Category: Entertainment License: All Rights Reserved Like it (0) Dislike it (0) Added: December 02, 2011 This Presentation is Public Favorites: 0 Presentation Description Learn how to implement the intercepting filters design pattern. Comments Posting comment... Premium member Presentation Transcript Intercepting Filters Design Pattern: Intercepting Filters Design PatternOverview: Overview Objective Learn how to use the intercepting filter design pattern. Requirements Array Extending an Object Estimated Time 10 minutes www.prodigyview.comFollow Along With Code Example: Follow Along With Code Example Download a copy of the example code at www.prodigyview.com/source . Install the system in an environment you feel comfortable testing in. Proceed to examples /design/ Filters.phpWhat are Filters?: What are Filters? Intercepting Filters is a design pattern that wraps execution and intercepts the transmissions and/or request of response. Intercepting filters can be stacked in a chain and alter execution without changing the source code. A simpler explanation would be modifying the data that is passed into or returned from a method. This may also possibly affect the execution of that method without directly altering the source code.Intercepting Filters Visual: Intercepting Filters Visual Filter is reached Continue Execution Filter Data Filter passes data to another object to filter Filtered data is passed back, normal execution continues MyObject :: doSomething ($ mydata ); My Filter Object OutputPVPatterns and PVStaticPatterns: PVPatterns and PVStaticPatterns The classes that contain the functions for using filters is the PVPatterns and PVStaticPatterns classes. PVPatterns is for instances and PVStaticPatterns is for static methods. Both PVObject and PVStaticObject extend the pattern classes.Vending Machine Example: Vending Machine Example We are going to start off with a vending machine example. Our VendingMachine extends PVObject . PVObject extends PVPatterns which has the filter methods we need. Extending PVObject Compile the data to filter Make the method filterable by adding the filtersAdding A Filter: Adding A Filter If you noticed in our filter class, we had an explicit section where the filters are were defined. Filters are suppose to be tied to a specific function in a specific class. We can simply use get_class and __Function__ to get the current class and function. The method _ hasFitler first determines if they method has any filters. If true, lets execute them. The function has two different filters because there are two different events being performed, a check and a selection. The filter is being applied by passing in the class name, the function name, the data to be filtered, and options. Keep in mind that the filter can only filter one piece of data. Checks if there is a filter for this class and this method Apply the filter for this class and this method Executes only if the event type has been setItem Check: Item Check Now for our vending we have items like beer which need to be checked before buying. Lets add in a class that handles that. Data passed from the filter Options passed about the filter Return the dataItem Chooser: Item Chooser Soda sounds generic. What kind of soda? Next we are going to add a class to handle what kind of item we are picking. Data passed from the filter Options passed about the filter Return the dataVend! Round 1: Vend! Round 1 So we have our vending machine set up. Lets run the function with some data and look at the results. Remember the parameters was item, money and age.Round 1 Results: Round 1 Results Oh man, that ’ s not good. We are having minors getting beer and anyone putting any price and getting what they want. And all the items are generic! Let’s fix this.Round 2- Add Some filters: Round 2- Add Some filters So let’s add some filters in. The first two arguments is the class and method to tie the filter too. The second two arguments is the class and method that will do the filtering. The last in the options in which you can tie the filter being called to a particular event. Let’s give this a try. The class to attach the filter to The method to filter The class that will filter the data The method in the class to filter the data Filter works only on this eventRound 2 Results: Round 2 Results Ok a little better, at least we are getting some none generic items back. But we still need to verify the age and amount tendered.Round 3 – Verification Filters: Round 3 – Verification Filters Now we are going to add the last set filters on, the same way we added the previous filters. Calls an instanceRound 3 Result: Round 3 Result Finally, the results we need. So that is filters in a nutshell. We modified the data in the method without ever modifying the method.Challenge!: Challenge! Below is an optional challenge designed to help you gain a better understanding of the design pattern. Create 3 classes with 2 methods each. Make sure each method accepts 2 parameters and has at least one filter. Attach a filter to each method that filters out by calling a filter from another class. Design the filters in a way THAT DOES NOT CAUSE AN INFINITE LOOP. Execute code.Summary: Summary Apply a filter using the _ applyFilter method. The name of the class and the name of the function calling the filter should be used. The function only accepts 1 parameter for data to be filters. Add a filter before execution using the _ addFilter method. Specify the class and method to be filter and the class and method to run the filter through.API Reference: API Reference For a better understanding of the Collections and the Iterator, check out the api at the two links below. PVStaticPatterns PVPatterns www.prodigyview.com More Tutorials For more tutorials, please visit: http:// www.prodigyview.com /tutorials