variables

.NET Integer vs Int16?

I have a questionable coding practice. When I need to iterate through a small list of items whose count limit is under 32000, I use Int16 for my i variable type instead of Integer. I do this because I assume using the int16 is more efficient than a full blown Integer. Am I wrong? Is there no effective performance difference (however ...

Is a variable named i unacceptable?

As far as variable naming conventions go, should iterators be named i or something more semantic like count? If you don't use i, why not? If you feel that i is acceptable, are there cases of iteration where it shouldn't be used? ...

What is the best method to convert to an Integer in JavaScript?

There are several different methods for converting floating point numbers to Integers in JavaScript. My question is what method gives the best performance, is most compatible, or is considered the best practice? Here are a few methods that I know of: var a = 2.5; window.parseInt(a); // 2 Math.floor(a); // 2 a | 0; // ...

Do you prefix your instance variable with 'this' in java ?

And... we have another QAW (Quality Assurance War) on our hand. After reading the more generic "What kind of prefix do you use for member variables?" question, I tried to argue with my QA department about the advantages to always add 'this' before instance (or member) variables in java code. They are not convinced. I know there is a si...

Whats a good naming convention for large scope function variables?

You can have different naming convention for class members, static objects, global objects, and structs. Some of the examples of them are as bellow. _member m_member or in java case, the usage of this.member But is there any good technique or naming convention for function variables scope. That convey when a single variable has complet...

Help a Newbie with C# variables

Okay this question is so basic it is probably in my book head first c#, but alas I am lazy :) Actually I read it and sort of understand and sort of don't. Here is what I have. I am trying to save data to a database on a button push but the variables seem to be private by the nature of where they are defined. I have tried to move where t...

What is the naming convention in Python for variable and function names?

Coming from a C# background the naming convention for variables and method names are usually either CamelCase or Pascal Case: // C# example string thisIsMyVariable = "a" public void ThisIsMyMethod() In Python, I have seen the above but I have also seen underscores being used: # python example this_is_my_variable = 'a' def this_is_my_...

.NET DBNull vs Nothing across all variable types?

I am a little confused about null values and variables in .NET. (VB preferred) Is there any way to check the "nullness" of ANY given variable regardless of whether it was an object or a value type? Or does my null check have to always anticipate whether it's checking a value type (e.g. System.Integer) or an object? I guess what I'm lo...

python dictionary update method

I have a list string tag. I am trying to initialize a dictionary with the key as the tag string and values as the array index. for i, ithTag in enumerate(tag): tagDict.update(ithTag=i) The above returns me {'ithTag': 608} 608 is the 608th index My problem is that while the i is being interpreted as a variable, Python is treatin...

Passing a variable to dtsx package results in unexpected precedence constraint evaluation

I have a dtsx package with a precedence constraint that evaluates an expression and a constraint. The constraint is "success" and the expression is "@myVariable" == 3. myVariable is an int32, and when set in Visual Studio's design GUI the package executes fine. There are two other paths that check for the value to be 1 or 2. However ...

Is there a way in VBA to know about variables that aren't being used?

Is there a tool, method or setting in VBA to warn about variables that have been DIMmed, but aren't being used? ...

Speed of multiple variable assignment in T-SQL

Imagine I have a chunk of initialisation code at the top of a stored procedure with a number of variable assignments: SET @proc = 'sp_madeupname' SET @magic_number = 42 SET @tomorrows_date = DATEADD(dd, 1, GETDATE()) ... Clearly doing all of the above as one SELECT would be faster: SELECT @proc = 'sp_madeupname' ,@magic_numb...

How to correctly name a variable which represents a value of 1 - n?

It obviously depends on the context you are using them in but, I was wondering if there is a universally accepted way to name such variables, or at least in a mathematical context. I've often seen: float k = someValue; float oneMinusK = 1 - k; ...which seems as descriptive as much as meaningless to me. Please note that I'm ...

What descriptive variable name can I use here?

I'm creating a custom Java Struts tag that is for building and formatting an html select box in a standardised way (part of our usability guidelines). Each select box has an additional/initial value which describes the requirement of the value returned by the select element, i.e.: Mandatory - with the label "Please Select" Optional - ...

Best name for array indexed by id with boolean value

I get obsessed with the best names for arrays and variables that I use, I'll look up words in the thesaurus, dictionary, etc.. So I'm trying to name this array / structure: $nameMe = array( '392' => TRUE, '234' => TRUE, '754' => TRUE, '464' => TRUE, ); and it's used to check if that id has a certain property, like so ...

Databases: Are "TEXT" fields less efficient than "varchar"?

Is it less efficient to use TEXT than varchar in an SQL database? If so why? If not why would you not just always use TEXT? I'm not targetting a specific database here but oracle is probably the most relevant, although I'm testing on MySQL for the time being as part of a proof of concept. ...

How do I interpolate variables to call a Perl function from a module?

Requirement is to pass module name and function name from the command-line argument. I need to get the command-line argument in the program and I need to call that function from that module For example, calling a try.pl program with 2 arguments: MODULE1(Module name) Display(Function name) perl try.pl MODULE1 Display I want to some t...

What's the point of the var keyword?

The var keyword does away with the need for an explicit type declaration and I have read with interest the SO discussion of when it might be appropriate. I have also read about (but not used) Boo which seems to take things a step further by making it optional to declare a local variable. With Boo, both the type and the declaration can ...

Placement of instance variable declarations

I've seen some developers put instance variable declarations at the end of classes though I mostly see them placed at the top. The only reasons I can think of for doing this are stylistic preference or maybe it somehow makes them easier to work with in an IDE. Is there a more legitimate reason for choosing this style? ...

Using PHP variables on multiple pages

Is it possible to use a variable from one page in a piece of code on another? e.g. submit a form on one page and on the second page use a PHP script to add the data from the form to a MySQL table Thanks for all the help ...