English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

When you program and you need to create variables, let's say you're working on a program that needs a variable to hold some kind of money for the player, do you get to choose the variable names (within reason) or do you get a list of specific names you have to give variables? Like, could it be

player.coins
player.cash
player.money
etc?

I know this is along the lines of a C++/Java program, and it's probably not coded exactly right, but it's just an example, so please bear with me. ^_^ Thanks.

2007-07-11 05:51:26 · 4 answers · asked by Invader Z 1 in Computers & Internet Programming & Design

But I mean what if you work for a company?

2007-07-11 07:06:59 · update #1

4 answers

I've worked in Defense contracting and for a major telecommunications provider (two of the big bastions of corporate bureaucracy)... and I've never had anyone tell me what variable names to use.

There are often guidelines (variable names should be descriptive, and less than 20 character, etc.). And on a big project the design team will often dictate the names of important variables, classes, API methods, etc.

2007-07-11 07:14:44 · answer #1 · answered by McFate 7 · 0 0

There are often "naming conventions" in use. These often state specify abreviations that can be used. They often give the form. A member variable might have to be formated one way, function names another, local variables in another.
Something like

MyFunction
myMemberFunction
myvariable
my_member_variable

Beyond such naming conventions, variable names are nearly always left up to the individual programmer.

One exception: Function parameters names are often specified as part of the design.

2007-07-11 16:56:45 · answer #2 · answered by Bill G 2 · 0 0

Indeed you can name variables anyway you like, there is standard conventions used in java and c++.

C++ tends to use underscores while Java uses capitals, for example playerCoins, playerCash, playerMoney

Best to name your variables properly or you might forget what each variable means later on.

2007-07-11 14:21:19 · answer #3 · answered by Donny Dutch 4 · 0 0

When creating a program and your using variables you can name them anything you want. This is your program and your the programmer so you make the decisions. The only thing I suggest is no special characters such as (.,;:"!@#). I use the underscore from time to time but I try to avoid it if possible

2007-07-11 13:08:53 · answer #4 · answered by Anonymous · 0 0

fedest.com, questions and answers