Dynamic contagion, part one

Suppose you’re an epidemiologist modeling the potential spread of a highly infectious disease. The straightforward way to model such a series of unfortunate events is to assume that the population can be divided into three sets: the definitely infected, the definitely healthy, and the possibly infected. If a member of the healthy population encounters a…

9

Past performance is no guarantee of future results

Before I get started today, a couple housekeeping notes. First off, sorry for no blog the last three weeks; I have been crazy busy adding features to the Roslyn C# semantic analyzer. More on that in an upcoming episode. Second, check out the snazzy new Developer Tools blog aggregation page; it’s one stop shopping for…

20

Keep it secret, keep it safe

A lot of people really love the idea of cryptography. To computer geeks like us there is nothing cooler than the idea that computing relatively simple arithmetic on a message can enable you to communicate secretly with anyone in the world, even if there are eavesdroppers. Unfortunately, this means that there are a lot of…

20

The curious property revealed

Today is the fifteenth anniversary of my first day of full time work here at Microsoft. Hard to believe it has been a decade and a half of writing developer tools. I am tremendously fortunate to be able to work with such a great team on such a great toolset for such great customers. I’m…

17

Guidelines and rules for GetHashCode

“The code is more what you’d call guidelines than actual rules” – truer words were never spoken. It’s important when writing code to understand what are vague “guidelines” that should be followed but can be broken or fudged, and what are crisp “rules” that have serious negative consequences for correctness and robustness. I often get…

37

All your base do not belong to you

People sometimes ask me why you can’t do this in C#: class GrandBase{  public virtual void M() { Console.WriteLine(“GB”); }}class Base : GrandBase{  public override void M() { Console.WriteLine(“B”); }}class Derived : Base{  public override void M()   {     Console.WriteLine(“D”);    base.base.M(); // illegal!   }} The author of the most-derived class here wishes to…

9

Asynchrony in C# 5, Part Eight: More Exceptions

(In this post I’ll be talking about exogenous, vexing, boneheaded and fatal exceptions. See this post for a definition of those terms.) If your process experiences an unhandled exception then clearly something bad and unanticipated has happened. If its a fatal exception then you’re already in no position to save the process; it is going…

34

Careful with that axe, part one: Should I specify a timeout?

(This is part one of a two-part series on the dangers of aborting a thread. Part two is here.) The other day, six years ago, I was was talking a bit about how to decide whether to keep waiting for a bus, or to give up and walk. It led to a quite interesting discussion…

19

Why Can't I Access A Protected Member From A Derived Class? Part Six

Reader Jesse McGrew asks an excellent follow-up question to my 2005 post about why you cannot access a protected member from a derived class. (You probably want to re-read that post in order to make sense of this one.) I want to be clear in my terminology, so I’m going to define some terms. Suppose…

22

Use the right tool for the job

Consider the following scheme: I have some client software which I sell. When the client software starts up for the first time, it obtains a “token” from the user. The token string can be anything; the user can choose their name, their cat’s name, their password, the contents of some disk file, whatever. How the…

18