Archive for August, 2005

Sign Up for Free Issues of CoDe Focus Magazine!

Every so often, we produce special issues of CoDe Magazine that focus in on a specific topic. We call these special issues CoDe Focus Magazines.

These magazines are distributed at special events such as conferences or product launches. We generally distribute them free of charge to our subscribers and additional mailing lists. If you are interested in receiving such free magazines, click the link below. (Regardless if you are a current subscriber or not! Everyone qualifies for a free issue!)

Click here to be added to the list!

There are several issues planned at this point. One that will ship fairly soon targets Tablet PC and Mobile PC Development. The link above will allow you to sign up for those issues and also for issues beyond that. This will give us a good idea of what topics we should be tackling first. So make sure you tell us about as many of your interests as possible.

Feel free to pass this on to your friends…

1 Comment

The using block

There’s something about the using block (that’s been around in C# since its creation, and it’s now a new feature in VB 2005) that I never quite got it.
 
The using block is supposed to always call the Disposable method on a object automatically at the end of the block. However, what if something bad happen on that code and an exception is thrown? For instance let’s say we have the following class:
 

 class MyClass : IDisposable
 {

  #region IDisposable Members

  public void Dispose()
  {
   Console.WriteLine("Disposing…");
  }

  #endregion
 }

 
And then we use that class like so:
 
using (MyClass foo = new MyClass())
{
    throw new Exception("Forcing an exception…");
}
 
In such case, the Dispose method never gets called. That means we’d have to wrap that code up in a try/catch/Finally block, and call the Dispose method manually on the Finally block, defeating the purpose of the using block.
 
For that reason, instead of going that route, I’ve actually just been taking care of that myself, like so:
 

   MyClass foo = null;

   try
   {
    foo = new MyClass();
    throw new Exception("Forcing an exception…");
   }
   catch
   {
    Console.WriteLine("Catching…");
   }
   finally
   {
    Console.WriteLine("Finally…");

    if (foo != null)
    {
     foo.Dispose();
    }
   }

 
That way I’m pretty sure that the Dispose method gets called no matter what (provided that the object doesn’t have a null reference).
 
Maybe somebody could jump in here and give us some insight in case I’m overlooking something here.

Leave a comment

What’s up with zero-based arrays?

From the series "What the heck were they thinking":
 
Every now and then I find myself wondering about some things that just don’t make sense on the software development world. I’ll start blogging about that type of thing just so that I can keep track of those things.
 
One thing that is just way over my ahead to understand is a zero-based array. Come on, people, I’m not smart enough to understand that: MyArray[0] is the first element… MyArray[1], the second… No, seriously, what’s up with that? It’s just not intuitive at all. It’s like saying "on my first birthday I’ll be two years old". Or that "my second marriage is my marriage number 1".
 
How many times have people messed up a for loop because they forgot about the darn zero-based array?
 
"Pseudo code"
For i = 1 to Array.Lenght
    var = Array[i-1]
 
Gimme a break. That’s just wrong. You go explain this to somebody who’s not into programming, he/she is going to say: "hmmm… that doesn’t look like something created by somebody really smart, who’s supposed to know something about logic… that’s just the opposite of logic".  🙂

2 Comments

Just getting started…

Hey,
 
I’m just getting started on this blog. I’ll try to keep two blogs: one where I’ll post things related to software development, or technology in general, and another one where I’ll post things about anything else.  🙂 My other blog can be found at: http://spaces.msn.com/members/classala/  
 
More to come.  🙂

Leave a comment