October 17, 2003
@ 04:30 AM

After Joel Spolsky's recent post on exceptions which generated lots of dissenting opinions he has attempted to recant in a way that leads one to believe he is bad at accepting critical feedback.

In his most recent posting Joel writes

And Back To Exceptions

There's no perfect way to write code to handle errors. Arguments about whether exception handling is "good" or "bad" quickly devolve into disjointed pros and cons which never balance each other out, the hallmark of a religious debate. There are lots of good reasons to use exceptions, and lots of good reasons not to. All design is about tradeoffs. There is no perfect design and there is certainly never any perfect code.

His response is a cop out and not something I'd expect from a professional software developer who had been shown the errors in his proposed solution. This non-recant actually lowers my opinion of Joel in ways his original post did not. At least the original post could be based on past experience with bad uses of exceptions or usage of exceptions in programming languages where they were bolted on such as C++. His newest post just sounds like he is trying to save face instead of critically analyzing the dissenting opinions and showing the pros and cons of his approach and that of others. The best part is that he picks perhaps the worst defense of using exceptions to counterpoint against

With status returns:

STATUS DoSomething(int a, int b)
{
    STATUS st;
    st = DoThing1(a);
    if (st != SGOOD) return st;
    st = DoThing2(b);
    if (st != SGOOD) return st;
    return SGOOD;
}

And then with exceptions:

void DoSomething(int a, int b)
{
    DoThing1(a);
    DoThing2(b);
}

Ned, for the sake of argument, could you do me a huge favor, let's use a real example. Change the name of DoSomething() to InstallSoftware(), rename DoThing1() to CopyFiles() and DoThing2() to MakeRegistryEntries().

Since I'm always one to take a challenge here goes how I'd probably write the code

void DoSomething(string name, string location)
{

try{
    InstallSoftware(name);
    CopyFiles(location);
    MakeRegistryEntries(name);

  }catch(SoftwareInstallationException e){

  RollbackInstall(name);

  }catch(FileIOException fioe){

  RollbackFileCopy(location); 

  RollbackInstall(name);

 }catch(RegistryException re){

   RollbackRegistryWrite(name);

   RollbackFileCopy(location); 

   RollbackInstall(name);

  }

DisplayInstallationCompleteMessage(name, location);

}

or even better

void DoSomething(string name, string location)
{

    try{
    InstallSoftware(name);
    CopyFiles(location);
    MakeRegistryEntries(name);

   }catch(Exception e){

     throw InstallationException(e, name, location);

  }

DisplayInstallationCompleteMessage(name, location);

}

Of course, you could ask what happens if a rollback attempt fails in which case it either should catch the exceptions in itself or throw an exception. Either way, I prefer that the above approaches to littering the code with if...else blocks.


 

Categories: Ramblings

October 14, 2003
@ 04:04 PM

In the transition from Visual Studio 2002 (which uses v1.0 of the .NET Framework) and Visual Studio 2003 (which uses v1.1. of the .NET Framework) the Microsoft Visual Studio team decided to change the project file formats so that they'd be incompatible. This means that development teams can't build .NET Framework if developers use different versions of Visual Studio that were released merely one year from each other.  

Since I use Visual Studio 2002 at home this has led to some complaints from various members of the RSS Bandit workspace who like most developers are using the latest and greatest (Visual Studio 2003) because it means the project files under source control are not compatible with their version of Visual Studio. I have been hesitant to move to Visual Studio 2003 and v1.1 of the .NET Framework because I don't want RSS Bandit to become targetted at v1.1 of the .NET Framework instead of being able to run on both v1.0 and v1.1 of the .NET Framework. Based on my web server logs, users with v1.0 of the .NET Framework installed still outnumber those with v1.1.

However it seems this is out of my hands. Last night Torsten initiated a vote in the RSS Bandit workspace and the numbers overwhelmingly indicate that the members of the workspace want to move to v1.1 of the .NET Framework. So it looks like I need to go buy a copy of Visual Studio 2003.

I now have to figure the best process to put in place to ensure that RSS Bandit always runs on both v1.0 and v1.1 of the .NET Framework. Already there is one issue I'm sure will cause breakages if I don't keep an eye on it, when people the project moves, the System.Xml.Xsl.XslTransform class had a number of overloads of its Transform() method obsoleted and replaced by new methods. When compiled against v1.1 of the .NET Framework the compiler complains that RSS Bandit uses obsoleted methods which is fine in our case since the obsoletions were a result of some overreactions during our month-long security push from last year.  However many people keep thinking that they should change the method calls to the new ones which will break RSS Bandit when it runs on v1.1 of the .NET Framework since those methods don't exist there.

Last week Torsten asked when I think we'll start to make the transition to v2.0 of the .NET Framework (no doubt inspired by all the PDC hype. From what I've seen that's going to be a bitch of a move. I suspect we won't do that till a few months after Whidbey (the next version of the .NET framework) goes gold which gives us about a year and a half.


 

Categories: RSS Bandit

October 13, 2003
@ 11:23 PM

Joel Spolsky writes

The reasoning is that I consider exceptions to be no better than "goto's", considered harmful since the 1960s, in that they create an abrupt jump from one point of code to another. In fact they are significantly worse than goto's:

  1. They are invisible in the source code. Looking at a block of code, including functions which may or may not throw exceptions...
  2. They create too many possible exit points for a function. To write correct code, you really have to think about every possible code path through your function...

A better alternative is to have your functions return error values when things go wrong, and to deal with these explicitly

Whoa, this is probably the second post from Joel that I've completely disagreed with. Exceptions may suck (unchecked exceptions especially) but using return values with error codes sucks a lot more.
 

Categories: Ramblings

RSS Bandit is now the most kickass news aggregator for the .NET Framework. However there are features people keep asking for that I haven't seen others working on that I'll try to get into RSS Bandit before the end of the year. In this post I describe the top 3 as I see them.
 

Categories: RSS Bandit

October 12, 2003
@ 10:08 PM

From the Reuter's article Suspected Penis Snatcher Beaten to Death.

BANJUL (Reuters) - A 28-year-old man accused of stealing a man's penis through sorcery was beaten to death in the West African country of Gambia on Thursday, police said. A police spokesman told Reuters that Baba Jallow was killed by about 10 people in the town of Serekunda, nine miles from the capital Banjul.

Reports of penis snatching are not uncommon in West Africa, with purported victims claiming that alleged sorcerers simply touched them to make their genitals shrink or disappear in order to extort cash in the promise of a cure.

The police spokesman said many men in Serekunda were now afraid to shake hands, and he urged people not to believe reports of "vanishing" genitals. Belief in sorcery is widespread in West Africa.

This particular urban legend was quite common back home in Nigeria and every couple of years there'd be "seasons" of mass hysteria where people got beaten up for allegedly snatching penises. There was always some story of "a friend of a friend" who got his penis snatched by some lady/gentleman/witchdoctor who they bumped into in a crowded street but managed to confront the person in time and request their penis back. 

I never realized this urban legend/mass hysteria  was widespread across West Africa. You learn a new thing every day.


 

Categories: Ramblings

Aaron Swarts has an interesting post entitled Shades of Gray where he asks the following questions
  1. What do you do when someone says something obviously false? Do you correct them? Do you ignore them?

  2. What if they continue to repeat it? Are they malicious? Misguided? Simply taking another, but still reasonable, point of view?

  3. What if they get people to agree with them? Are they a conspiracy? Biased? Driven by other motivations? Amoral? Immoral?

  4. What if everyone starts to say it? Do you question your belief? Your sanity? Your life?

Below are some thoughts that surfaced when I read his entry and the followup post
 

Categories: Ramblings

October 11, 2003
@ 07:29 PM

I just made available a download containing a signed assembly (i.e. DLL for the non-.NET savvy) for the EXSLT.NET project. You can download it from here. Here's the elevator speech description of the project.

The EXSLT.NET library is an implementation of EXSLT extensions to XSLT for the .NET platform. EXSLT.NET implements the following EXSLT modules: Dates and Times, Common, Math,Regular Expressions, Sets and Strings. In addition EXSLT.NET provides own set of useful extension functions. See full list of supported extension functions and elements in "Extension Functions and Elements" section.

The project is primarily a merger of the code from my article EXSLT: Enhancing the Power of XSLT and Oleg Tkachenko's article Producing Multiple Outputs from an XSL Transformation with a number of enhancements from folks like Dimitre Novatchev and Paul Reid.

I'll probably write a followup article about this for my Extreme XML column on MSDN. In the meanwhile I assume Oleg will probably send out an announcement to xsl-list & xml-dev about the project in the next few days.


 

Categories: XML

October 10, 2003
@ 04:40 PM
The one where yet another person requests a feature that's been in RSS Bandit for months.
 

Categories: RSS Bandit

October 10, 2003
@ 10:52 AM
An exploration of the term Almost Standard Compliant
 

Categories: Life in the B0rg Cube

October 10, 2003
@ 10:27 AM

Since I moved websites I'd like people to access my dasBlog RSS feed as opposed to my old RSS feeds. However whereas getting a web server to send a 301 (Moved Permanently) result to a client is a piece of cake in Apache (simply edit some config file) it seems to be a bitch and a half in IIS.

If anyone has any tips or tricks as to how to setup IIS 5.1 running ASP.NET to send 301s I'm all ears.


 

Categories: Ramblings