Delphi 2007 Handbook








December 24, 2005

.NET and Robustness

In .NET security is a top concern, but apparently application robustness is not.

(I'm back from a trip to Dublin, Ireland.) If you read any book on .NET, you'll notice that one of the core ideas behind Microsoft's abstraction layer is security, safety, and so on. This makes me wonder why they didn't consider the robustness of the programs developers write an equally important element of the equation.

Consider this case I effectively stumbled into (in a slightly different situation, part of a CF application) last week:

DateTime.Now.ToString.Substring (5, 50);

The code should extract a portion of a string of the current date. However, as the number of characters is larger than the length of the string, the .NET library raises an exception. Even worse, if you don't handle the exception explicitly in code, the program will end. If you compare this with Delphi's equivalent (the Copy function), it will copy the available characters up to the maximum length indicated as parameter, without raising any such exception. And if this code is based on the VCL, the library will trigger its global exception error, display a message, and keep working. Which one is safer (despite the fact you can use pointers in Win32)? Placing a similar burden (try-except block, more accurate range checking) on the developer with no safety net seems a bad idea to me. That's why I cannot wait for a VCL.NET for the Compact Framework plaftorm.

Speaking of which, I recently found another gem. I had a application trying to make an HTTP call. In case of connection problems, an exception is raised. Now before you have a chance to trap it, the exception loads its own description. But to save space the assembly with the error messages is not deployed on the CF platform. Therefore, you get an error message saying that a resource assembly cannot be found. After that, you'll get to your except block. It ends up that you're not even allowed to distribute the error messages library, but have to build your own. Unbelievable!





 

1 Comments

.NET and Robustness 

I developed a simple application using VS 2003 and C#.
This application add a Bitmap background to an ascii 
print (from as400). It's running on a 2000 server. 
After 2 month of big problems I rewrite It in Delphi 
5. All the problems disappeared.
So probably you are right. Consider that the only 
Stable IDE for .Net was VS 2003. All other IDE I 
tested (from Delphi 2005 to #Develop) are not so 
stable. 
Comment by Luca Bertoncini [http://sviluppoesviluppo.blogspot.com] on December 28, 21:12


Post Your Comment

Click here for posting your feedback to this blog.

There are currently 0 pending (unapproved) messages.