Click here to Skip to main content
Click here to Skip to main content

Tagged as

Go to top

Don't Name Things NAME....

, 4 Aug 2013
Rate this:
Please Sign up or sign in to vote.
Why you shouldn't use reserved words

A Quick Lesson On How To Waste 10 Minutes ...

If you have a new puppy, and it pees in the corner of the room, the recommended thing to do is get a fresh newspaper, roll it up tightly, raise it high in air, annnnnd.... bring it down sharply on *your own head*, repeating the mantra "I should've watched puppy more carefully...." ten times... then clean up the pee....

I was putting together a Windows form in C#/VS and after dropping on a ListView, proceeded to add some columns and give them titles. One of the columns was for "Customer name", but space was tight so I decided to make the title "Name" ... and that's where the trouble started. You see I didn't give the title property the value "Name", **by mistake** I gave the *NAME* property the value "Name" ... and continued to build out the interface. A while later, when I started to add code and build, but of course it failed. Naturally, the error message I got was not especially helpful so much head scratching and digging ensued.

When I clicked the error, I don't see the entire picture...

That only jumps out at me when I started back tracking what I changed to see what happened...

Conclusion

Lesson (re-learned): Don't use reserved words when naming objects or controls, it's bad, and it will bite you. Whenever something goes wrong, look for the simplest solution first, then dig deeper. Remember, compilers are very good at doing what we tell them, so when you get build errors, the first thing to look at is what you have written, chances are you've done a sprinkle in a corner somewhere.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

AJSON
Chief Technology Officer
United Kingdom United Kingdom
Part-time software engineer, part-time student, always learning and refactoring my wetware. Happiest tucking into a big bowl of c# or python sprinkled with a crisp topping of JQuery...started with a single ZX80 a lifetime ago, now happily explore, build and create on interweb scale...

Comments and Discussions

 
QuestionGood Tip! PinprofessionalJohnny J.4-Aug-13 22:10 
AnswerRe: Good Tip! PinprofessionalMaimonides4-Aug-13 22:11 
AnswerRe: Good Tip! PinmemberAllen ONeill4-Aug-13 22:22 
QuestionIts simple PinmemberMember 101877103-Aug-13 17:31 
AnswerRe: Its simple PinprofessionalMaimonides4-Aug-13 22:10 
GeneralThoughts PinprofessionalPIEBALDconsult3-Aug-13 5:51 
GeneralRe: Thoughts PinmemberAllen ONeill3-Aug-13 6:06 
GeneralRe: Thoughts PinmemberHaBiX4-Aug-13 6:43 
GeneralRe: Thoughts PinmemberAllen ONeill5-Aug-13 1:30 

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

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

| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 5 Aug 2013
Article Copyright 2013 by AJSON
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid