Web design tools - 308 CHAPTER 10 INFINITE DATA PATTERN to

308 CHAPTER 10 INFINITE DATA PATTERN to focus on the architecture and mechanics of the Infinite Data pattern. For those wondering, the prime number calculation routine is a brute force technique that tests whether a number is prime. What is desired with the implementation is the ability to display seemingly infinite data in a timely manner, hence the prime number algorithm is a secondary concern. Calculating the prime number of a large enough maximum value will require some time and allow the testing of multiple concurrently running tasks. The pattern implementation uses the Persistent Communications pattern. In the definition of the Persistent Communications pattern, there are three variations that can be implemented. The Infinite Data pattern uses the server push variation without implementing user identification. A server push is when the client sends a request to a generic URL, and the server responds with a specific URL used to process requests. In the case of the prime number calculation, the generic URL could be /ajax/chap08/PrimeNumberHandler, and the specific URL would be /ajax/ chap08/PrimeNumberHandler/1_101. It sounds ideal and would work if it were not for ASP.NET. One of the problems implementing the Infinite Data pattern is that infrastructures such as ASP.NET are not always implementation friendly. The problem is that the Infinite Data pattern uses URLs in a way that is not friendly with the default ASP.NET infrastructure. ASP.NET, unlike Java Servlet, does not understand the notion of generic URLs. When using ASP.NET, using a specific URL such as /ajax/chap08/PrimeNumberHandler.ashxwould be necessary. Some readers will remember that when the Permutations pattern was implemented, ASP.NET was used. The reason why the Permutations pattern worked is because ASP.NET HTTP modules were used. In Javaspeak, a module is a filter, and the module redirected to a specific URL. The difference is that one handler will process multiple requests associated with a URL and its descendent URLs. The Permutations pattern redirected to a URL used to process a single request. So one solution could be to have the generic URL redirect to something specific such as /ajax/chap08/PrimeNumberHandler/1_101.aspx. Again, the problem is that that does not work in ASP.NET. There has to be a file 1_101.aspx in the directory PrimeNumberHandler. The HTTP module could copy a file to satisfy the reference of the specific file. The solution, though technically possible, is not practically viable. The URL used in the server push is generated dynamically, and there could be hundreds of thousands of URLs. Managing hundreds of thousands of files is not an option. Another solution would be to attach a CGI parameter to the URL as follows: /ajax/chap08/ PrimeNumberHandler.ashx?task=1234. Attaching the CGI parameter would work, but it is not a best practice. Doing so is a so-called necessary practice as the infrastructure does not allow anything else. The problem of using CGI parameters in this context is that it conflicts with caching on the Internet. Another clever approach would be not to use the task identifier, but the URL /ajax/ chap08/PrimeNumberCalculatorTask.ashx?number=20. The new URL is saying, Please calculate the prime numbers up to the number 20. Using the URL in that manner is not bad idea, because then the answer for the prime numbers up to 20 could be cached. In fact, an optimization would be to cache the prime numbers calculated. Then as a larger number is referenced, only the difference between the previously largest value and new large number needs to be calculated. But we won t use that approach in this chapter because we would be diverting from using a classic implementation of the Infinite Data pattern. The optimizations illustrated for calculating the prime number are optimizations that could be used in the implementation of the prime number task. The overall infrastructure would remain identical, and focusing on the optimization would take attention away from implementing the Infinite Data pattern.
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.

Leave a Reply