variable-names

Really long class/variable/property/method names

Some friends and colleagues of mine have a little running contest to find or write the longest class/variable/property/method names possible. Keep in mind, we try to be good boys and girls and keep the naming intelligible and concise, while still explaining what the thing does via its name. Sometimes it just doesn't happen though. Hav...

Do you use particular conventions for naming complementary variables?

I often find myself trying to come up with good names for complementary pairs of variables; where two variables denote opposing concepts, two participants in some sort of duologue, and so on. This might be better explained by a counter-example - I maintain an app that prints two graphics as part of a print advertisement. They're stored ...

What does the @ in this code sample mean?

Html.TextBox("ParentPassword", "", new { @class = "required" }) what the gosh darned heck is the @ for the @class. ...

Why can't variable names start with numbers?

I was working with a new c++ developer a while back when he asked the question: "Why can't variable names start with numbers?" I couldn't come up with an answer except that some numbers can have text in them (123456L, 123456U) and that wouldn't be possible if the compilers were thinking everything with some amount of alpha characters wa...

Am I immoral for using a variable name that differs from its type only by case?

For instance, take this piece of code: var person = new Person(); or for you Pythonistas: person = Person() I'm told constantly how bad this is, but have yet to see an example of the immorality of these two lines of code. To me, person is a Person and trying to give it another name is a waste of time. I suppose in the days before...

What would be a good variable name for a rectangle the describes an objects position and size?

The title is fairly self-explanatory, but I'll reiterate: What would be a good variable name for a rectangle that describes an objects position and size. EDIT - The object is a paddle for a Pong-like game, and there is already a rectangle named 'bounds' to restrict where the paddle can be moved to. I ended up going with 'bounds' for th...

What variable name do you use for file descriptors?

A pretty silly trivial question. The canonical example is f = open('filename'), but f is not very descriptive. After not looking at code in a while, you can forget whether it means "file" or "function f(x)" or "fourier transform results" or something else. EIBTI. In Python, file is already taken by a function. What else do you use...

Programmatic way to get variable name in C?

I am developing a tool to dump data from variables. I need to dump the variable name, and also the values. My solution: Store variable name as a string, and print the "variable name", followed by its value. Is there any programmatic way to know the variable name? ...

How to create a generic id reference with jQuery

I have about 6 div elements with the same class. When I mouseover any one of them I want to show a nother div next to them. I am thinking of giving them all an id of the form id="mydiv-divname" where mydiv- will always be constant. How would I reference the mydiv-* elements. I can't find the exact syntax but I think it should be someth...

Which name is more correct in my case: manager or factory (or something else)?

I have next code: PhotoFactory factory = PhotoFactory.getFactory (PhotoResource.PICASA); PhotoSession session = factory.openSession (login, password); PhotoAlbum album = factory.createAlbum (); Photo photo = factory.createPhoto (); album.addPhoto (photo); if (session.canUpload ()) { session.uploadAlbum (album); } session.close (); ...

XCode find and replace in project problem with XIB

I wanted to rename one badly named variable to something more naturally named (UITableView myListView --> myTableView). Did that with XCode "Edit - Find - Find in project" and replaced all found 7 items with the new one. Application compiled ok, started and crashed. After some debugging found out that there was one (1) old name remainin...

Is there a convention, when using Java RMI, to use the dollar sign $ in a variable name?

I realize that it is a valid part of a variable name, but I've never seen variable names actually use the symbol $ before. The Java tutorial says this: Additionally, the dollar sign character, by convention, is never used at all. You may find some situations where auto-generated names will contain the dollar sign, but your variable ...

How do I access variables with hyphenated names in Smarty?

I've got a PHP page that parses an XML file with SimpleXml, then passes that object to a Smarty template. My problem is that the XML file has hyphens in its tag names, e.g. video-player. In PHP, this is no problem, I just use $xml->{'video-player'} and everything's fine. Smarty, on the other hand, throws a fit when I try to use that synt...

clang unicode characters for variable name

cat test.cpp #include <iostream> int main() { int à; } results in: clang++ test.cpp test.cpp:4:7: error: expected unqualified-id int à; ^ 1 error generated. Now, is there a way to get clang to allow unicode variable names? Thanks! ...

What does the variable name "lsSQL" mean?

I've noticed in a recent article on TDWTF that someone was using the variable name lsSQL . I have also noticed similar variable names in a legacy application I am working on and in other places around the web, but I have never found out what the ls prefix stands for. What does ls mean? What kind of notation is that? Thanks, Tom ...