joeware - never stop exploring... :)

Information about joeware mixed with wild and crazy opinions...

MSDN Magazine June 2006 – Part II

by @ 2:55 pm on 5/13/2006. Filed under tech

The first article is about moving from Visual Studio 2003 to Visual Studio 2005. I thought, this should be a good article… I don’t actually use either IDE (Borland guy here…) but it is good to see what others say about them. I am reading away and then got a trifle perturbed…

There was a comment about minor language changes. I thought, oh yeah, this should be good, MSFT has traditionally been pretty bad about following standards compliance in their compilers and VS2005 is a complete about face there…

But then the following code was given as an example:

for (int i=0;i==something;i++)  //[1] 
 {    
  // do something 
 } 
if (i==0) then 
 {  
  // do something 
 }

I read that and was like what??? Then I read that VS 2005 finally says that is bad and disallows it from working… I was flabberghasted…First…. THAT NEVER SHOULD HAVE WORKED!  And if it did, programmers should be bright enough not to do it.

Second, this isn’t new….. coders should know that for a long time now that that isn’t acceptable. I was taught that was bad all the way back when I was in school back in the late eighties regardless of whether a compiler let you do it or not. Just because a compiler LETS you do something doesn’t mean it is good and you SHOULD do it. The author further says that it should NOW be done this way….

int i;
for (i=0;i==something;i++)  //[1] 
 {    
  // do something 
 } 
if (i==0) then 
 {  
  // do something 
 }

 

Again… it always should have been done that way. This is all about scope. Using vars outside of their area of scope isn’t smart even if the compiler is stupid enough to let you do it. The fact that someone learned this wasn’t good because they were upgrading compilers just scares the bejeezus out of me and I am not a professional coder, I just do it for fun.

 

***EDITED: 2006/05/15 – 12:25PM EST – Thanks to Alun for catching a typo, my original post blew up on the cut and pasted code because of the greaterthan lessthan symbols. When I retyped I cut and paste from the first example and added to but neglected to delete from. Thanks Alun. 🙂

***EDITED: 2006/05/15 – 12:30PM EST – Fricken WordPress does not work well with code examples… Had to fix the whitespace on the code after fixing the int problem.

 

[1] I changed this, wordpress has tremendous difficulties with the greater than and less than symbols…

Rating 3.00 out of 5

One Response to “MSDN Magazine June 2006 – Part II”

  1. Alun Jones says:

    Your second example has one too many “int”s in it. As it stands now, you’ll be hiding one of the is.

[joeware – never stop exploring… :) is proudly powered by WordPress.]