Implementing the Singleton Design Pattern
Sometimes in your applications you will have objects that by their very nature should exist at most one time and one time only a global application object would be one example. Indeed, Singletons occasionally get a bad rap for being glorified global variables, which developers frown on because it's more of a hassle to ensure that the state of that variable is correct everywhere. In IronPython, we'll store an instance of a class in a variable for reference if that instance variable is null, we...
Passing Information via the QueryString
The QueryString portion of a URL is the segment past the file extension, if one exists. In a URL such as the QueryString parameters are id and dummy. We can pass information between pages using the QueryString Listing 9-25, Figure 9-5 . It's always a good idea to check whether a QueryString parameter is null before attempting to perform operations on it. Also, since the QueryString is publicly visible both when a user hovers over a link and in the address bar once the user has browsed to that...
Reading Cookies
Storing information in a cookie is only half the battle well, one-third if you consider deleting cookies, which we'll cover next . If you want to retrieve the value of a cookie, you should always check for whether that cookie exists before attempting to do so if a user has disabled cookies, it won't exist and an exception will be thrown Listing 9-17 . Listing 9-17. Reading Cookies import System System.DateTime.Now.ToString check for the existence of the cookie first if None Tip Why not just...
