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...
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...
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.
...
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...
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?).
...
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.
...
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...
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 ...
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"?
...
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...
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...
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...
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.
...
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 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?
...
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...
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...
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...
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...
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.
...