Attention: We are retiring the ASP.NET Community Blogs. Learn more >

a stupid thing I do over and over and over....and then I did it again!

So today I am testing some code.  I keep getting a NullRef Exception.  I am beating my head against my desk why. 

So, it dawns on me I have some initialization code in the type I am instantiating. I walk through the initialization code and there it is...I do this EVERY time:

dim text as StringBuilder

I then start using text.append

For whatever reason, 100% of the time when using a StringBuilder I forget to to call New.  

So, whats yours? 

  

5 Comments

  • Nope, 100% perfect all the time I'm afraid ;-) I do have a problem switching back to classic ASP (to maintain some of our legacy sites) where I infallibly put semi-cokon at the end of the line and forget the 'then' in if statements...

  • cokon -> colon...I also have 'spelling issues'

  • luckily my 100% goof is behind me with the .NET framework.



    I ALWAYS forgot to call .MoveNext() when I was looping through an ADO recordset, which then resulted in an email to the sysadmin telling him to bounce the dev web server so I could bust out of my loop.



    Heck Scott G., I've started ending sentences in email with a ;. I even CamelCase words that don't even need it. e.g. EveryBody.

  • I always forget to add method calls to the method I just wrote. Example: I'll write a method that calls other new sub methods and end up with several hundred new lines of code. Then I compile and test and nothing happens and I swear aloud. Then I realize that I didn't add MySpiffyNewMethod(); to OnLoad. The code works perfectly after I actually call it. I also refer to methods as functions as a VB layover habit.

  • The source of the majority of my "bugs:"



    if (!Page.IsPostback)



    WHY can't I remember that? Why don't I just put that in Page_Load right from the start? If I start having mysterious problems, it's often that I forgot that and I wind up blowing away all the user input when they submit.



    Go me.

Comments have been disabled for this content.