I identified a bug in the simulator and fixed it. Now, the traditional craps table performs better than the crapless table in all scenarios I’ve tested. I’m more comfortable with these results, which give about a 76-78% chance of breaking even or better given a certain ratio of bet size Read more…
Extension methods are methods that are added to existing compiled types. These are useful for adding new members to classes in the BCL or in assemblies for which source code is not available. However, extension methods can also be useful because they can be called on null references. For instance, an immutable Stack(of T) implementation might contain a head of type T and a tail of type Stack(of T). How do you create an empty stack if T is allowed to be a non-nullable value type? (more…)
The event keyword in C# causes the compiler to provide registration and unregistration methods and member variables for delegate types. These methods could be written manually; the event keyword just saves time. An event is declared with the syntax public event DelegateType EventName;, and invoked with EventName(arguments_specified_by_delegate). Microsoft’s recommended event Read more…
The golden rule of .NET memory management is simple:
Allocate a class instance onto the managed heap using the new keyword and forget about it.The garbage collector destroys an object when it is no longer needed, which is (basically) when the object is unreachable by the code base. (more…)
Recently I've been developing an application which, on a user's request, has to perform a series of time-intensive tasks. Based on my understanding of the XmlHttpRequest object, the approach I decided to take was as follows:
- Set the series of steps in the session, including any and all parameters I was aware of at the time the process starts.
- Open a page which uses an XmlHttpRequest to make a single AJAX call to a handler, which would call the functions that do the actual work.
- Read and parse the output from the AJAX handler, and update the content of the page, when the XHR's readyState was equal to 3.
This afternoon I began working on bringing a new production server online to facilitate my client's customers paying their own invoices through an application I wrote. The application is written in PHP and the client's customer database, with which it interacts, is Microsoft SQL Server 7.0. The application worked wonderfully on my development machine. Unfortunately, upon installing it on the production server, it exhibited very peculiar behavior: it would connect successfully to MSSQL, and most queries would be accepted and return correct results. Of the entire app, it appeared that there was only one query which did not function properly. When PHP attempted to execute this query to MSSQL, I received a Fatal error: Allowed memory size of X bytes exhausted (tried to allocate Y bytes) error. Increasing the memory limit did not relieve this error, and in fact, writing a very simple script containing only the problematic query exhibited the same behavior. (more…)