CSC/ECE 517 Fall 2010/ch5 5b mt: Difference between revisions
No edit summary |
|||
Line 47: | Line 47: | ||
==Quick Access Table== | ==Quick Access Table== | ||
<table> | |||
<tr> | |||
<th>Type</th> | |||
<th>Hungarian</th> | |||
<th>Ruby</th> | |||
<th>Java</th> | |||
<th>C</th> | |||
<th>.NET</th> | |||
</tr> | |||
<tr> | |||
<td>String</td> | |||
<td>String</td> | |||
<td>String</td> | |||
<td>String</td> | |||
<td>String</td> | |||
<td>String</td> | |||
</tr> | |||
<tr> | |||
<td>Number</td> | |||
<td>Number</td> | |||
<td>Number</td> | |||
<td>Number</td> | |||
<td>Number</td> | |||
<td>Number</td> | |||
</tr> | |||
</table> | |||
==Conclusions== | ==Conclusions== |
Revision as of 02:14, 3 November 2010
Variable Naming Conventions
Variables are used in all computer programming languages and are used for various reasons; such as, holding the value of a constant, holding the value of something used many times throughout the program, or used briefly for counting. The names used for each variable are more difficult to choose than simply making any word or word combination. The rest of this article is dedicated to helping the novice programmer determine variable names for different programming languages and purposes.
Introduction
A Variable is a name used within a program that holds the value of something that is known or unknown. For example, the variable "firstName" would be used to hold the string of letters that comprises a person's first name. The variable may not be set at the beginning of the program and it may change multiple times after being set. Naming conventions are a set of rules used to guide the programmer when creating the names of variables. Using the previous example, if there were no naming conventions, the variable could be named "fn", which is ambiguous and would be hard to follow when reading through many lines of code. Therefore, general naming conventions, which are incorporated by many languages are needed to aid the ability to follow the code without having the author present. General naming conventions are not perfect; thus, many coding languages have adopted their own type of convention. Furthermore, there are universally used variables and special types of variables that are used without regard for a language type.
||An example of multiple cites for the same resource [1] [1] If it doesn't have multiple cites for the same resource just leave off the a and b
||
The Good and the Bad
( really bad algorithm goes here )
( algorithm with short-names go here )
( original algorithm goes here )
Notable Naming Conventions
General Conventions
Hungarian
Universally Used Variables
Special Variable Conventions
Language Specific Conventions
||This is our second subtopic||
Ruby
Java
C/C++/C#
.NET
Quick Access Table
Type | Hungarian | Ruby | Java | C | .NET |
---|---|---|---|---|---|
String | String | String | String | String | String |
Number | Number | Number | Number | Number | Number |
Conclusions
Variables are inevitable in programming. The naming of variables must be taken with caution so that they make sense to any who read through the code. When creating names of variables the author should take into account the language of the code, the purpose of the variable, and the type of value the variable will hold. Adhering to naming conventions is not a requirement, but they are merely guides that a programmer can use to determine the best way to name the program's variables.
References
1. a, b Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/
Additional Resources
- Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367
- .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx
- C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html
- Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation
- Hungarian notation was invented by Microsoft programmer Charles Simonyi.
- While Hungarian notation can be applied to any programming language and environment, it was widely adopted by Microsoft for use with the C language, in particular for Microsoft Windows