Free Code Here!

I just received this hilarious message: 
Thanks, you *****, for not responding to my Prim’s e-mail, and may you be cursed with the worst of success in Computer Science.
Sincerely,
Michael
Every once in a while I get requests from people asking me for completed code. The purpose of my articles (and this blog) is to aid understanding, not […]

What’s wrong with this code? - 1

What is wrong with the following code? 
struct Foo {
    public int id;
    public string value;
    public static readonly Foo Empty = new Foo(””);
    public Foo(string val)
    {
         this.value = val;
         this.id = -1;
     }
};
and elsewhere…
Foo m = new Foo(”Something”); 
if (object.ReferenceEquals(m, Foo.Empty))
{
    …//do something
} else
{

}
 

Tags: .net, Code, programming, quiz

.Net Deprecation

A useful attribute in .Net is Obselete. When you mark a method with this the compiler will flag any line that accesses the method (or property, or whatever) with a warning (error is optional).
I recently used it for a framework that sits between a database and applications–I wanted to faithfully reflect the database design (since […]

Benefits of using “as” in C#

The “as” keyword is very useful in managed code because it solves a very common problem.
Suppose you have this:
object o;


string s = (string)o;
but what if o is null? Then you will get a NullReferenceException. Sometimes this is ok, but often if o is null, you want s to be null as well.
Enter ‘as’. as is […]

Detecting database connection

How to detect whether a database is up and available before processing data.

Sleep and the length of days

Is it just a coincidence that humans require roughly the same amount of sleep as there are hours during the night?
In other words, is the amount of sleep that is “healthy” for us the result of long centuries of nurturing and tradition or is it biological?
In other words, if the day were 30 hours long, […]

Programmer’s Paradise

Joel of Joel on Software recently posted a good article on managing programmers in software companies. I liked this paragraph:
A programmer is most productive with a quiet private office, a great computer, unlimited beverages, an ambient temperature between 68 and 72 degrees (F), no glare on the screen, a chair that’s so comfortable you don’t […]

The web in a box

I was reading an interview of Gary Flake who works with MSN search. The following quote stood out to me:
 However, there is an even richer class of algorithms that can only be efficiently built on a 64 bit system because you essentially have to have a significant part of the web stored close to a […]