The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Switch statement angst

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Udi Dahan

Posts: 882
Nickname: udidahan
Registered: Nov, 2003

Udi Dahan is The Software Simplist
Switch statement angst Posted: Aug 1, 2006 3:09 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Udi Dahan.
Original Post: Switch statement angst
Feed Title: Udi Dahan - The Software Simplist
Feed URL: http://feeds.feedburner.com/UdiDahan-TheSoftwareSimplist
Feed Description: I am a software simplist. I make this beast of architecting, analysing, designing, developing, testing, managing, deploying software systems simple. This blog is about how I do it.
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Udi Dahan
Latest Posts From Udi Dahan - The Software Simplist

Advertisement
The C# compiler doesn't like the following code:
public void NewCommandActivatedCallback(object sender, EntityTypeEventArgs e);
{
switch(e.EntityType)
{
case typeof(Customer): // open new customer form; break;
case typeof(Order): // open new order form; break;
//and so on
}
}

It doesn't like the fact that the values of the case elements aren't constant. Well, logically speaking they are constant. Is the following code that much different?

public void NewCommandActivatedCallback(object sender, EntityTypeEventArgs e);
{
switch(e.EntityType.Name)
{
case "Customer": // open new customer form; break;
case "Order": // open new order form; break;
//and so on
}
}

Well, yes. For starters, it compiles. It's also uglier. And less maintainable. But, its semantically equivalent.
My wish for Orcas is FIX IT!!! God! We've been carrying this crap through 2.5 versions of .net. Enough already. Hell, roll it into SP1 of VS2003 or VS2005. It's not like it'll break any existing code.

OK, I feel better now. Move along now. Nothing to see here.

Read: Switch statement angst

Topic: Want to test drive Office 2007? Previous Topic   Next Topic Topic: Is this the beginning of a trend?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use