variable-naming

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...

How should i name for this table and function?

I have a list of media that i inspired and a list i was inspired by. In a table i named it inspirer, inspired. I am sure inspirer is not a word so thats one problem. next is i have 2 functions, i want to pull a list of everyone i inspired and i was inspired by. inspired() and inspiredBy() can get confusing, so i need inspired as getInsp...

Should I capitalize constructor names for my classes?

I use camel case which has the first letter of all variable names, functions, etc lowercased. But the class names are capitalized. Should I use: class Foo { function foo() { } } or : class Foo { function Foo() { } } Which is a better convention? I'm confused. ...

Explanation of naming conventions for classes, methods and variables

I'm currently in University and they're pretty particular about following their standards. They've told me this: All classes must start with a capital letter Correct public class MyClass {} Incorrect public class myClass {} public class _myClass {} All methods must start with a lowercase letter Correct public voi...

Who "invented" i,j,k as integer counter variable names?

Possible Duplicate: Why are we using i as a counter in loops I've used these myself for more than 15 years but cannot really remember how/where I picked up that habit. As it is really widespread, I'm curious to know who originally suggested / recommended using these names for integer loop counters (was it the K&R book?). ...

What are all the most common method/variable/class names that you use?

Most common method/variable/class names that you use often and that explain you intent clearly and precisely.Is there any pattern you follow to figure that out. ...

How to receive a batch of checkbox data in PHP?

The key code is: while ($row= mysql_fetch_array($result, MYSQL_ASSOC)) { $id=$row[id]; $html=<<<html <tr><td> <input style="float:left" type="checkbox" name="mycheckbox[]" value="$id"> <span style="float:left">$row[content]</span> <span style="color:black;float:right">$row[submitter]</span></td></tr> html; echo $html; } Th...

When, if ever, should the name of a property contain the name of the class?

public class Fruit { // choose one public int Id { get; set; } public int FruitId get; set; } // redundant or usefully more descriptive? // choose one public string Name { get; set; } public string FruitName { get; set;} // redundant or usefully more descriptive? public string Fruit { get; set; } // or what ...

Good name for the opposite of the "canary" metaphor

The "canary" is a common metaphor (for example in buffer overflow checks) for detecting mis-behaving operations by setting a flag before and verifying that it is still set after. Is there a common term for the opposite, when the operation should kill the "canary"? ...

Naming a set of method,field,local var, and function

In writing a compiler grammar, I'm trying to come up with a name/label for a set of elements that include pretty much everything with an ident in it: method, field, local var and function I thought "members" first, but vars and functions aren't class members. Any ideas? EDIT: This is higher up than an identifier. Here's how it's use...

PHP - Worth including the data type in the variable name?

Hello! I'm trying to write my code as maintainable and easy to understand as possible, and I thought of including the type of data a variable holds in its name. e.g: $intCurrentLine = 1; instead of $currentLine = 1; $strUser = 'blah'; instead of $user = 'blah'; I don't think it is really necessary in the above example, but may it be...

Javascript and CSS, using dashes

I'm starting to learn some javascript and understand that dashes are not permitted when naming identifiers. However, in CSS it's common to use a dash for IDs and classes. Does using a dash in CSS interfere with javascript interaction somehow? For instance if I were to use getElementByID("css-dash-name"). I've tried a few examples us...

What is "POSNR" an abreviation or acronym for?

I'm working with some data that's coming out of an SAP system. There's a field named POSNR that appears to be a line item/database identifier of some kind. What is this an abbreviation for? It's not hyper-critical to what I'm doing, but every time I stare at the word it looks like pure gibberish and can be slightly distracting. ...

Why do I see JavaScript variables prefixed with $?

This is sort of a meta-question. Many snippets of JavaScript I've seen here on SO are named with a dollar sign prefix (for example, $id on the second line of the snippet shown in this question). I'm not referring to jQuery or other libraries. I am well aware that this is valid, but it seems awkward to do when not necessary. Why do pe...

Why are some variables in PHP written in uppercase?

Why does some code in PHP have to be written in uppercase? For instance: if(isSet($_GET['lang'])) $lang = $_GET['lang']; $_SESSION['lang'] = $lang; Do they work if I write them in lowercase? ...

Variable names of unordered set items without implied structure

This question will be asked in a specific form, but applies to a more general question, how to name unordered set items without implying any sort of structure. In terms of graph theory, a connected, undirected graph will contain vertices that are connected via edges. When creating an edge class with two member variables that are vertic...

Naming suggestions for a function returning parent prototype

I'm having a naming trouble with a function which returns parent prototype of specified object. It's being used like this: # Pseudo Code MyClass { super(MyClass,this).constructor.call(.... The problem is that I want to use a word which is as superior as "super", but "super" is reserved even it's undefined. Now I'm using "parent", b...

Java / Android self naming

I am about to start developing an Android application and had a question if in Java there self naming. For instance say I had a variable named dog that held the value of scruffy. Could I then create a variable named scruffy from that variable. In PHP it would be $$dog. That would make a variable with the name scruffy. If this is possi...

Someone is using the struct name as a variable name too. What does the code really say? (c++)

This morning we found an old chunk of code that was causing a library call to crash. struct fred { int a; int b; int c; }; fred fred[MAX_SIZE+1]; memset( fred, 0, sizeof(fred) * MAX_SIZE+1 ); It appears that the sizeof(fred) may have been the full array size, rather than the structure size, as it was ov...

How do you refer to the currently logged user in your code?

In other words - what would be a good name for a variable that references the currently logged user? I've come up with a few: logged_user visitor me I'm not convinced either of them is good enough though. ...