Click here to Skip to main content
14,604,287 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
 
GeneralRe: What is the most common error in a .Net application? [modified] Pin
jith - iii16-Dec-08 6:17
Memberjith - iii16-Dec-08 6:17 
GeneralRe: What is the most common error in a .Net application? Pin
Colin Angus Mackay16-Dec-08 7:39
MemberColin Angus Mackay16-Dec-08 7:39 
GeneralRe: What is the most common error in a .Net application? Pin
Kevin McFarlane17-Dec-08 6:51
MemberKevin McFarlane17-Dec-08 6:51 
GeneralRe: What is the most common error in a .Net application? Pin
Adar Wesley5-Jan-09 9:15
MemberAdar Wesley5-Jan-09 9:15 
GeneralRe: What is the most common error in a .Net application? Pin
Colin Angus Mackay5-Jan-09 11:29
MemberColin Angus Mackay5-Jan-09 11:29 
GeneralRe: What is the most common error in a .Net application? Pin
chaiguy133716-Dec-08 6:52
Memberchaiguy133716-Dec-08 6:52 
GeneralRe: What is the most common error in a .Net application? Pin
jith - iii16-Dec-08 8:15
Memberjith - iii16-Dec-08 8:15 
GeneralRe: What is the most common error in a .Net application? Pin
chaiguy133716-Dec-08 8:27
Memberchaiguy133716-Dec-08 8:27 
What strikes me, is that if developers (even experienced ones) are still making this "mistake", then it indicates a conflict in how developers think versus how the compiler "thinks". In other words, it doesn't necessarily mean that the developer doesn't know what they're doing. When I design and write methods, etc., I usually assume that the object I'm working with is alive and non-null, yet later on I may set a certain property or field to null because it no longer applies. If it doesn't apply, then naturally neither does any operation that would affect that object, and therefore even if I didn't originally intend or expect to set that property or field to null, the fact that I later decide to should not break my existing code that assumes it is alive!

Just to give a concrete example of how this might be the case, suppose I have some logging window that keeps track of debugging output while I'm running my program, and throughout the development process this window is always open, or at least exists and is maybe invisible. But when I start my optimizing phase, I no longer want to keep that debug window open all the time, consuming resources the end user doesn't need. However, in my code, I originally assumed it was alive, and did something like this:

myApp.DebugWindow.WriteLine( "foo" );

Sure you could argue (and many will) that this is poor programming and I should in fact precede every statement with "if ( myApp.DebugWindow != null )" but frankly in my opinion this is just additional work that needs to be done that doesn't really affect the intended behavior of the program.

If I set myApp.DebugWindow to null, then at least when running in release mode, any null reference exceptions should simply be absorbed by the runtime. There is no excuse to crash the whole application for something as silly as forgetting to prefix a statement with an "!= null" check first.

Granted, there are ways one could do this, by installing a handler and checking for null reference exceptions, and explicitly setting them to handled (in fact that might be a good practice in general), but again this is more work and the whole point here is to make the language much friendlier with imperfectly-specified programs.

I know a lot of people will disagree with me on this one; but I'm all about software working as well as it possibly can, and not crashing and disrupting the user for things that aren't important. Everyone strives for "perfect" software, but it shouldn't be a requirement of the language.

Sad but true: 4/3 of Americans have difficulty with simple fractions.

There are 10 types of people in this world: those who understand binary and those who don't.

{o,o}.oO( Check out my blog! )
|)””’)          http://pihole.org/
-”-”-

GeneralRe: What is the most common error in a .Net application? Pin
Member 295683816-Dec-08 20:39
MemberMember 295683816-Dec-08 20:39 
GeneralRe: What is the most common error in a .Net application? Pin
chaiguy133717-Dec-08 3:51
Memberchaiguy133717-Dec-08 3:51 
GeneralRe: What is the most common error in a .Net application? Pin
Lashdex30-Jun-09 18:35
MemberLashdex30-Jun-09 18:35 
GeneralRe: What is the most common error in a .Net application? Pin
Super Lloyd15-Dec-08 8:06
MemberSuper Lloyd15-Dec-08 8:06 
GeneralRe: What is the most common error in a .Net application? Pin
jith - iii15-Dec-08 8:24
Memberjith - iii15-Dec-08 8:24 
GeneralRe: What is the most common error in a .Net application? Pin
Colin Angus Mackay16-Dec-08 5:54
MemberColin Angus Mackay16-Dec-08 5:54 
GeneralRe: What is the most common error in a .Net application? Pin
jith - iii16-Dec-08 6:24
Memberjith - iii16-Dec-08 6:24 
GeneralRe: What is the most common error in a .Net application? Pin
Colin Angus Mackay16-Dec-08 7:37
MemberColin Angus Mackay16-Dec-08 7:37 
GeneralRe: What is the most common error in a .Net application? Pin
jith - iii16-Dec-08 8:30
Memberjith - iii16-Dec-08 8:30 
GeneralRe: What is the most common error in a .Net application? Pin
Colin Angus Mackay16-Dec-08 8:53
MemberColin Angus Mackay16-Dec-08 8:53 
GeneralRe: What is the most common error in a .Net application? [modified] Pin
jith - iii16-Dec-08 9:32
Memberjith - iii16-Dec-08 9:32 
GeneralRe: What is the most common error in a .Net application? Pin
franky198716-Dec-08 20:43
Memberfranky198716-Dec-08 20:43 
GeneralRe: What is the most common error in a .Net application? Pin
chaiguy133716-Dec-08 8:30
Memberchaiguy133716-Dec-08 8:30 
GeneralRe: What is the most common error in a .Net application? Pin
ormonds17-Dec-08 15:41
Memberormonds17-Dec-08 15:41 
GeneralRe: What is the most common error in a .Net application? Pin
ToddHileHoffer15-Dec-08 8:10
MemberToddHileHoffer15-Dec-08 8:10 
JokeRe: What is the most common error in a .Net application? Pin
PJ Arends15-Dec-08 8:51
professionalPJ Arends15-Dec-08 8:51 
GeneralRe: What is the most common error in a .Net application? Pin
lw@zi 15-Dec-08 9:16
professional lw@zi 15-Dec-08 9:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.