Click here to Skip to main content
11,430,908 members (69,760 online)
Click here to Skip to main content

Tagged as

Don't Name Things NAME....

, 5 Aug 2013 CPOL
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
Architect/engineer, student, always learning and refactoring my wetware. Happiest tucking into a big bowl of c# or python sprinkled with a crisp topping of Javascript...started with a single ZX80 a lifetime ago, now happily explore, build and create on interweb scale...


6/Oct/14 - "Full Calendar – A Complete Web Diary System for jQuery and C# MVC" - voted article of the day on ASP.net

Comments and Discussions

 
QuestionGood Tip! Pin
Johnny J.4-Aug-13 23:10
professionalJohnny J.4-Aug-13 23:10 
AnswerRe: Good Tip! Pin
Maimonides4-Aug-13 23:11
professionalMaimonides4-Aug-13 23:11 
AnswerRe: Good Tip! Pin
Allen ONeill4-Aug-13 23:22
memberAllen ONeill4-Aug-13 23:22 
QuestionIts simple Pin
Member 101877103-Aug-13 18:31
memberMember 101877103-Aug-13 18:31 
AnswerRe: Its simple Pin
Maimonides4-Aug-13 23:10
professionalMaimonides4-Aug-13 23:10 
GeneralThoughts Pin
PIEBALDconsult3-Aug-13 6:51
professionalPIEBALDconsult3-Aug-13 6:51 
GeneralRe: Thoughts Pin
Allen ONeill3-Aug-13 7:06
memberAllen ONeill3-Aug-13 7:06 
GeneralRe: Thoughts Pin
HaBiX4-Aug-13 7:43
memberHaBiX4-Aug-13 7:43 
GeneralRe: Thoughts Pin
Allen ONeill5-Aug-13 2:30
memberAllen ONeill5-Aug-13 2: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 | Terms of Use | Mobile
Web02 | 2.8.150428.2 | Last Updated 5 Aug 2013
Article Copyright 2013 by AJSON
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid