Category Image Common Programming Mistakes


Here are some simple common programming errors that the compiler will not necessarily catch. Obviously I've been caught by each one of these at one time or another!

I will add to this from time to time.....

  • You declared an instance variable in your class, for example,
    Customer _customer;
    However when you initialized (perhaps lazily) the _customer variable in a method of the class, you accidentally declared it again in the assignment statement leaving the class variable null
    Customer _customer = new Customer();
    ... which created a temporary local instance in the method and left the _customer class variable as null. What you meant to type was...
    _customer = new Customer();

Posted: Thursday - December 29, 2005 at 11:26 AM        


Published by