variables

To foo bar, or not to foo bar: that is the question.

This was something originally discussed during a presentation given by Charles Brian Quinn of the Big Nerd Ranch at acts_as_conference. He was discussing what he had learned from instructing a Ruby on Rails Bootcamp to many people both new to programming and new to Rails. One particular slide that stood out was along the lines of never...

Variable Naming Conventions in C++

Hi All, I come from a .NET world and I'm new to writting C++. I'm just wondering what are the preferred naming conventions when it comes to naming local variables and struct members. For example, the legacy code that I've inheritted has alot of these: struct MyStruct { TCHAR szMyChar[STRING_SIZE]; bool bMyBo...

Is there a concise catalog of variable naming-conventions?

There are many different styles of variable names that I've come across over the years. The current wikipedia entry on naming conventions is fairly light... I'd love to see a concise catalog of variable naming-conventions, identifying it by a name/description, and some examples. If a convention is particularly favored by a certain...

Java - Abstract class to contain variables?

Is it good practice to let abstract classes define instance variables? public abstract class ExternalScript extends Script { String source; public abstract void setSource(String file); public abstract String getSource(); } The sub class, ExternalJavaScript.class, would then automatically get the source variable but I fe...

Transfer variables between PHP pages

I want to get user input in one page, store that in a php variable and use it in another php page. I have tried using 'sessions' but it doesn't seem to be working. Is there another safe alternative? This information is likely to be usernames and passwords. ...

Is there an easy way to use a base class's variables?

When you have a derived class, is there an simpler way to refer to a variable from a method other than: BaseClass::variable EDIT As it so happens, I found a page that explained this issue using functions instead: Template-Derived-Classes Errors. Apparently it makes a difference when using templates classes. ...

How best to implement user selectable variables in web application

I have a Java based web-application and a new requirement to allow Users to place variables into text fields that are replaced when a document or other output is produced. How have others gone about this? I was thinking of having a pre-defined set of variables such as : @BOOKING_NUMBER@ @INVOICE_NUMBER@ Then when a user enters some t...

Variable LIMIT Clause in MySQL

I am writing a stored procedure where I have an input parameter called my_size that is an int, I want to be able to use in a limit clause in a select statement. Apparently this is not supported, is there a way to work around this? # I want something like: SELECT * FROM some_table LIMIT my_size; # Instead of hardcoding a permanent limit...

What's bigger than a double?

Is there a native c++ variable type that's "bigger" than a double? float is 7 double is 15 (of course depending on the compiler) Is there anything bigger that's native, or even non-native? ...

Classes: Public vars or public functions to change local vars?

Exactly what the topic title says, In which cases would you prefer using public functions to change local variables over just defining that variable as public and modifying it directly? ...

Python - one variable equals another variable when it shouldn't

Here is my sample code. It is meant to be an iterative procedure for gauss seidel (matrix solver). Essentially when the error is small enough it breaks out of the while loop. i=1 while (i>0): x_past = x_present j=0 while(j<3): value=0 k=0 while(k<3): if(k!=j): if(i==1): ...

Java Instance Variable Accessibility

What is the difference in the accessibility of the following variables in Java? public class Joe { public int a; protected int b; private int b; int c; } I'm most interested in what the last one is doing. ...

Share variable across site ASP.NET

I have a class isSearching with a single boolean property in a 'functions' file in my webapp. On my search page, I have a variable oSearchHandler declared as a Public Shared variable. How can I access the contents of oSearchHandler on other pages in my webapp? Code with Session.... 'search.aspx Public Function oSearchString(ByVal oTe...

Uninitialized variables and members in Java

Consider this: public class TestClass { private String a; private String b; public TestClass() { a = "initialized"; } public void doSomething() { String c; a.notify(); // This is fine b.notify(); // This is fine - but will end in an exception c.notify(); // "Local variable c may not have been ...

Is it better in C++ to pass by value or pass by constant reference?

Is it better in C++ to pass by value or pass by constant reference? I am wondering which is better practice. I realize that pass by constant reference should provide for better performance in the program because you are not making a copy of the variable. ...

What is the difference between an int and a long in C++?

Correct me if I am wrong, int is 4 bytes, with a range of values from -2,147,483,648 to 2,147,483,647 (2^31) long is 4 bytes, with a range of values from -2,147,483,648 to 2,147,483,647 (2^31) What is the difference in C++? Can they be used interchangeably? ...

Should you access a variable within the same class via a Property?

If you have a Property that gets and sets to an instance variable then normally you always use the Property from outside that class to access it. My question is should you also always do so within the class? I've always used the Property if there is one, even within the class, but would like to hear some arguments for and against as to...

Does Perl have PHP-like dynamic variables?

Hello, In PHP, I can write: $vname = 'phone'; $$vname = '555-1234'; print $phone; ... And the script will output "555-1234". Is there any equivalent in Perl? Edit: Thanks, CMS. Is there any way to constrain $phone to the scope of the local block, as if I'd written "my $phone"? Using "my $$vname" gives me "Can't declare scalar dere...

Best way to substitute variables in plain text using PHP

What's the best way to take some plain text (not PHP code) which contains PHP-style variables, and then substitute in the value of the variable. This is kinda hard to describe, so here's an example. // -- myFile.txt -- Mary had a little $pet. // -- parser.php -- $pet = "lamb"; // open myFile.txt and transform it such that... $newConten...

Do you follow the naming convention of the original programmer?

If you take over a project from someone to do simple updates do you follow their naming convention? I just received a project where the previous programmer used Hungarian Notation everywhere. Our core product has a naming standard, but we've had a lot of people do custom reporting over the years and do whatever they felt like. I do no...