<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Grepper</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Grepper"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Grepper"/>
	<updated>2026-06-26T17:36:10Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39900</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39900"/>
		<updated>2010-11-03T05:01:31Z</updated>

		<summary type="html">&lt;p&gt;Grepper: /* Hungarian */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As a popular saying goes, source code is meant to be read by humans; it is only a coincidence that it is also interpreted by machines.  Holding the data for source code, 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 choose good variable names and convention-styles for when writing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; might 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''||&lt;br /&gt;
&lt;br /&gt;
==Popular Naming Conventions==&lt;br /&gt;
&lt;br /&gt;
To establish consistency, several conventions have been popularized to give programmers a method for writing variable names.  For example, since in most programming languages white space is considered a delimiter for token parsing, one has to establish a non-whitespace system for separating two adjacent words for one variable.  If one wants to reference a &amp;quot;First Name&amp;quot; data string, there are many different ways we could establish a variable name for this.&lt;br /&gt;
&lt;br /&gt;
===Camel Case===&lt;br /&gt;
The format for Camel Case is to start the variable name off with a valid, lowercase letter, and then for each word afterwards, capitalize its first letter.  This allows each word to be easily distinguished without injecting any unnatural characters into the variable name.  For our &amp;quot;First Name&amp;quot; example, we would reference this as &amp;lt;code&amp;gt;firstName&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Hungarian===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Hungarian_notation Hungarian notation] is a naming convention that was intended to be used in any language. There are two types of this notation, Systems and Apps.  Systems notation requires the variable to be prefixed by the data type of the variable's use.  For example, a float number that is used to hold the value of the circumference of a sprocket would be defined as &amp;lt;span style=&amp;quot;color:darkred&amp;quot;&amp;gt;fSprocketCircumference&amp;lt;/span&amp;gt;. Apps notation requires the purpose of the variable it's prefix.  Using the previous example, the Apps definition would be &amp;lt;span style=&amp;quot;color:darkred&amp;quot;&amp;gt;numSprocketCircumference&amp;lt;/span&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In reference to our &amp;quot;First Name&amp;quot; example, notice how we wish to elaborate that this variable will hold a string.  A candidate Hungarian convention variable name could be &amp;lt;code&amp;gt;strFirstName&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Universally Used Variables===&lt;br /&gt;
There are commonly used variables that programmers use no matter what language he/she is coding in.  The following list does not constitute acceptance of the variables as properly named.  The most common are:&lt;br /&gt;
* i, j, k - used for counting especially in short code snippets&lt;br /&gt;
* x, y, z - used for holding the position of an object&lt;br /&gt;
* file - to indicate a placeholder for the location of a file&lt;br /&gt;
* dir - holds the string of a folder in a file system&lt;br /&gt;
* e - holds the value of the system error&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Special Variable Conventions===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Dos And Don'ts ==&lt;br /&gt;
&lt;br /&gt;
When picking your variable names, here are a few '''Do''' and '''Don'ts''' to consider.&lt;br /&gt;
&lt;br /&gt;
* Do use meaningful words&lt;br /&gt;
* Do use intention-revealing names (p 84 java book)&lt;br /&gt;
* Do be descriptive&lt;br /&gt;
* Do keep consistent in your naming convention&lt;br /&gt;
&lt;br /&gt;
* Don't ever name your variables, &amp;quot;data&amp;quot; ( http://www.oreillynet.com/onlamp/blog/2004/03/the_worlds_two_worst_variable.html )&lt;br /&gt;
&lt;br /&gt;
* Don't use needless variables, eg.&lt;br /&gt;
** &amp;lt;code&amp;gt;FOURTY_TWO = 42;&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;x = 4; one_more_than_x = x + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Don't give up!&lt;br /&gt;
&lt;br /&gt;
== Questions to Ask ==&lt;br /&gt;
&lt;br /&gt;
* Will my variable names by understood?&lt;br /&gt;
* Will they provide information to the maintenance programmer?&lt;br /&gt;
* Will they be easy to get right as more code is written?&lt;br /&gt;
* Will they get confused with one another?&lt;br /&gt;
&lt;br /&gt;
(Source http://www.wellho.net/solutions/general-what-makes-a-good-variable-name.html )&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Now that you have the basic tools an example that shows three types of naming, bad, okay, and good is used to help pull all of the information that has been given to this point.&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using really short variable names, can be difficult to understand.&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Finally, here is the same algorithm, with the original variable names from the [http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode source-example] (include reference number here).&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''Graph'', ''source''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''Graph'':&lt;br /&gt;
  3          dist[''v''] := infinity ;&lt;br /&gt;
  4          previous[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      dist[''source''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''Graph'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest dist[] ;&lt;br /&gt;
 10          '''if''' dist[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''alt'' := dist[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''alt'' &amp;lt; dist[''v'']:&lt;br /&gt;
 17                  dist[''v''] := ''alt'' ;&lt;br /&gt;
 18                  previous[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' dist[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
So finally, with meaningful variable names in place, it is much easier to understand the purpose of the code.  In fact, many may recognize it as Dijkstra's algorithm.  Comparing this well-named example to our first example shows just how important naming can be when writing code.&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39897</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39897"/>
		<updated>2010-11-03T04:56:29Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As a popular saying goes, source code is meant to be read by humans; it is only a coincidence that it is also interpreted by machines.  Holding the data for source code, 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 choose good variable names and convention-styles for when writing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; might 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using really short variable names, can be difficult to understand.&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Finally, here is the same algorithm, with the original variable names from the [http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode source-example] (include reference number here).&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''Graph'', ''source''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''Graph'':&lt;br /&gt;
  3          dist[''v''] := infinity ;&lt;br /&gt;
  4          previous[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      dist[''source''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''Graph'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest dist[] ;&lt;br /&gt;
 10          '''if''' dist[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''alt'' := dist[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''alt'' &amp;lt; dist[''v'']:&lt;br /&gt;
 17                  dist[''v''] := ''alt'' ;&lt;br /&gt;
 18                  previous[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' dist[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
So finally, with meaningful variable names in place, it is much easier to understand the purpose of the code.  In fact, many may recognize it as Dijkstra's algorithm.  Comparing this well-named example to our first example shows just how important naming can be when writing code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Popular Naming Conventions==&lt;br /&gt;
&lt;br /&gt;
To establish consistency, several conventions have been popularized to give programmers a method for writing variable names.  For example, since in most programming languages white space is considered a delimiter for token parsing, one has to establish a non-whitespace system for separating two adjacent words for one variable.  If one wants to reference a &amp;quot;First Name&amp;quot; data string, there are many different ways we could establish a variable name for this.&lt;br /&gt;
&lt;br /&gt;
===Camel Case===&lt;br /&gt;
The format for Camel Case is to start the variable name off with a valid, lowercase letter, and then for each word afterwards, capitalize its first letter.  This allows each word to be easily distinguished without injecting any unnatural characters into the variable name.  For our &amp;quot;First Name&amp;quot; example, we would reference this as &amp;lt;code&amp;gt;firstName&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Hungarian===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Hungarian_notation Hungarian notation] is a naming convention that was intended to be used in any language. There are two types of this notation, Systems and Apps.  Systems notation requires the variable to be prefixed by the data type of the variable's use.  For example, a float number that is used to hold the value of the circumference of a sprocket would be defined as &amp;lt;span style=&amp;quot;color:darkred&amp;quot;&amp;gt;fSprocketCircumference&amp;lt;/span&amp;gt;. Apps notation requires the purpose of the variable it's prefix.  Using the previous example, the Apps definition would be &amp;lt;span style=&amp;quot;color:darkred&amp;quot;&amp;gt;numSprocketCircumference&amp;lt;/span&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Universally Used Variables===&lt;br /&gt;
There are commonly used variables that programmers use no matter what language he/she is coding in.  The following list does not constitute acceptance of the variables as properly named.  The most common are:&lt;br /&gt;
* i, j, k - used for counting especially in short code snippets&lt;br /&gt;
* x, y, z - used for holding the position of an object&lt;br /&gt;
* file - to indicate a placeholder for the location of a file&lt;br /&gt;
* dir - holds the string of a folder in a file system&lt;br /&gt;
* e - holds the value of the system error&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Special Variable Conventions===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Dos And Don'ts ==&lt;br /&gt;
&lt;br /&gt;
When picking your variable names, here are a few '''Do''' and '''Don'ts''' to consider.&lt;br /&gt;
&lt;br /&gt;
* Do use meaningful words&lt;br /&gt;
* Do use intention-revealing names (p 84 java book)&lt;br /&gt;
* Do be descriptive&lt;br /&gt;
* Do keep consistent in your naming convention&lt;br /&gt;
&lt;br /&gt;
* Don't ever name your variables, &amp;quot;data&amp;quot; ( http://www.oreillynet.com/onlamp/blog/2004/03/the_worlds_two_worst_variable.html )&lt;br /&gt;
&lt;br /&gt;
* Don't use needless variables, eg.&lt;br /&gt;
** &amp;lt;code&amp;gt;FOURTY_TWO = 42;&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;x = 4; one_more_than_x = x + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Don't give up!&lt;br /&gt;
&lt;br /&gt;
== Questions to Ask ==&lt;br /&gt;
&lt;br /&gt;
* Will my variable names by understood?&lt;br /&gt;
* Will they provide information to the maintenance programmer?&lt;br /&gt;
* Will they be easy to get right as more code is written?&lt;br /&gt;
* Will they get confused with one another?&lt;br /&gt;
&lt;br /&gt;
(Source http://www.wellho.net/solutions/general-what-makes-a-good-variable-name.html )&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39896</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39896"/>
		<updated>2010-11-03T04:53:20Z</updated>

		<summary type="html">&lt;p&gt;Grepper: /* Popular Naming Conventions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As a popular saying goes, source code is meant to be read by humans; it is only a coincidence that it is also interpreted by machines.  Holding the data for source code, 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 choose good variable names and convention-styles for when writing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; might 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using really short variable names, can be difficult to understand.&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Finally, here is the same algorithm, with the original variable names from the [http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode source-example] (include reference number here).&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''Graph'', ''source''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''Graph'':&lt;br /&gt;
  3          dist[''v''] := infinity ;&lt;br /&gt;
  4          previous[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      dist[''source''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''Graph'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest dist[] ;&lt;br /&gt;
 10          '''if''' dist[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''alt'' := dist[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''alt'' &amp;lt; dist[''v'']:&lt;br /&gt;
 17                  dist[''v''] := ''alt'' ;&lt;br /&gt;
 18                  previous[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' dist[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
So finally, with meaningful variable names in place, it is much easier to understand the purpose of the code.  In fact, many may recognize it as Dijkstra's algorithm.  Comparing this well-named example to our first example shows just how important naming can be when writing code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Popular Naming Conventions==&lt;br /&gt;
&lt;br /&gt;
To establish consistency, several conventions have been popularized to give programmers a method for writing variable names.  For example, since in most programming languages white space is considered a delimiter for token parsing, one has to establish a non-whitespace system for separating two adjacent words for one variable.  If one wants to reference a &amp;quot;First Name&amp;quot; data string, there are many different ways we could establish a variable name for this.&lt;br /&gt;
&lt;br /&gt;
===Hungarian===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Hungarian_notation Hungarian notation] is a naming convention that was intended to be used in any language. There are two types of this notation, Systems and Apps.  Systems notation requires the variable to be prefixed by the data type of the variable's use.  For example, a float number that is used to hold the value of the circumference of a sprocket would be defined as &amp;lt;span style=&amp;quot;color:darkred&amp;quot;&amp;gt;fSprocketCircumference&amp;lt;/span&amp;gt;. Apps notation requires the purpose of the variable it's prefix.  Using the previous example, the Apps definition would be &amp;lt;span style=&amp;quot;color:darkred&amp;quot;&amp;gt;numSprocketCircumference&amp;lt;/span&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Universally Used Variables===&lt;br /&gt;
There are commonly used variables that programmers use no matter what language he/she is coding in.  The following list does not constitute acceptance of the variables as properly named.  The most common are:&lt;br /&gt;
* i, j, k - used for counting especially in short code snippets&lt;br /&gt;
* x, y, z - used for holding the position of an object&lt;br /&gt;
* file - to indicate a placeholder for the location of a file&lt;br /&gt;
* dir - holds the string of a folder in a file system&lt;br /&gt;
* e - holds the value of the system error&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Special Variable Conventions===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Dos And Don'ts ==&lt;br /&gt;
&lt;br /&gt;
When picking your variable names, here are a few '''Do''' and '''Don'ts''' to consider.&lt;br /&gt;
&lt;br /&gt;
* Do use meaningful words&lt;br /&gt;
* Do use intention-revealing names (p 84 java book)&lt;br /&gt;
* Do be descriptive&lt;br /&gt;
* Do keep consistent in your naming convention&lt;br /&gt;
&lt;br /&gt;
* Don't ever name your variables, &amp;quot;data&amp;quot; ( http://www.oreillynet.com/onlamp/blog/2004/03/the_worlds_two_worst_variable.html )&lt;br /&gt;
&lt;br /&gt;
* Don't use needless variables, eg.&lt;br /&gt;
** &amp;lt;code&amp;gt;FOURTY_TWO = 42;&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;x = 4; one_more_than_x = x + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Don't give up!&lt;br /&gt;
&lt;br /&gt;
== Questions to Ask ==&lt;br /&gt;
&lt;br /&gt;
* Will my variable names by understood?&lt;br /&gt;
* Will they provide information to the maintenance programmer?&lt;br /&gt;
* Will they be easy to get right as more code is written?&lt;br /&gt;
* Will they get confused with one another?&lt;br /&gt;
&lt;br /&gt;
(Source http://www.wellho.net/solutions/general-what-makes-a-good-variable-name.html )&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39895</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39895"/>
		<updated>2010-11-03T04:53:01Z</updated>

		<summary type="html">&lt;p&gt;Grepper: /* Popular Naming Conventions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As a popular saying goes, source code is meant to be read by humans; it is only a coincidence that it is also interpreted by machines.  Holding the data for source code, 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 choose good variable names and convention-styles for when writing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; might 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using really short variable names, can be difficult to understand.&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Finally, here is the same algorithm, with the original variable names from the [http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode source-example] (include reference number here).&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''Graph'', ''source''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''Graph'':&lt;br /&gt;
  3          dist[''v''] := infinity ;&lt;br /&gt;
  4          previous[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      dist[''source''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''Graph'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest dist[] ;&lt;br /&gt;
 10          '''if''' dist[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''alt'' := dist[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''alt'' &amp;lt; dist[''v'']:&lt;br /&gt;
 17                  dist[''v''] := ''alt'' ;&lt;br /&gt;
 18                  previous[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' dist[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
So finally, with meaningful variable names in place, it is much easier to understand the purpose of the code.  In fact, many may recognize it as Dijkstra's algorithm.  Comparing this well-named example to our first example shows just how important naming can be when writing code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Popular Naming Conventions==&lt;br /&gt;
&lt;br /&gt;
To establish consistency, several conventions have been popularized to give programmers a method for writing variable names.  For example, since in most programming languages white space is considered a delimiter for token parsing, one has to establish a system for separating two adjacent words for one variable.  If one wants to reference a &amp;quot;First Name&amp;quot; data string, there are many different ways we could establish a variable name for this.&lt;br /&gt;
&lt;br /&gt;
===Hungarian===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Hungarian_notation Hungarian notation] is a naming convention that was intended to be used in any language. There are two types of this notation, Systems and Apps.  Systems notation requires the variable to be prefixed by the data type of the variable's use.  For example, a float number that is used to hold the value of the circumference of a sprocket would be defined as &amp;lt;span style=&amp;quot;color:darkred&amp;quot;&amp;gt;fSprocketCircumference&amp;lt;/span&amp;gt;. Apps notation requires the purpose of the variable it's prefix.  Using the previous example, the Apps definition would be &amp;lt;span style=&amp;quot;color:darkred&amp;quot;&amp;gt;numSprocketCircumference&amp;lt;/span&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Universally Used Variables===&lt;br /&gt;
There are commonly used variables that programmers use no matter what language he/she is coding in.  The following list does not constitute acceptance of the variables as properly named.  The most common are:&lt;br /&gt;
* i, j, k - used for counting especially in short code snippets&lt;br /&gt;
* x, y, z - used for holding the position of an object&lt;br /&gt;
* file - to indicate a placeholder for the location of a file&lt;br /&gt;
* dir - holds the string of a folder in a file system&lt;br /&gt;
* e - holds the value of the system error&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Special Variable Conventions===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Dos And Don'ts ==&lt;br /&gt;
&lt;br /&gt;
When picking your variable names, here are a few '''Do''' and '''Don'ts''' to consider.&lt;br /&gt;
&lt;br /&gt;
* Do use meaningful words&lt;br /&gt;
* Do use intention-revealing names (p 84 java book)&lt;br /&gt;
* Do be descriptive&lt;br /&gt;
* Do keep consistent in your naming convention&lt;br /&gt;
&lt;br /&gt;
* Don't ever name your variables, &amp;quot;data&amp;quot; ( http://www.oreillynet.com/onlamp/blog/2004/03/the_worlds_two_worst_variable.html )&lt;br /&gt;
&lt;br /&gt;
* Don't use needless variables, eg.&lt;br /&gt;
** &amp;lt;code&amp;gt;FOURTY_TWO = 42;&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;x = 4; one_more_than_x = x + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Don't give up!&lt;br /&gt;
&lt;br /&gt;
== Questions to Ask ==&lt;br /&gt;
&lt;br /&gt;
* Will my variable names by understood?&lt;br /&gt;
* Will they provide information to the maintenance programmer?&lt;br /&gt;
* Will they be easy to get right as more code is written?&lt;br /&gt;
* Will they get confused with one another?&lt;br /&gt;
&lt;br /&gt;
(Source http://www.wellho.net/solutions/general-what-makes-a-good-variable-name.html )&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39894</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39894"/>
		<updated>2010-11-03T04:52:41Z</updated>

		<summary type="html">&lt;p&gt;Grepper: /* Popular Naming Conventions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As a popular saying goes, source code is meant to be read by humans; it is only a coincidence that it is also interpreted by machines.  Holding the data for source code, 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 choose good variable names and convention-styles for when writing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; might 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using really short variable names, can be difficult to understand.&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Finally, here is the same algorithm, with the original variable names from the [http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode source-example] (include reference number here).&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''Graph'', ''source''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''Graph'':&lt;br /&gt;
  3          dist[''v''] := infinity ;&lt;br /&gt;
  4          previous[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      dist[''source''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''Graph'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest dist[] ;&lt;br /&gt;
 10          '''if''' dist[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''alt'' := dist[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''alt'' &amp;lt; dist[''v'']:&lt;br /&gt;
 17                  dist[''v''] := ''alt'' ;&lt;br /&gt;
 18                  previous[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' dist[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
So finally, with meaningful variable names in place, it is much easier to understand the purpose of the code.  In fact, many may recognize it as Dijkstra's algorithm.  Comparing this well-named example to our first example shows just how important naming can be when writing code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Popular Naming Conventions==&lt;br /&gt;
&lt;br /&gt;
To establish consistency, several conventions have been established to give programmers a method for writing variable names.  For example, since in most programming languages white space is considered a delimiter for token parsing, one has to establish a system for separating two adjacent words for one variable.  If one wants to reference a &amp;quot;First Name&amp;quot; data string, there are many different ways we could establish a variable name for this.&lt;br /&gt;
&lt;br /&gt;
===Hungarian===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Hungarian_notation Hungarian notation] is a naming convention that was intended to be used in any language. There are two types of this notation, Systems and Apps.  Systems notation requires the variable to be prefixed by the data type of the variable's use.  For example, a float number that is used to hold the value of the circumference of a sprocket would be defined as &amp;lt;span style=&amp;quot;color:darkred&amp;quot;&amp;gt;fSprocketCircumference&amp;lt;/span&amp;gt;. Apps notation requires the purpose of the variable it's prefix.  Using the previous example, the Apps definition would be &amp;lt;span style=&amp;quot;color:darkred&amp;quot;&amp;gt;numSprocketCircumference&amp;lt;/span&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Universally Used Variables===&lt;br /&gt;
There are commonly used variables that programmers use no matter what language he/she is coding in.  The following list does not constitute acceptance of the variables as properly named.  The most common are:&lt;br /&gt;
* i, j, k - used for counting especially in short code snippets&lt;br /&gt;
* x, y, z - used for holding the position of an object&lt;br /&gt;
* file - to indicate a placeholder for the location of a file&lt;br /&gt;
* dir - holds the string of a folder in a file system&lt;br /&gt;
* e - holds the value of the system error&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Special Variable Conventions===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Dos And Don'ts ==&lt;br /&gt;
&lt;br /&gt;
When picking your variable names, here are a few '''Do''' and '''Don'ts''' to consider.&lt;br /&gt;
&lt;br /&gt;
* Do use meaningful words&lt;br /&gt;
* Do use intention-revealing names (p 84 java book)&lt;br /&gt;
* Do be descriptive&lt;br /&gt;
* Do keep consistent in your naming convention&lt;br /&gt;
&lt;br /&gt;
* Don't ever name your variables, &amp;quot;data&amp;quot; ( http://www.oreillynet.com/onlamp/blog/2004/03/the_worlds_two_worst_variable.html )&lt;br /&gt;
&lt;br /&gt;
* Don't use needless variables, eg.&lt;br /&gt;
** &amp;lt;code&amp;gt;FOURTY_TWO = 42;&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;x = 4; one_more_than_x = x + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Don't give up!&lt;br /&gt;
&lt;br /&gt;
== Questions to Ask ==&lt;br /&gt;
&lt;br /&gt;
* Will my variable names by understood?&lt;br /&gt;
* Will they provide information to the maintenance programmer?&lt;br /&gt;
* Will they be easy to get right as more code is written?&lt;br /&gt;
* Will they get confused with one another?&lt;br /&gt;
&lt;br /&gt;
(Source http://www.wellho.net/solutions/general-what-makes-a-good-variable-name.html )&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39892</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39892"/>
		<updated>2010-11-03T04:46:15Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As a popular saying goes, source code is meant to be read by humans; it is only a coincidence that it is also interpreted by machines.  Holding the data for source code, 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 choose good variable names and convention-styles for when writing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; might 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using really short variable names, can be difficult to understand.&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Finally, here is the same algorithm, with the original variable names from the [http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode source-example] (include reference number here).&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''Graph'', ''source''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''Graph'':&lt;br /&gt;
  3          dist[''v''] := infinity ;&lt;br /&gt;
  4          previous[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      dist[''source''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''Graph'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest dist[] ;&lt;br /&gt;
 10          '''if''' dist[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''alt'' := dist[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''alt'' &amp;lt; dist[''v'']:&lt;br /&gt;
 17                  dist[''v''] := ''alt'' ;&lt;br /&gt;
 18                  previous[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' dist[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
So finally, with meaningful variable names in place, it is much easier to understand the purpose of the code.  In fact, many may recognize it as Dijkstra's algorithm.  Comparing this well-named example to our first example shows just how important naming can be when writing code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Popular Naming Conventions==&lt;br /&gt;
===Hungarian===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Hungarian_notation Hungarian notation] is a naming convention that was intended to be used in any language. There are two types of this notation, Systems and Apps.  Systems notation requires the variable to be prefixed by the data type of the variable's use.  For example, a float number that is used to hold the value of the circumference of a sprocket would be defined as &amp;lt;span style=&amp;quot;color:darkblue&amp;quot;&amp;gt;fSprocketCircumference&amp;lt;/span&amp;gt;. Apps notation requires the purpose of the variable it's prefix.  Using the previous example, the Apps definition would be &amp;lt;span style=&amp;quot;color:darkblue&amp;quot;&amp;gt;numSprocketCircumference&amp;lt;/span&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Universally Used Variables===&lt;br /&gt;
There are commonly used variables that programmers use no matter what language he/she is coding in.  The following list does not constitute acceptance of the variables as properly named.  The most common are:&lt;br /&gt;
* i, j, k - used for counting especially in short code snippets&lt;br /&gt;
* x, y, z - used for holding the position of an object&lt;br /&gt;
* file - to indicate a placeholder for the location of a file&lt;br /&gt;
* dir - holds the string of a folder in a file system&lt;br /&gt;
* e - holds the value of the system error&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Special Variable Conventions===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Dos And Don'ts ==&lt;br /&gt;
&lt;br /&gt;
When picking your variable names, here are a few '''Do''' and '''Don'ts''' to consider.&lt;br /&gt;
&lt;br /&gt;
* Do use meaningful words&lt;br /&gt;
* Do use intention-revealing names (p 84 java book)&lt;br /&gt;
* Do be descriptive&lt;br /&gt;
* Do keep consistent in your naming convention&lt;br /&gt;
&lt;br /&gt;
* Don't ever name your variables, &amp;quot;data&amp;quot; ( http://www.oreillynet.com/onlamp/blog/2004/03/the_worlds_two_worst_variable.html )&lt;br /&gt;
&lt;br /&gt;
* Don't use needless variables, eg.&lt;br /&gt;
** &amp;lt;code&amp;gt;FOURTY_TWO = 42;&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;x = 4; one_more_than_x = x + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Don't give up!&lt;br /&gt;
&lt;br /&gt;
== Questions to Ask ==&lt;br /&gt;
&lt;br /&gt;
* Will my variable names by understood?&lt;br /&gt;
* Will they provide information to the maintenance programmer?&lt;br /&gt;
* Will they be easy to get right as more code is written?&lt;br /&gt;
* Will they get confused with one another?&lt;br /&gt;
&lt;br /&gt;
(Source http://www.wellho.net/solutions/general-what-makes-a-good-variable-name.html )&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39890</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39890"/>
		<updated>2010-11-03T04:41:42Z</updated>

		<summary type="html">&lt;p&gt;Grepper: /* Dos And Don'ts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As a popular saying goes, source code is meant to be read by humans; it is only a coincidence that it is also interpreted by machines.  Holding the data for source code, 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 choose good variable names and convention-styles for when writing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; might 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using really short variable names, can be difficult to understand.&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Finally, here is the same algorithm, with the original variable names from the [http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode source-example] (include reference number here).&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''Graph'', ''source''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''Graph'':&lt;br /&gt;
  3          dist[''v''] := infinity ;&lt;br /&gt;
  4          previous[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      dist[''source''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''Graph'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest dist[] ;&lt;br /&gt;
 10          '''if''' dist[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''alt'' := dist[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''alt'' &amp;lt; dist[''v'']:&lt;br /&gt;
 17                  dist[''v''] := ''alt'' ;&lt;br /&gt;
 18                  previous[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' dist[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
So finally, with meaningful variable names in place, it is much easier to understand the purpose of the code.  In fact, many may recognize it as Dijkstra's algorithm.  Comparing this well-named example to our first example shows just how important naming can be when writing code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notable Naming Conventions==&lt;br /&gt;
===General Conventions===&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Hungarian====&lt;br /&gt;
&lt;br /&gt;
====Universally Used Variables====&lt;br /&gt;
&lt;br /&gt;
====Special Variable Conventions====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Dos And Don'ts ==&lt;br /&gt;
&lt;br /&gt;
When picking your variable names, here are a few '''Do''' and '''Don'ts''' to consider.&lt;br /&gt;
&lt;br /&gt;
* Do use meaningful words&lt;br /&gt;
* Do use intention-revealing names (p 84 java book)&lt;br /&gt;
* Do be descriptive&lt;br /&gt;
* Do keep consistent in your naming convention&lt;br /&gt;
&lt;br /&gt;
* Don't ever name your variables, &amp;quot;data&amp;quot; ( http://www.oreillynet.com/onlamp/blog/2004/03/the_worlds_two_worst_variable.html )&lt;br /&gt;
&lt;br /&gt;
* Don't use needless variables, eg.&lt;br /&gt;
** &amp;lt;code&amp;gt;FOURTY_TWO = 42;&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;x = 4; one_more_than_x = x + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Don't give up!&lt;br /&gt;
&lt;br /&gt;
== Questions to Ask ==&lt;br /&gt;
&lt;br /&gt;
* Will my variable names by understood?&lt;br /&gt;
* Will they provide information to the maintenance programmer?&lt;br /&gt;
* Will they be easy to get right as more code is written?&lt;br /&gt;
* Will they get confused with one another?&lt;br /&gt;
&lt;br /&gt;
(Source http://www.wellho.net/solutions/general-what-makes-a-good-variable-name.html )&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39889</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39889"/>
		<updated>2010-11-03T04:41:29Z</updated>

		<summary type="html">&lt;p&gt;Grepper: /* Dos And Don'ts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As a popular saying goes, source code is meant to be read by humans; it is only a coincidence that it is also interpreted by machines.  Holding the data for source code, 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 choose good variable names and convention-styles for when writing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; might 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using really short variable names, can be difficult to understand.&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Finally, here is the same algorithm, with the original variable names from the [http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode source-example] (include reference number here).&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''Graph'', ''source''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''Graph'':&lt;br /&gt;
  3          dist[''v''] := infinity ;&lt;br /&gt;
  4          previous[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      dist[''source''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''Graph'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest dist[] ;&lt;br /&gt;
 10          '''if''' dist[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''alt'' := dist[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''alt'' &amp;lt; dist[''v'']:&lt;br /&gt;
 17                  dist[''v''] := ''alt'' ;&lt;br /&gt;
 18                  previous[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' dist[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
So finally, with meaningful variable names in place, it is much easier to understand the purpose of the code.  In fact, many may recognize it as Dijkstra's algorithm.  Comparing this well-named example to our first example shows just how important naming can be when writing code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notable Naming Conventions==&lt;br /&gt;
===General Conventions===&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Hungarian====&lt;br /&gt;
&lt;br /&gt;
====Universally Used Variables====&lt;br /&gt;
&lt;br /&gt;
====Special Variable Conventions====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Dos And Don'ts ==&lt;br /&gt;
&lt;br /&gt;
When picking your variable names, here are a few '''Do''' and '''Don'ts''' to consider.&lt;br /&gt;
&lt;br /&gt;
* Do use meaningful words&lt;br /&gt;
* Do use intention-revealing names (p 84 java book)&lt;br /&gt;
* Do be descriptive&lt;br /&gt;
* Do keep consistent in your naming convention&lt;br /&gt;
&lt;br /&gt;
* Don't ever name your variables, &amp;quot;data&amp;quot; ( http://www.oreillynet.com/onlamp/blog/2004/03/the_worlds_two_worst_variable.html )&lt;br /&gt;
&lt;br /&gt;
* Don't use needless variables, eg.&lt;br /&gt;
** &amp;lt;code&amp;gt;FOURTY_TWO = 42;&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;code&amp;gt;x = 4; one_more_than_x = x + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Don't give up!&lt;br /&gt;
&lt;br /&gt;
== Questions to Ask ==&lt;br /&gt;
&lt;br /&gt;
* Will my variable names by understood?&lt;br /&gt;
* Will they provide information to the maintenance programmer?&lt;br /&gt;
* Will they be easy to get right as more code is written?&lt;br /&gt;
* Will they get confused with one another?&lt;br /&gt;
&lt;br /&gt;
(Source http://www.wellho.net/solutions/general-what-makes-a-good-variable-name.html )&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39888</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39888"/>
		<updated>2010-11-03T04:22:32Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As a popular saying goes, source code is meant to be read by humans; it is only a coincidence that it is also interpreted by machines.  Holding the data for source code, 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 choose good variable names and convention-styles for when writing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; might 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using really short variable names, can be difficult to understand.&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Finally, here is the same algorithm, with the original variable names from the [http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode source-example] (include reference number here).&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''Graph'', ''source''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''Graph'':&lt;br /&gt;
  3          dist[''v''] := infinity ;&lt;br /&gt;
  4          previous[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      dist[''source''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''Graph'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest dist[] ;&lt;br /&gt;
 10          '''if''' dist[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''alt'' := dist[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''alt'' &amp;lt; dist[''v'']:&lt;br /&gt;
 17                  dist[''v''] := ''alt'' ;&lt;br /&gt;
 18                  previous[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' dist[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
So finally, with meaningful variable names in place, it is much easier to understand the purpose of the code.  In fact, many may recognize it as Dijkstra's algorithm.  Comparing this well-named example to our first example shows just how important naming can be when writing code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notable Naming Conventions==&lt;br /&gt;
===General Conventions===&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Hungarian====&lt;br /&gt;
&lt;br /&gt;
====Universally Used Variables====&lt;br /&gt;
&lt;br /&gt;
====Special Variable Conventions====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Dos And Don'ts ==&lt;br /&gt;
&lt;br /&gt;
When picking your variable names, here are a few '''Do''' and '''Don'ts''' to consider.&lt;br /&gt;
&lt;br /&gt;
* Do use meaningful words&lt;br /&gt;
* Do use intention-revealing names (p 84 java book)&lt;br /&gt;
* Do be descriptive&lt;br /&gt;
* Do keep consistent in your naming convention&lt;br /&gt;
&lt;br /&gt;
* Don't ever name your variables, &amp;quot;data&amp;quot; ( http://www.oreillynet.com/onlamp/blog/2004/03/the_worlds_two_worst_variable.html )&lt;br /&gt;
* Don't give up!&lt;br /&gt;
&lt;br /&gt;
== Questions to Ask ==&lt;br /&gt;
&lt;br /&gt;
* Will my variable names by understood?&lt;br /&gt;
* Will they provide information to the maintenance programmer?&lt;br /&gt;
* Will they be easy to get right as more code is written?&lt;br /&gt;
* Will they get confused with one another?&lt;br /&gt;
&lt;br /&gt;
(Source http://www.wellho.net/solutions/general-what-makes-a-good-variable-name.html )&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39887</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39887"/>
		<updated>2010-11-03T04:17:45Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As a popular saying goes, source code is meant to be read by humans; it is only a coincident that it is also interpreted by machines.  Holding the data for source code, 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 choose good variable names and convention-styles for when writing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; might 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using really short variable names, can be difficult to understand.&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Finally, here is the same algorithm, with the original variable names from the [http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode source-example] (include reference number here).&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''Graph'', ''source''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''Graph'':&lt;br /&gt;
  3          dist[''v''] := infinity ;&lt;br /&gt;
  4          previous[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      dist[''source''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''Graph'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest dist[] ;&lt;br /&gt;
 10          '''if''' dist[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''alt'' := dist[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''alt'' &amp;lt; dist[''v'']:&lt;br /&gt;
 17                  dist[''v''] := ''alt'' ;&lt;br /&gt;
 18                  previous[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' dist[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
So finally, with meaningful variable names in place, it is much easier to understand the purpose of the code.  In fact, many may recognize it as Dijkstra's algorithm.  Comparing this well-named example to our first example shows just how important naming can be when writing code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notable Naming Conventions==&lt;br /&gt;
===General Conventions===&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Hungarian====&lt;br /&gt;
&lt;br /&gt;
====Universally Used Variables====&lt;br /&gt;
&lt;br /&gt;
====Special Variable Conventions====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Dos And Don'ts ==&lt;br /&gt;
&lt;br /&gt;
When picking your variable names, here are a few '''Do''' and '''Don'ts''' to consider.&lt;br /&gt;
&lt;br /&gt;
* Do use meaningful words&lt;br /&gt;
* Do use intention-revealing names (p 84 java book)&lt;br /&gt;
* Do be descriptive&lt;br /&gt;
* Do keep consistent in your naming convention&lt;br /&gt;
&lt;br /&gt;
* Don't ever name your variables, &amp;quot;data&amp;quot; ( http://www.oreillynet.com/onlamp/blog/2004/03/the_worlds_two_worst_variable.html )&lt;br /&gt;
* Don't give up!&lt;br /&gt;
&lt;br /&gt;
== Questions to Ask ==&lt;br /&gt;
&lt;br /&gt;
* Will my variable names by understood?&lt;br /&gt;
* Will they provide information to the maintenance programmer?&lt;br /&gt;
* Will they be easy to get right as more code is written?&lt;br /&gt;
* Will they get confused with one another?&lt;br /&gt;
&lt;br /&gt;
(Source http://www.wellho.net/solutions/general-what-makes-a-good-variable-name.html )&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39886</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39886"/>
		<updated>2010-11-03T04:17:17Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As a popular saying goes, source code is meant to be read by humans; it is only a coincident that it is also interpreted by machines.  Providing the data for source code, 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 choose good variable names and convention-styles for when writing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; might 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using really short variable names, can be difficult to understand.&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Finally, here is the same algorithm, with the original variable names from the [http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode source-example] (include reference number here).&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''Graph'', ''source''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''Graph'':&lt;br /&gt;
  3          dist[''v''] := infinity ;&lt;br /&gt;
  4          previous[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      dist[''source''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''Graph'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest dist[] ;&lt;br /&gt;
 10          '''if''' dist[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''alt'' := dist[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''alt'' &amp;lt; dist[''v'']:&lt;br /&gt;
 17                  dist[''v''] := ''alt'' ;&lt;br /&gt;
 18                  previous[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' dist[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
So finally, with meaningful variable names in place, it is much easier to understand the purpose of the code.  In fact, many may recognize it as Dijkstra's algorithm.  Comparing this well-named example to our first example shows just how important naming can be when writing code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notable Naming Conventions==&lt;br /&gt;
===General Conventions===&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Hungarian====&lt;br /&gt;
&lt;br /&gt;
====Universally Used Variables====&lt;br /&gt;
&lt;br /&gt;
====Special Variable Conventions====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Dos And Don'ts ==&lt;br /&gt;
&lt;br /&gt;
When picking your variable names, here are a few '''Do''' and '''Don'ts''' to consider.&lt;br /&gt;
&lt;br /&gt;
* Do use meaningful words&lt;br /&gt;
* Do use intention-revealing names (p 84 java book)&lt;br /&gt;
* Do be descriptive&lt;br /&gt;
* Do keep consistent in your naming convention&lt;br /&gt;
&lt;br /&gt;
* Don't ever name your variables, &amp;quot;data&amp;quot; ( http://www.oreillynet.com/onlamp/blog/2004/03/the_worlds_two_worst_variable.html )&lt;br /&gt;
* Don't give up!&lt;br /&gt;
&lt;br /&gt;
== Questions to Ask ==&lt;br /&gt;
&lt;br /&gt;
* Will my variable names by understood?&lt;br /&gt;
* Will they provide information to the maintenance programmer?&lt;br /&gt;
* Will they be easy to get right as more code is written?&lt;br /&gt;
* Will they get confused with one another?&lt;br /&gt;
&lt;br /&gt;
(Source http://www.wellho.net/solutions/general-what-makes-a-good-variable-name.html )&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39885</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39885"/>
		<updated>2010-11-03T04:16:10Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As a popular saying goes, source code is meant to be read by humans; it is only a coincident that it is also interpreted by machines.  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 choose good variable names and convention-styles for when writing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; might 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using really short variable names, can be difficult to understand.&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Finally, here is the same algorithm, with the original variable names from the [http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode source-example] (include reference number here).&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''Graph'', ''source''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''Graph'':&lt;br /&gt;
  3          dist[''v''] := infinity ;&lt;br /&gt;
  4          previous[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      dist[''source''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''Graph'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest dist[] ;&lt;br /&gt;
 10          '''if''' dist[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''alt'' := dist[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''alt'' &amp;lt; dist[''v'']:&lt;br /&gt;
 17                  dist[''v''] := ''alt'' ;&lt;br /&gt;
 18                  previous[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' dist[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
So finally, with meaningful variable names in place, it is much easier to understand the purpose of the code.  In fact, many may recognize it as Dijkstra's algorithm.  Comparing this well-named example to our first example shows just how important naming can be when writing code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notable Naming Conventions==&lt;br /&gt;
===General Conventions===&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Hungarian====&lt;br /&gt;
&lt;br /&gt;
====Universally Used Variables====&lt;br /&gt;
&lt;br /&gt;
====Special Variable Conventions====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Dos And Don'ts ==&lt;br /&gt;
&lt;br /&gt;
When picking your variable names, here are a few '''Do''' and '''Don'ts''' to consider.&lt;br /&gt;
&lt;br /&gt;
* Do use meaningful words&lt;br /&gt;
* Do use intention-revealing names (p 84 java book)&lt;br /&gt;
* Do be descriptive&lt;br /&gt;
* Do keep consistent in your naming convention&lt;br /&gt;
&lt;br /&gt;
* Don't ever name your variables, &amp;quot;data&amp;quot; ( http://www.oreillynet.com/onlamp/blog/2004/03/the_worlds_two_worst_variable.html )&lt;br /&gt;
* Don't give up!&lt;br /&gt;
&lt;br /&gt;
== Questions to Ask ==&lt;br /&gt;
&lt;br /&gt;
* Will my variable names by understood?&lt;br /&gt;
* Will they provide information to the maintenance programmer?&lt;br /&gt;
* Will they be easy to get right as more code is written?&lt;br /&gt;
* Will they get confused with one another?&lt;br /&gt;
&lt;br /&gt;
(Source http://www.wellho.net/solutions/general-what-makes-a-good-variable-name.html )&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39883</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39883"/>
		<updated>2010-11-03T04:04:51Z</updated>

		<summary type="html">&lt;p&gt;Grepper: /* Questions to Ask */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 choose good variable names and convention-styles for when writing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; might 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using really short variable names, can be difficult to understand.&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Finally, here is the same algorithm, with the original variable names from the [http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode source-example] (include reference number here).&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''Graph'', ''source''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''Graph'':&lt;br /&gt;
  3          dist[''v''] := infinity ;&lt;br /&gt;
  4          previous[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      dist[''source''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''Graph'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest dist[] ;&lt;br /&gt;
 10          '''if''' dist[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''alt'' := dist[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''alt'' &amp;lt; dist[''v'']:&lt;br /&gt;
 17                  dist[''v''] := ''alt'' ;&lt;br /&gt;
 18                  previous[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' dist[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
So finally, with meaningful variable names in place, it is much easier to understand the purpose of the code.  In fact, many may recognize it as Dijkstra's algorithm.  Comparing this well-named example to our first example shows just how important naming can be when writing code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notable Naming Conventions==&lt;br /&gt;
===General Conventions===&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Hungarian====&lt;br /&gt;
&lt;br /&gt;
====Universally Used Variables====&lt;br /&gt;
&lt;br /&gt;
====Special Variable Conventions====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Dos And Don'ts ==&lt;br /&gt;
&lt;br /&gt;
When picking your variable names, here are a few '''Do''' and '''Don'ts''' to consider.&lt;br /&gt;
&lt;br /&gt;
* Do use meaningful words&lt;br /&gt;
* Do use intention-revealing names (p 84 java book)&lt;br /&gt;
* Do be descriptive&lt;br /&gt;
* Do keep consistent in your naming convention&lt;br /&gt;
&lt;br /&gt;
* Don't ever name your variables, &amp;quot;data&amp;quot; ( http://www.oreillynet.com/onlamp/blog/2004/03/the_worlds_two_worst_variable.html )&lt;br /&gt;
* Don't give up!&lt;br /&gt;
&lt;br /&gt;
== Questions to Ask ==&lt;br /&gt;
&lt;br /&gt;
* Will my variable names by understood?&lt;br /&gt;
* Will they provide information to the maintenance programmer?&lt;br /&gt;
* Will they be easy to get right as more code is written?&lt;br /&gt;
* Will they get confused with one another?&lt;br /&gt;
&lt;br /&gt;
(Source http://www.wellho.net/solutions/general-what-makes-a-good-variable-name.html )&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39882</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39882"/>
		<updated>2010-11-03T04:04:17Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 choose good variable names and convention-styles for when writing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; might 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using really short variable names, can be difficult to understand.&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Finally, here is the same algorithm, with the original variable names from the [http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode source-example] (include reference number here).&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''Graph'', ''source''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''Graph'':&lt;br /&gt;
  3          dist[''v''] := infinity ;&lt;br /&gt;
  4          previous[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      dist[''source''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''Graph'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest dist[] ;&lt;br /&gt;
 10          '''if''' dist[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''alt'' := dist[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''alt'' &amp;lt; dist[''v'']:&lt;br /&gt;
 17                  dist[''v''] := ''alt'' ;&lt;br /&gt;
 18                  previous[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' dist[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
So finally, with meaningful variable names in place, it is much easier to understand the purpose of the code.  In fact, many may recognize it as Dijkstra's algorithm.  Comparing this well-named example to our first example shows just how important naming can be when writing code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notable Naming Conventions==&lt;br /&gt;
===General Conventions===&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Hungarian====&lt;br /&gt;
&lt;br /&gt;
====Universally Used Variables====&lt;br /&gt;
&lt;br /&gt;
====Special Variable Conventions====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Dos And Don'ts ==&lt;br /&gt;
&lt;br /&gt;
When picking your variable names, here are a few '''Do''' and '''Don'ts''' to consider.&lt;br /&gt;
&lt;br /&gt;
* Do use meaningful words&lt;br /&gt;
* Do use intention-revealing names (p 84 java book)&lt;br /&gt;
* Do be descriptive&lt;br /&gt;
* Do keep consistent in your naming convention&lt;br /&gt;
&lt;br /&gt;
* Don't ever name your variables, &amp;quot;data&amp;quot; ( http://www.oreillynet.com/onlamp/blog/2004/03/the_worlds_two_worst_variable.html )&lt;br /&gt;
* Don't give up!&lt;br /&gt;
&lt;br /&gt;
== Questions to Ask ==&lt;br /&gt;
&lt;br /&gt;
* Will my variable names by understood&lt;br /&gt;
* Will they provide information to the maintenance programmer&lt;br /&gt;
* Will they be easy to get right as more code is written&lt;br /&gt;
* Will they get confused with one another&lt;br /&gt;
&lt;br /&gt;
(Source http://www.wellho.net/solutions/general-what-makes-a-good-variable-name.html )&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39881</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39881"/>
		<updated>2010-11-03T03:54:44Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 choose good variable names and convention-styles for when writing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; might 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using really short variable names, can be difficult to understand.&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Finally, here is the same algorithm, with the original variable names from the [http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode source-example] (include reference number here).&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''Graph'', ''source''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''Graph'':&lt;br /&gt;
  3          dist[''v''] := infinity ;&lt;br /&gt;
  4          previous[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      dist[''source''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''Graph'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest dist[] ;&lt;br /&gt;
 10          '''if''' dist[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''alt'' := dist[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''alt'' &amp;lt; dist[''v'']:&lt;br /&gt;
 17                  dist[''v''] := ''alt'' ;&lt;br /&gt;
 18                  previous[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' dist[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
So finally, with meaningful variable names in place, it is much easier to understand the purpose of the code.  In fact, many may recognize it as Dijkstra's algorithm.  Comparing this well-named example to our first example shows just how important naming can be when writing code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notable Naming Conventions==&lt;br /&gt;
===General Conventions===&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Hungarian====&lt;br /&gt;
&lt;br /&gt;
====Universally Used Variables====&lt;br /&gt;
&lt;br /&gt;
====Special Variable Conventions====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Dos And Don'ts ==&lt;br /&gt;
&lt;br /&gt;
When picking your variable names, here are a few '''Do''' and '''Don'ts''' to consider.&lt;br /&gt;
&lt;br /&gt;
* Do use meaningful words&lt;br /&gt;
* Do use intention-revealing names (p 84 java book)&lt;br /&gt;
* Do be descriptive&lt;br /&gt;
* Do keep consistent in your naming convention&lt;br /&gt;
&lt;br /&gt;
* Don't ever name your variables, &amp;quot;data&amp;quot; ( http://www.oreillynet.com/onlamp/blog/2004/03/the_worlds_two_worst_variable.html )&lt;br /&gt;
* Don't give up!&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39880</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39880"/>
		<updated>2010-11-03T03:49:53Z</updated>

		<summary type="html">&lt;p&gt;Grepper: /* Dos And Don'ts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 choose good variable names and convention-styles for when writing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; might 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using really short variable names, can be difficult to understand.&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Finally, here is the same algorithm, with the original variable names from the [http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode source-example] (include reference number here).&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''Graph'', ''source''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''Graph'':&lt;br /&gt;
  3          dist[''v''] := infinity ;&lt;br /&gt;
  4          previous[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      dist[''source''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''Graph'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest dist[] ;&lt;br /&gt;
 10          '''if''' dist[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''alt'' := dist[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''alt'' &amp;lt; dist[''v'']:&lt;br /&gt;
 17                  dist[''v''] := ''alt'' ;&lt;br /&gt;
 18                  previous[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' dist[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
So finally, with meaningful variable names in place, it is much easier to understand the purpose of the code.  In fact, many may recognize it as Dijkstra's algorithm.  Comparing this well-named example to our first example shows just how important naming can be when writing code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notable Naming Conventions==&lt;br /&gt;
===General Conventions===&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Hungarian====&lt;br /&gt;
&lt;br /&gt;
====Universally Used Variables====&lt;br /&gt;
&lt;br /&gt;
====Special Variable Conventions====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Language Specific Conventions===&lt;br /&gt;
||This is our second subtopic||&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Ruby====&lt;br /&gt;
[http://www.ruby-lang.org/en/ Ruby] does not offer many suggestions for naming variables.  What it does offer is how certain variables must begin.  A normal variable is any concatenation of letter or number as long as a letter or underscore '_' is used at the beginning.  An [http://en.wikipedia.org/wiki/Instance_variable instance variable], which occurs in a class as multiple copies, begins with  '@'.  A [http://en.wikipedia.org/wiki/Class_variable class variable] only has one copy used for all instances of a class, begins with '@@'.  A [http://en.wikipedia.org/wiki/Global_variable global variable], which can be used from anywhere within the program, begins with '$'.&lt;br /&gt;
&lt;br /&gt;
====Java====&lt;br /&gt;
&lt;br /&gt;
====C/C++/C#====&lt;br /&gt;
&lt;br /&gt;
====.NET====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Quick Access Table==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Type&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Hungarian&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Ruby&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Java&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;C&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;.NET&amp;lt;/th&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Dos And Don'ts ==&lt;br /&gt;
&lt;br /&gt;
When picking your variable names, here are a few '''Do''' and '''Don'ts''' to consider.&lt;br /&gt;
&lt;br /&gt;
* Do use meaningful words&lt;br /&gt;
* Do use intention-revealing names (p 84 java book)&lt;br /&gt;
* Do be descriptive&lt;br /&gt;
* Do keep consistent in your naming convention&lt;br /&gt;
&lt;br /&gt;
* Don't ever name your variables, &amp;quot;data&amp;quot; ( http://www.oreillynet.com/onlamp/blog/2004/03/the_worlds_two_worst_variable.html )&lt;br /&gt;
* Don't give up!&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39879</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39879"/>
		<updated>2010-11-03T03:49:45Z</updated>

		<summary type="html">&lt;p&gt;Grepper: /* Dos And Don'ts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 choose good variable names and convention-styles for when writing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; might 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using really short variable names, can be difficult to understand.&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Finally, here is the same algorithm, with the original variable names from the [http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode source-example] (include reference number here).&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''Graph'', ''source''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''Graph'':&lt;br /&gt;
  3          dist[''v''] := infinity ;&lt;br /&gt;
  4          previous[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      dist[''source''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''Graph'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest dist[] ;&lt;br /&gt;
 10          '''if''' dist[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''alt'' := dist[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''alt'' &amp;lt; dist[''v'']:&lt;br /&gt;
 17                  dist[''v''] := ''alt'' ;&lt;br /&gt;
 18                  previous[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' dist[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
So finally, with meaningful variable names in place, it is much easier to understand the purpose of the code.  In fact, many may recognize it as Dijkstra's algorithm.  Comparing this well-named example to our first example shows just how important naming can be when writing code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notable Naming Conventions==&lt;br /&gt;
===General Conventions===&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Hungarian====&lt;br /&gt;
&lt;br /&gt;
====Universally Used Variables====&lt;br /&gt;
&lt;br /&gt;
====Special Variable Conventions====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Language Specific Conventions===&lt;br /&gt;
||This is our second subtopic||&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Ruby====&lt;br /&gt;
[http://www.ruby-lang.org/en/ Ruby] does not offer many suggestions for naming variables.  What it does offer is how certain variables must begin.  A normal variable is any concatenation of letter or number as long as a letter or underscore '_' is used at the beginning.  An [http://en.wikipedia.org/wiki/Instance_variable instance variable], which occurs in a class as multiple copies, begins with  '@'.  A [http://en.wikipedia.org/wiki/Class_variable class variable] only has one copy used for all instances of a class, begins with '@@'.  A [http://en.wikipedia.org/wiki/Global_variable global variable], which can be used from anywhere within the program, begins with '$'.&lt;br /&gt;
&lt;br /&gt;
====Java====&lt;br /&gt;
&lt;br /&gt;
====C/C++/C#====&lt;br /&gt;
&lt;br /&gt;
====.NET====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Quick Access Table==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Type&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Hungarian&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Ruby&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Java&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;C&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;.NET&amp;lt;/th&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Dos And Don'ts ==&lt;br /&gt;
&lt;br /&gt;
When picking your variable names, here are a few '''Do''' and '''Don'ts''' to consider.&lt;br /&gt;
&lt;br /&gt;
* Do use meaningful words&lt;br /&gt;
* Do use intention-revealing names (p 84 java book)&lt;br /&gt;
* Do be descriptive&lt;br /&gt;
* Do keep consistent in your naming convention&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Don't ever name your variables, &amp;quot;data&amp;quot; ( http://www.oreillynet.com/onlamp/blog/2004/03/the_worlds_two_worst_variable.html )&lt;br /&gt;
* Don't give up!&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39878</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39878"/>
		<updated>2010-11-03T03:49:33Z</updated>

		<summary type="html">&lt;p&gt;Grepper: /* Dos And Don'ts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 choose good variable names and convention-styles for when writing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; might 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using really short variable names, can be difficult to understand.&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Finally, here is the same algorithm, with the original variable names from the [http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode source-example] (include reference number here).&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''Graph'', ''source''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''Graph'':&lt;br /&gt;
  3          dist[''v''] := infinity ;&lt;br /&gt;
  4          previous[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      dist[''source''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''Graph'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest dist[] ;&lt;br /&gt;
 10          '''if''' dist[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''alt'' := dist[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''alt'' &amp;lt; dist[''v'']:&lt;br /&gt;
 17                  dist[''v''] := ''alt'' ;&lt;br /&gt;
 18                  previous[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' dist[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
So finally, with meaningful variable names in place, it is much easier to understand the purpose of the code.  In fact, many may recognize it as Dijkstra's algorithm.  Comparing this well-named example to our first example shows just how important naming can be when writing code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notable Naming Conventions==&lt;br /&gt;
===General Conventions===&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Hungarian====&lt;br /&gt;
&lt;br /&gt;
====Universally Used Variables====&lt;br /&gt;
&lt;br /&gt;
====Special Variable Conventions====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Language Specific Conventions===&lt;br /&gt;
||This is our second subtopic||&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Ruby====&lt;br /&gt;
[http://www.ruby-lang.org/en/ Ruby] does not offer many suggestions for naming variables.  What it does offer is how certain variables must begin.  A normal variable is any concatenation of letter or number as long as a letter or underscore '_' is used at the beginning.  An [http://en.wikipedia.org/wiki/Instance_variable instance variable], which occurs in a class as multiple copies, begins with  '@'.  A [http://en.wikipedia.org/wiki/Class_variable class variable] only has one copy used for all instances of a class, begins with '@@'.  A [http://en.wikipedia.org/wiki/Global_variable global variable], which can be used from anywhere within the program, begins with '$'.&lt;br /&gt;
&lt;br /&gt;
====Java====&lt;br /&gt;
&lt;br /&gt;
====C/C++/C#====&lt;br /&gt;
&lt;br /&gt;
====.NET====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Quick Access Table==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Type&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Hungarian&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Ruby&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Java&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;C&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;.NET&amp;lt;/th&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Dos And Don'ts ==&lt;br /&gt;
&lt;br /&gt;
When picking your variable names, here are a few '''Do''' and '''Don'ts''' to consider.&lt;br /&gt;
&lt;br /&gt;
* Do use meaningful words&lt;br /&gt;
* Do use intention-revealing names (p 84 java book)&lt;br /&gt;
* Do be descriptive&lt;br /&gt;
* Do keep consistent in your naming convention&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Don't ever name your variables, &amp;quot;data&amp;quot; ( http://www.oreillynet.com/onlamp/blog/2004/03/the_worlds_two_worst_variable.html )&lt;br /&gt;
* Don't give up!&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39877</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39877"/>
		<updated>2010-11-03T03:48:31Z</updated>

		<summary type="html">&lt;p&gt;Grepper: /* Dos And Don'ts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 choose good variable names and convention-styles for when writing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; might 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using really short variable names, can be difficult to understand.&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Finally, here is the same algorithm, with the original variable names from the [http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode source-example] (include reference number here).&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''Graph'', ''source''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''Graph'':&lt;br /&gt;
  3          dist[''v''] := infinity ;&lt;br /&gt;
  4          previous[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      dist[''source''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''Graph'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest dist[] ;&lt;br /&gt;
 10          '''if''' dist[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''alt'' := dist[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''alt'' &amp;lt; dist[''v'']:&lt;br /&gt;
 17                  dist[''v''] := ''alt'' ;&lt;br /&gt;
 18                  previous[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' dist[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
So finally, with meaningful variable names in place, it is much easier to understand the purpose of the code.  In fact, many may recognize it as Dijkstra's algorithm.  Comparing this well-named example to our first example shows just how important naming can be when writing code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notable Naming Conventions==&lt;br /&gt;
===General Conventions===&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Hungarian====&lt;br /&gt;
&lt;br /&gt;
====Universally Used Variables====&lt;br /&gt;
&lt;br /&gt;
====Special Variable Conventions====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Language Specific Conventions===&lt;br /&gt;
||This is our second subtopic||&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Ruby====&lt;br /&gt;
[http://www.ruby-lang.org/en/ Ruby] does not offer many suggestions for naming variables.  What it does offer is how certain variables must begin.  A normal variable is any concatenation of letter or number as long as a letter or underscore '_' is used at the beginning.  An [http://en.wikipedia.org/wiki/Instance_variable instance variable], which occurs in a class as multiple copies, begins with  '@'.  A [http://en.wikipedia.org/wiki/Class_variable class variable] only has one copy used for all instances of a class, begins with '@@'.  A [http://en.wikipedia.org/wiki/Global_variable global variable], which can be used from anywhere within the program, begins with '$'.&lt;br /&gt;
&lt;br /&gt;
====Java====&lt;br /&gt;
&lt;br /&gt;
====C/C++/C#====&lt;br /&gt;
&lt;br /&gt;
====.NET====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Quick Access Table==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Type&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Hungarian&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Ruby&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Java&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;C&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;.NET&amp;lt;/th&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Dos And Don'ts ==&lt;br /&gt;
&lt;br /&gt;
When picking your variable names, here are a few '''Do''' and '''Don'ts''' to consider.&lt;br /&gt;
&lt;br /&gt;
* Do use meaningful words&lt;br /&gt;
* Do use intention-revealing names (p 84 java book)&lt;br /&gt;
* Do be descriptive&lt;br /&gt;
* Do keep consistent in your naming convention&lt;br /&gt;
&lt;br /&gt;
* Don't ever name your variables, &amp;quot;data&amp;quot; ( http://www.oreillynet.com/onlamp/blog/2004/03/the_worlds_two_worst_variable.html )&lt;br /&gt;
* Don't give up!&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39876</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39876"/>
		<updated>2010-11-03T03:46:56Z</updated>

		<summary type="html">&lt;p&gt;Grepper: /* Dos And Don'ts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 choose good variable names and convention-styles for when writing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; might 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using really short variable names, can be difficult to understand.&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Finally, here is the same algorithm, with the original variable names from the [http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode source-example] (include reference number here).&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''Graph'', ''source''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''Graph'':&lt;br /&gt;
  3          dist[''v''] := infinity ;&lt;br /&gt;
  4          previous[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      dist[''source''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''Graph'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest dist[] ;&lt;br /&gt;
 10          '''if''' dist[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''alt'' := dist[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''alt'' &amp;lt; dist[''v'']:&lt;br /&gt;
 17                  dist[''v''] := ''alt'' ;&lt;br /&gt;
 18                  previous[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' dist[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
So finally, with meaningful variable names in place, it is much easier to understand the purpose of the code.  In fact, many may recognize it as Dijkstra's algorithm.  Comparing this well-named example to our first example shows just how important naming can be when writing code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notable Naming Conventions==&lt;br /&gt;
===General Conventions===&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Hungarian====&lt;br /&gt;
&lt;br /&gt;
====Universally Used Variables====&lt;br /&gt;
&lt;br /&gt;
====Special Variable Conventions====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Language Specific Conventions===&lt;br /&gt;
||This is our second subtopic||&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Ruby====&lt;br /&gt;
[http://www.ruby-lang.org/en/ Ruby] does not offer many suggestions for naming variables.  What it does offer is how certain variables must begin.  A normal variable is any concatenation of letter or number as long as a letter or underscore '_' is used at the beginning.  An [http://en.wikipedia.org/wiki/Instance_variable instance variable], which occurs in a class as multiple copies, begins with  '@'.  A [http://en.wikipedia.org/wiki/Class_variable class variable] only has one copy used for all instances of a class, begins with '@@'.  A [http://en.wikipedia.org/wiki/Global_variable global variable], which can be used from anywhere within the program, begins with '$'.&lt;br /&gt;
&lt;br /&gt;
====Java====&lt;br /&gt;
&lt;br /&gt;
====C/C++/C#====&lt;br /&gt;
&lt;br /&gt;
====.NET====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Quick Access Table==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Type&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Hungarian&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Ruby&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Java&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;C&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;.NET&amp;lt;/th&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Dos And Don'ts ==&lt;br /&gt;
&lt;br /&gt;
When picking your variable names, here are a few '''Do''' and '''Don'ts''' to consider.&lt;br /&gt;
&lt;br /&gt;
 * Do use meaningful words&lt;br /&gt;
 * Do use intention-revealing names (p 84 java book)&lt;br /&gt;
 * Do be descriptive&lt;br /&gt;
 * Do keep consistent in your naming convention&lt;br /&gt;
&lt;br /&gt;
 * Don't ever name your variables, &amp;quot;data&amp;quot; ( http://www.oreillynet.com/onlamp/blog/2004/03/the_worlds_two_worst_variable.html )&lt;br /&gt;
 * Don't give up!&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39875</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39875"/>
		<updated>2010-11-03T03:46:32Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 choose good variable names and convention-styles for when writing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; might 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using really short variable names, can be difficult to understand.&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Finally, here is the same algorithm, with the original variable names from the [http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode source-example] (include reference number here).&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''Graph'', ''source''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''Graph'':&lt;br /&gt;
  3          dist[''v''] := infinity ;&lt;br /&gt;
  4          previous[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      dist[''source''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''Graph'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest dist[] ;&lt;br /&gt;
 10          '''if''' dist[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''alt'' := dist[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''alt'' &amp;lt; dist[''v'']:&lt;br /&gt;
 17                  dist[''v''] := ''alt'' ;&lt;br /&gt;
 18                  previous[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' dist[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
So finally, with meaningful variable names in place, it is much easier to understand the purpose of the code.  In fact, many may recognize it as Dijkstra's algorithm.  Comparing this well-named example to our first example shows just how important naming can be when writing code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notable Naming Conventions==&lt;br /&gt;
===General Conventions===&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Hungarian====&lt;br /&gt;
&lt;br /&gt;
====Universally Used Variables====&lt;br /&gt;
&lt;br /&gt;
====Special Variable Conventions====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Language Specific Conventions===&lt;br /&gt;
||This is our second subtopic||&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Ruby====&lt;br /&gt;
[http://www.ruby-lang.org/en/ Ruby] does not offer many suggestions for naming variables.  What it does offer is how certain variables must begin.  A normal variable is any concatenation of letter or number as long as a letter or underscore '_' is used at the beginning.  An [http://en.wikipedia.org/wiki/Instance_variable instance variable], which occurs in a class as multiple copies, begins with  '@'.  A [http://en.wikipedia.org/wiki/Class_variable class variable] only has one copy used for all instances of a class, begins with '@@'.  A [http://en.wikipedia.org/wiki/Global_variable global variable], which can be used from anywhere within the program, begins with '$'.&lt;br /&gt;
&lt;br /&gt;
====Java====&lt;br /&gt;
&lt;br /&gt;
====C/C++/C#====&lt;br /&gt;
&lt;br /&gt;
====.NET====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Quick Access Table==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Type&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Hungarian&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Ruby&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Java&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;C&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;.NET&amp;lt;/th&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Dos And Don'ts ==&lt;br /&gt;
&lt;br /&gt;
When picking your variable names, here are a few ''Do'' and ''Don'ts'' to consider.&lt;br /&gt;
&lt;br /&gt;
 * Do use meaningful words&lt;br /&gt;
 * Do use intention-revealing names (p 84 java book)&lt;br /&gt;
 * Do be descriptive&lt;br /&gt;
 * Do keep consistent in your naming convention&lt;br /&gt;
&lt;br /&gt;
 * Don't ever name your variables, &amp;quot;data&amp;quot; ( http://www.oreillynet.com/onlamp/blog/2004/03/the_worlds_two_worst_variable.html )&lt;br /&gt;
 * Don't give up!&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39874</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39874"/>
		<updated>2010-11-03T03:44:35Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 choose good variable names and convention-styles for when writing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; might 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using really short variable names, can be difficult to understand.&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Finally, here is the same algorithm, with the original variable names from the [http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode source-example] (include reference number here).&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''Graph'', ''source''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''Graph'':&lt;br /&gt;
  3          dist[''v''] := infinity ;&lt;br /&gt;
  4          previous[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      dist[''source''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''Graph'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest dist[] ;&lt;br /&gt;
 10          '''if''' dist[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''alt'' := dist[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''alt'' &amp;lt; dist[''v'']:&lt;br /&gt;
 17                  dist[''v''] := ''alt'' ;&lt;br /&gt;
 18                  previous[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' dist[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
So finally, with meaningful variable names in place, it is much easier to understand the purpose of the code.  In fact, many may recognize it as Dijkstra's algorithm.  Comparing this well-named example to our first example shows just how important naming can be when writing code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notable Naming Conventions==&lt;br /&gt;
===General Conventions===&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Hungarian====&lt;br /&gt;
&lt;br /&gt;
====Universally Used Variables====&lt;br /&gt;
&lt;br /&gt;
====Special Variable Conventions====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Language Specific Conventions===&lt;br /&gt;
||This is our second subtopic||&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Ruby====&lt;br /&gt;
[http://www.ruby-lang.org/en/ Ruby] does not offer many suggestions for naming variables.  What it does offer is how certain variables must begin.  A normal variable is any concatenation of letter or number as long as a letter or underscore '_' is used at the beginning.  An [http://en.wikipedia.org/wiki/Instance_variable instance variable], which occurs in a class as multiple copies, begins with  '@'.  A [http://en.wikipedia.org/wiki/Class_variable class variable] only has one copy used for all instances of a class, begins with '@@'.  A [http://en.wikipedia.org/wiki/Global_variable global variable], which can be used from anywhere within the program, begins with '$'.&lt;br /&gt;
&lt;br /&gt;
====Java====&lt;br /&gt;
&lt;br /&gt;
====C/C++/C#====&lt;br /&gt;
&lt;br /&gt;
====.NET====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Quick Access Table==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Type&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Hungarian&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Ruby&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Java&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;C&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;.NET&amp;lt;/th&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Dos And Don'ts ==&lt;br /&gt;
&lt;br /&gt;
 * Do use meaningful words&lt;br /&gt;
 * Do use intention-revealing names (p 84 java book)&lt;br /&gt;
 * Do be descriptive&lt;br /&gt;
 * Do keep consistent in your naming convention&lt;br /&gt;
&lt;br /&gt;
 * Don't ever name your variables, &amp;quot;data&amp;quot; ( http://www.oreillynet.com/onlamp/blog/2004/03/the_worlds_two_worst_variable.html )&lt;br /&gt;
 * Don't give up!&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39871</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39871"/>
		<updated>2010-11-03T03:30:46Z</updated>

		<summary type="html">&lt;p&gt;Grepper: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 choose good variable names and convention-styles for when writing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; might 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using really short variable names, can be difficult to understand.&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Finally, here is the same algorithm, with the original variable names from the [http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode source-example] (include reference number here).&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''Graph'', ''source''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''Graph'':&lt;br /&gt;
  3          dist[''v''] := infinity ;&lt;br /&gt;
  4          previous[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      dist[''source''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''Graph'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest dist[] ;&lt;br /&gt;
 10          '''if''' dist[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''alt'' := dist[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''alt'' &amp;lt; dist[''v'']:&lt;br /&gt;
 17                  dist[''v''] := ''alt'' ;&lt;br /&gt;
 18                  previous[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' dist[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
So finally, with meaningful variable names in place, it is much easier to understand the purpose of the code.  In fact, many may recognize it as Dijkstra's algorithm.  Comparing this well-named example to our first example shows just how important naming can be when writing code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notable Naming Conventions==&lt;br /&gt;
===General Conventions===&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Hungarian====&lt;br /&gt;
&lt;br /&gt;
====Universally Used Variables====&lt;br /&gt;
&lt;br /&gt;
====Special Variable Conventions====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Language Specific Conventions===&lt;br /&gt;
||This is our second subtopic||&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Ruby====&lt;br /&gt;
[http://www.ruby-lang.org/en/ Ruby] does not offer many suggestions for naming variables.  What it does offer is how certain variables must begin.  A normal variable is any concatenation of letter or number as long as a letter or underscore '_' is used at the beginning.  An [http://en.wikipedia.org/wiki/Instance_variable instance variable], which occurs in a class as multiple copies, begins with  '@'.  A [http://en.wikipedia.org/wiki/Class_variable class variable] only has one copy used for all instances of a class, begins with '@@'.  A [http://en.wikipedia.org/wiki/Global_variable global variable], which can be used from anywhere within the program, begins with '$'.&lt;br /&gt;
&lt;br /&gt;
====Java====&lt;br /&gt;
&lt;br /&gt;
====C/C++/C#====&lt;br /&gt;
&lt;br /&gt;
====.NET====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Quick Access Table==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Type&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Hungarian&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Ruby&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Java&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;C&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;.NET&amp;lt;/th&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39870</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39870"/>
		<updated>2010-11-03T03:29:50Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 choose good variable names and convention-styles for when writing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using really short variable names, can be difficult to understand.&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Finally, here is the same algorithm, with the original variable names from the [http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode source-example] (include reference number here).&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''Graph'', ''source''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''Graph'':&lt;br /&gt;
  3          dist[''v''] := infinity ;&lt;br /&gt;
  4          previous[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      dist[''source''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''Graph'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest dist[] ;&lt;br /&gt;
 10          '''if''' dist[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''alt'' := dist[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''alt'' &amp;lt; dist[''v'']:&lt;br /&gt;
 17                  dist[''v''] := ''alt'' ;&lt;br /&gt;
 18                  previous[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' dist[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
So finally, with meaningful variable names in place, it is much easier to understand the purpose of the code.  In fact, many may recognize it as Dijkstra's algorithm.  Comparing this well-named example to our first example shows just how important naming can be when writing code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notable Naming Conventions==&lt;br /&gt;
===General Conventions===&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Hungarian====&lt;br /&gt;
&lt;br /&gt;
====Universally Used Variables====&lt;br /&gt;
&lt;br /&gt;
====Special Variable Conventions====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Language Specific Conventions===&lt;br /&gt;
||This is our second subtopic||&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Ruby====&lt;br /&gt;
[http://www.ruby-lang.org/en/ Ruby] does not offer many suggestions for naming variables.  What it does offer is how certain variables must begin.  A normal variable is any concatenation of letter or number as long as a letter or underscore '_' is used at the beginning.  An [http://en.wikipedia.org/wiki/Instance_variable instance variable], which occurs in a class as multiple copies, begins with  '@'.  A [http://en.wikipedia.org/wiki/Class_variable class variable] only has one copy used for all instances of a class, begins with '@@'.  A [http://en.wikipedia.org/wiki/Global_variable global variable], which can be used from anywhere within the program, begins with '$'.&lt;br /&gt;
&lt;br /&gt;
====Java====&lt;br /&gt;
&lt;br /&gt;
====C/C++/C#====&lt;br /&gt;
&lt;br /&gt;
====.NET====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Quick Access Table==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Type&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Hungarian&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Ruby&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Java&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;C&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;.NET&amp;lt;/th&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39853</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39853"/>
		<updated>2010-11-03T02:47:09Z</updated>

		<summary type="html">&lt;p&gt;Grepper: /* The Good and The Bad */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using really short variable names, can be difficult to understand.&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Finally, here is the same algorithm, with the original variable names from the [http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode source-example] (include reference number here).&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''Graph'', ''source''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''Graph'':&lt;br /&gt;
  3          dist[''v''] := infinity ;&lt;br /&gt;
  4          previous[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      dist[''source''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''Graph'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest dist[] ;&lt;br /&gt;
 10          '''if''' dist[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''alt'' := dist[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''alt'' &amp;lt; dist[''v'']:&lt;br /&gt;
 17                  dist[''v''] := ''alt'' ;&lt;br /&gt;
 18                  previous[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' dist[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
So finally, with meaningful variable names in place, it is much easier to understand the purpose of the code.  In fact, many may recognize it as Dijkstra's algorithm.  Comparing this well-named example to our first example shows just how important naming can be when writing code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notable Naming Conventions==&lt;br /&gt;
===General Conventions===&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Hungarian====&lt;br /&gt;
&lt;br /&gt;
====Universally Used Variables====&lt;br /&gt;
&lt;br /&gt;
====Special Variable Conventions====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Language Specific Conventions===&lt;br /&gt;
||This is our second subtopic||&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Ruby====&lt;br /&gt;
&lt;br /&gt;
====Java====&lt;br /&gt;
&lt;br /&gt;
====C/C++/C#====&lt;br /&gt;
&lt;br /&gt;
====.NET====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Quick Access Table==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Type&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Hungarian&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Ruby&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Java&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;C&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;.NET&amp;lt;/th&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39852</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39852"/>
		<updated>2010-11-03T02:46:51Z</updated>

		<summary type="html">&lt;p&gt;Grepper: /* The Good and The Bad */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using really short variable names, can be difficult to understand.&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Finally, here is the same algorithm, with the original variable names from the [http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Pseudocode | source-example] (include reference number here).&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''Graph'', ''source''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''Graph'':&lt;br /&gt;
  3          dist[''v''] := infinity ;&lt;br /&gt;
  4          previous[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      dist[''source''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''Graph'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest dist[] ;&lt;br /&gt;
 10          '''if''' dist[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''alt'' := dist[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''alt'' &amp;lt; dist[''v'']:&lt;br /&gt;
 17                  dist[''v''] := ''alt'' ;&lt;br /&gt;
 18                  previous[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' dist[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
So finally, with meaningful variable names in place, it is much easier to understand the purpose of the code.  In fact, many may recognize it as Dijkstra's algorithm.  Comparing this well-named example to our first example shows just how important naming can be when writing code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notable Naming Conventions==&lt;br /&gt;
===General Conventions===&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Hungarian====&lt;br /&gt;
&lt;br /&gt;
====Universally Used Variables====&lt;br /&gt;
&lt;br /&gt;
====Special Variable Conventions====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Language Specific Conventions===&lt;br /&gt;
||This is our second subtopic||&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Ruby====&lt;br /&gt;
&lt;br /&gt;
====Java====&lt;br /&gt;
&lt;br /&gt;
====C/C++/C#====&lt;br /&gt;
&lt;br /&gt;
====.NET====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Quick Access Table==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Type&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Hungarian&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Ruby&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Java&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;C&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;.NET&amp;lt;/th&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39851</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39851"/>
		<updated>2010-11-03T02:40:17Z</updated>

		<summary type="html">&lt;p&gt;Grepper: /* The Good and The Bad */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
Clearly, code without meaningful variables greatly complicates reading what the algorithm is supposed to do.  Even with a slightly better example, using short 1-character variable names:&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''G'', ''s''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''G'':&lt;br /&gt;
  3          d[''v''] := infinity ;&lt;br /&gt;
  4          p[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      d[''s''] := 0 ;&lt;br /&gt;
  7      ''Q'' := the set of all nodes in ''G'' ;&lt;br /&gt;
  8      '''while''' ''Q'' '''is not''' empty:&lt;br /&gt;
  9          ''u'' := vertex in ''Q'' with smallest d[] ;&lt;br /&gt;
 10          '''if''' d[''u''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''u'' from ''Q'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''v'' of ''u'':&lt;br /&gt;
 15              ''a'' := d[''u''] + dist_between(''u'', ''v'') ;&lt;br /&gt;
 16              '''if''' ''a'' &amp;lt; d[''v'']:&lt;br /&gt;
 17                  d[''v''] := ''a'' ;&lt;br /&gt;
 18                  p[''v''] := ''u'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' d[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
( algorithm with short-names go here )&lt;br /&gt;
&lt;br /&gt;
( original algorithm goes here )&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notable Naming Conventions==&lt;br /&gt;
===General Conventions===&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Hungarian====&lt;br /&gt;
&lt;br /&gt;
====Universally Used Variables====&lt;br /&gt;
&lt;br /&gt;
====Special Variable Conventions====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Language Specific Conventions===&lt;br /&gt;
||This is our second subtopic||&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Ruby====&lt;br /&gt;
&lt;br /&gt;
====Java====&lt;br /&gt;
&lt;br /&gt;
====C/C++/C#====&lt;br /&gt;
&lt;br /&gt;
====.NET====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Quick Access Table==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Type&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Hungarian&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Ruby&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Java&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;C&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;.NET&amp;lt;/th&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39850</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39850"/>
		<updated>2010-11-03T02:28:52Z</updated>

		<summary type="html">&lt;p&gt;Grepper: /* The Good and the Bad */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and The Bad==&lt;br /&gt;
&lt;br /&gt;
Imagine you are diving into someone's code, and you find something like this...&lt;br /&gt;
&lt;br /&gt;
  1  '''function''' mystery_function(''var1'', ''var2''):&lt;br /&gt;
  2      '''for each''' vertex ''v'' in ''var1'':&lt;br /&gt;
  3          var3[''v''] := infinity ;&lt;br /&gt;
  4          var4[''v''] := undefined ;&lt;br /&gt;
  5      '''end for ''';&lt;br /&gt;
  6      var3[''var2''] := 0 ;&lt;br /&gt;
  7      ''var5'' := the set of all nodes in ''var1'' ;&lt;br /&gt;
  8      '''while''' ''var5'' '''is not''' empty:&lt;br /&gt;
  9          ''var7'' := vertex in ''var5'' with smallest var3[] ;&lt;br /&gt;
 10          '''if''' var3[''var7''] = infinity:&lt;br /&gt;
 11              '''break''' ;&lt;br /&gt;
 12          '''fi''' ;&lt;br /&gt;
 13          remove ''var7'' from ''var5'' ;&lt;br /&gt;
 14          '''for each''' neighbor ''var6'' of ''var7'':&lt;br /&gt;
 15              ''var8'' := var3[''var7''] + dist_between(''var7'', ''var6'') ;&lt;br /&gt;
 16              '''if''' ''var8'' &amp;lt; var3[''var6'']:&lt;br /&gt;
 17                  var3[''var6''] := ''var8'' ;&lt;br /&gt;
 18                  var4[''var6''] := ''var7'' ;&lt;br /&gt;
 19              '''fi ''' ;&lt;br /&gt;
 20          '''end for''' ;&lt;br /&gt;
 21      '''end while''' ;&lt;br /&gt;
 22      '''return''' var3[] ;&lt;br /&gt;
 23  '''end''' mystery_function.&lt;br /&gt;
&lt;br /&gt;
( algorithm with short-names go here )&lt;br /&gt;
&lt;br /&gt;
( original algorithm goes here )&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notable Naming Conventions==&lt;br /&gt;
===General Conventions===&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Hungarian====&lt;br /&gt;
&lt;br /&gt;
====Universally Used Variables====&lt;br /&gt;
&lt;br /&gt;
====Special Variable Conventions====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Language Specific Conventions===&lt;br /&gt;
||This is our second subtopic||&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Ruby====&lt;br /&gt;
&lt;br /&gt;
====Java====&lt;br /&gt;
&lt;br /&gt;
====C/C++/C#====&lt;br /&gt;
&lt;br /&gt;
====.NET====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Quick Access Table==&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Type&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Hungarian&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Ruby&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;Java&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;C&amp;lt;/th&amp;gt;&lt;br /&gt;
  &amp;lt;th&amp;gt;.NET&amp;lt;/th&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;String&amp;lt;/td&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
 &amp;lt;tr&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;Number&amp;lt;/td&amp;gt;&lt;br /&gt;
 &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39848</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5b_mt&amp;diff=39848"/>
		<updated>2010-11-03T02:13:29Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Variable Naming Conventions'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A [http://en.wikipedia.org/wiki/Variable_%28programming%29 Variable] is a name used within a program that holds the value of something that is known or unknown.  For example, the variable &amp;quot;firstName&amp;quot; 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.  [http://en.wikipedia.org/wiki/Naming_convention_%28programming%29 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 &amp;quot;fn&amp;quot;, 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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
||An example of multiple cites for the same resource &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodya&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  &amp;lt;sup&amp;gt;&amp;lt;span id=&amp;quot;1bodyb&amp;quot;&amp;gt;[[#1foot|[1]]]&amp;lt;/span&amp;gt;&amp;lt;/sup&amp;gt;  If it doesn't have multiple cites for the same resource just leave off the ''a'' and ''b''&lt;br /&gt;
&lt;br /&gt;
||&lt;br /&gt;
&lt;br /&gt;
==The Good and the Bad==&lt;br /&gt;
( really bad algorithm goes here )&lt;br /&gt;
&lt;br /&gt;
( algorithm with short-names go here )&lt;br /&gt;
&lt;br /&gt;
( original algorithm goes here )&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notable Naming Conventions==&lt;br /&gt;
===General Conventions===&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Hungarian====&lt;br /&gt;
&lt;br /&gt;
====Universally Used Variables====&lt;br /&gt;
&lt;br /&gt;
====Special Variable Conventions====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Language Specific Conventions===&lt;br /&gt;
||This is our second subtopic||&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Ruby====&lt;br /&gt;
&lt;br /&gt;
====Java====&lt;br /&gt;
&lt;br /&gt;
====C/C++/C#====&lt;br /&gt;
&lt;br /&gt;
====.NET====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Quick Access Table==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;span id=&amp;quot;1foot&amp;quot;&amp;gt;1. &amp;lt;sup&amp;gt;[[#1bodya|''a'']], [[#1bodyb|''b'']]&amp;lt;/sup&amp;gt;&amp;lt;/span&amp;gt; Author last, FI. (2010, April 26). Title of webpage. Retrieved October 15, 2010, from site name (Github): http://github.com/&lt;br /&gt;
&lt;br /&gt;
==Additional Resources==&lt;br /&gt;
* Sun Java naming conventions - http://www.oracle.com/technetwork/java/codeconventions-135099.html#367&lt;br /&gt;
* .NET 4 naming conventions - http://msdn.microsoft.com/en-us/library/ms229045.aspx&lt;br /&gt;
* C++ naming conventions - http://www.cprogramming.com/tutorial/style_naming_conventions.html&lt;br /&gt;
* Hungarian Notation - http://en.wikipedia.org/wiki/Hungarian_notation&lt;br /&gt;
** Hungarian notation was invented by Microsoft programmer Charles Simonyi.&lt;br /&gt;
** 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&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39341</id>
		<title>CSC/ECE 517 Fall 2010/ch3 4b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39341"/>
		<updated>2010-10-21T05:45:13Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Types vs Classes'''&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: #F2F2F2; border: solid thin black; padding: 5px;&amp;quot;&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.  This topic was covered three years ago (http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007), but all of the articles considered one language after the other, in a set of examples rather than a discussion of issues.  Make sure that you discuss the issues, using languages as examples rather than making language the primary means of organizing the chapter.&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Overall s.png|right|frame|Relationship between Type and Class]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
It is often that we talk about types, strongly typed, weakly typed, classes. To make it clear,  let us look into it clearly. Every programming language has a way to define a variable. A variable is a named address location which stores a particular value. &lt;br /&gt;
&lt;br /&gt;
[[Image:Connection s.png|right|thumb|Classes are a 'type' that can combine other types.]]&lt;br /&gt;
&lt;br /&gt;
===Types===&lt;br /&gt;
&lt;br /&gt;
Time for an analogy? Imagine a variable to be a vacant house. It could have animals, humans, robots, or another smaller house, or whatever you can think of. There has to be a way, from a third party perspective, so as to be cognizant of the kind of things that reside in the house. Types and typing is a concept which realizes this concept. A typed language or a strongly typed language is one where the type of a variable has to be declared so as to avoid any wrong dealings of the value during run time. For example, Java is a strongly typed language. If I need to use two integers for addition, I would explicitly have to mention them as an integer:- &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  int integer1;&lt;br /&gt;
  int integer2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we can’t then re-initialize it to any other type in its defined scope.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  integer1 = “Hello World”;  // cannot map an int to a String&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the case of non-typed languages, say Ruby, or Visual Basic, etc. We don’t need to specify a type. &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  def variable1;&lt;br /&gt;
  def variable2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, it could be initialized with anything,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
as well as &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = “Good morning Vietnam”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Classes===&lt;br /&gt;
&lt;br /&gt;
A class is a “type” of variable specification. The difference between a class and a regular primitive integer, character, etc is that a class:-&lt;br /&gt;
&lt;br /&gt;
# consists of one or more primitive or non-primitive variables&lt;br /&gt;
# is a pre-defined structure&lt;br /&gt;
# defines methods which operate on the internal state of the object&lt;br /&gt;
&lt;br /&gt;
The Type of Class is “Class”, just like the Type of integer is “integer” in case of strongly typed languages. &lt;br /&gt;
&lt;br /&gt;
For example, in case of Java:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;“The types of the Java programming language are divided into two categories: primitive types and reference types. The primitive types are the boolean type and the numeric types. The numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double. The reference types are class types, interface types, and array types. There is also a special null type. An object is a dynamically created instance of a class type or a dynamically created array. The values of a reference type are references to objects. All objects, including arrays, support the methods of class Object . String literals are represented by String objects .” [2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, as mentioned before, in Java, there are two “Types”:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type:lower-roman&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Primitive Type&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Reference Type&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Classes, Interfaces, Arrays are all consolidations of Primitive types, so they just need to “point” to or reference the primitive ones, hence the name.&lt;br /&gt;
It is sometimes confusing and difficult to come up with a clear and robust distinction between Types and Classes. One might think &amp;quot;Class to be a Type of Type&amp;quot;. &lt;br /&gt;
It is however important to know that in strict Object Oriented Languages, Type is a union of Classes and Primitives. This rule, more or less consistent (with some deviations where primitives are treated as classes). &lt;br /&gt;
 &lt;br /&gt;
==Types and Classes in Languages==&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
Ruby claims to be a strong object oriented language. It is object oriented to the extent that every thing is an object. Primitive datatypes are objects, and we can make use of the object oriented techniques on even the primitives. As mentioned before, Ruby is a dynamic typed language, as the type is bound at compile time. Everything in Ruby has a class. Every class in Ruby is inherited from class Class. &lt;br /&gt;
&lt;br /&gt;
Type in Ruby is well defined as well. Using self inspection (reflection), we can find out whether a name is a Class, or a method. Let us see this in action:- &lt;br /&gt;
&lt;br /&gt;
The first thing that comes to a one’s mind is something like :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
&amp;quot;hello&amp;quot;.class #=&amp;gt; String&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
But have you thought of your class as an object? Well that seems odd, but that’s how ruby works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
class Foo;end  #=&amp;gt; nil&lt;br /&gt;
Foo.class #=&amp;gt; Class&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What does the above snippet of code mean exactly?&lt;br /&gt;
It means 2 things : Foo is a constant and that constant holds(refers to) an object of Class type.&lt;br /&gt;
&lt;br /&gt;
Let us prove that:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Foo = Class.new&lt;br /&gt;
(irb):8 warning: already initialized constant Foo&lt;br /&gt;
=&amp;gt; Foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
As you can see, we got a warning because we tried to initialize the constant Foo again.&lt;br /&gt;
&lt;br /&gt;
So ,when you define some class ‘Foo’ in ruby, all you are doing is:&lt;br /&gt;
1-instantiating an object of type Class.&lt;br /&gt;
2-initializing a constant Foo that refers to that created object .&lt;br /&gt;
&lt;br /&gt;
So, when we say “object” ,then we do mean any object; an object of Class type, or any object of any type.[3]&lt;br /&gt;
&lt;br /&gt;
===Java===&lt;br /&gt;
&lt;br /&gt;
As mentioned before, Java is a strongly typed language. The type of data needs to be declared before using. The types of &amp;quot;types&amp;quot; in Java are :&lt;br /&gt;
   * Primitive Types:-  boolean and numeric. The numeric types are the integral types byte, short, int, long, and char, and the         &lt;br /&gt;
     floating-point types float and double. &lt;br /&gt;
   * Reference Types:- class types, interface types and array types. [2] &lt;br /&gt;
&lt;br /&gt;
Java is an object-oriented language, but it does make a clear distinction between the primitive type and Classes. int, float, char etc. are primitives, and the other data types other than the primitives are references. It is an interesting distinction to note, because of the differences in method calling system in different languages. Java makes a distinction in &amp;quot;calling-by-value&amp;quot; when a primitive is passed as a parameter, and &amp;quot;calling-by-reference&amp;quot; when an object is passed. In fact, if a primitive is passed, a call by value is invoked, but when a Class object is passed, only a reference is passed to the object. &lt;br /&gt;
&lt;br /&gt;
For a more language specific treatment of types and classes, you can refer: http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_6_ap &lt;br /&gt;
&lt;br /&gt;
==Discussion of Issues==&lt;br /&gt;
Okay, so you're about to write a program and you need to represent data somehow.  Should you use a primitive type?  What about a class?  There are several features that are handed to you with each.&lt;br /&gt;
&lt;br /&gt;
=== Primitive Types ===&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Simplicity =====&lt;br /&gt;
In strongly typed languages, primitive types are ideal for data which doesn't necessarily need to be partitioned into several smaller components.  If you are looking to store and represent a simple throw-away integer for looping, for example, there's little reason why one would want to construct a class for this throw-away integer purpose.&lt;br /&gt;
&lt;br /&gt;
Primitive types are also often times coupled with native operations, handed to you by the language.  For example, in Java, variables of type int are automatically given operations such as addition, subtraction, multiplication, and so on.  These operations work as follows:&lt;br /&gt;
# Receive both inputs&lt;br /&gt;
# Cast if necessary (for example, from an int to a double)&lt;br /&gt;
# Perform calculation&lt;br /&gt;
# Return result&lt;br /&gt;
&lt;br /&gt;
It is important to note that the primitive types themselves are left ''unchanged'', and the result is returned from the operation, giving the programmer the ability to place the result elsewhere.&lt;br /&gt;
&lt;br /&gt;
===== Efficiency =====&lt;br /&gt;
In efficiency-critical applications, primitive types and their operations are oftentimes mapped directly to hardware-supported equivalents, thus operations can be performed very quickly.  This style of downgrading the logic to more so the hardware level has been replaced over the years for general applications, since improvements to hardware components have eradicated the once-imperative necessity to program efficiently.  Another point of view concerning efficiency could be from development time: if the program one is writing doesn't require complex design, it would be quicker to use the language's built-in types instead of taking the time to design a class to do the same feature.&lt;br /&gt;
&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Single-state storage =====&lt;br /&gt;
One large disadvantages to primitive types are that they are generally capable of only holding a single dimension state.  This limitation requires the programmer to use other variables in conjunction if they desire to hold more than one field of data.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Since primitive types do not allow you to encapsulate your data, if you ever desire to change the behavior of your program, you are forced to manually check each use of the variable for enforcement.&lt;br /&gt;
&lt;br /&gt;
For example, suppose you have a system designed in Java that maintains an integer value which represents the number of books you have in a library.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
int numBooks;&lt;br /&gt;
...&lt;br /&gt;
numBooks = 0;&lt;br /&gt;
...&lt;br /&gt;
numBooks++;&lt;br /&gt;
...&lt;br /&gt;
numBooks--;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A few days later, you realize that you should probably refactor your system to maintain a log of when this variable updates.  You immediately face a problem since, as it is, your code directly manipulates a single-state type integer.  Without resorting to a more object-oriented solution, you would have to update each location in the code of where a change takes place in order to establish this bookkeeping (pun intended).&lt;br /&gt;
&amp;lt;code id=&amp;quot;bookKeeping&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public static void integerValueChanged(){&lt;br /&gt;
  // records that the value has been changed&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public static void main(String[]args){&lt;br /&gt;
  int numBooks;&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks = 0;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks++;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks--;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To generalize this concept, it is oftentimes necessary to modify &amp;quot;what happens&amp;quot; when something is updated, and this cannot be easily accomplished by merely using primitive types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Class Types ===&lt;br /&gt;
Classes to the rescue!  Classes give programmers the ability to construct complex data types that are also capable of defining their own operations, all while keeping the details and specifics black-boxed outsize of where the class will be used in the code.&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Multi-dimensional Storage =====&lt;br /&gt;
Contrasting to primitive types, classes allow programmers to couple a varying number of fields.  Grouping fields of data into a single class, then instantiating such an object and manipulating it is much more convenient than keeping track of several individual variables.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Oftentimes it is necessary to refactor a system to execute code when a change happens.  In object-land, we are able to do this through the ability to control what happens in our methods.&lt;br /&gt;
&lt;br /&gt;
Taking our [[#bookKeeping| example from above]], we can give a quick example of how a class could be defined to handle the situation much more elegantly.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public class RecordedNumber{&lt;br /&gt;
  // The integer value, kept concealed in the class&lt;br /&gt;
  private int value;&lt;br /&gt;
&lt;br /&gt;
  public RecordedNumber(int value){&lt;br /&gt;
    this.value = value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public int getValue(){&lt;br /&gt;
    return value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public void setValue(int newValue){&lt;br /&gt;
    // code to do any necessary recording.&lt;br /&gt;
    ...&lt;br /&gt;
    this.value = newValue;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class MyExample{&lt;br /&gt;
  public static void main(String[]args){&lt;br /&gt;
    RecordedNumber numBooks = new RecordedNumber(0);&lt;br /&gt;
    ...&lt;br /&gt;
    numBooks.setValue(4); // the object handles all necessary bookkeeping&lt;br /&gt;
    ...&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Code-reuse =====&lt;br /&gt;
Another nice feature to class-types encapsulate the concept surrounding code re-usability, especially in topics such as inheritance.  Classes allow the programmer to enhance an already existing class-type to be more specific, which in turn can prevent excessive code duplication.&lt;br /&gt;
&lt;br /&gt;
===== Application Structure =====&lt;br /&gt;
Designing an application in a object-oriented / class-specific style can reduce the challenges of designing and building a difficult system into merely making objects successfully interact.  It is from this concept that languages such as [http://en.wikipedia.org/wiki/Unified_Modeling_Language Unified Modeling Language (UML)] have been created, allowing software engineers to build around the notion of classes and their relationships to one another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Speed Considerations =====&lt;br /&gt;
In computational-intensive applications, objects built from classes tend to be less efficient than primitive data types built around procedural context.  This is due in part because of the object's creation, since it isn't supported directly hardware level.  Consideration is placed more so on good-design and coding-practices when implementing functionality around classes.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== Complexity =====&lt;br /&gt;
Oftentimes one doesn't need the functionality provided by classes to handle the problem they are trying to solve.  Consequently, such an unnecessary use oftentimes over-complicates the principle design and may add unnecessary burdens to maintain the code.  This regard is more so geared towards small-programs where objects and classes may not be the best fit for their implementation.  Examples of this situation vary, since it is highly opinionated, but are more so an example of bad design in an object-oriented sense: to quote Albert Einstein, &amp;quot;Everything should be made as simple as possible, but no simpler.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[1] http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html&lt;br /&gt;
&lt;br /&gt;
[2] Java:- Types, Values and Variables&lt;br /&gt;
    http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html&lt;br /&gt;
[3] Ruby Reflection ,http://www.khelll.com/blog/ruby/ruby-reflection/&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39340</id>
		<title>CSC/ECE 517 Fall 2010/ch3 4b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39340"/>
		<updated>2010-10-21T05:45:00Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Types vs Classes'''&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: #F2F2F2; border: solid thin black; padding: 5px;&amp;quot;&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.  This topic was covered three years ago (http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007), but all of the articles considered one language after the other, in a set of examples rather than a discussion of issues.  Make sure that you discuss the issues, using languages as examples rather than making language the primary means of organizing the chapter.&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Overall s.png|right|frame|Relationship between Type and Class]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
It is often that we talk about types, strongly typed, weakly typed, classes. To make it clear,  let us look into it clearly. Every programming language has a way to define a variable. A variable is a named address location which stores a particular value. &lt;br /&gt;
&lt;br /&gt;
[[Image:Connection s.png|right|thumb|Classes are a 'type' that can combine other types.]]&lt;br /&gt;
&lt;br /&gt;
===Types===&lt;br /&gt;
&lt;br /&gt;
Time for an analogy? Imagine a variable to be a vacant house. It could have animals, humans, robots, or another smaller house, or whatever you can think of. There has to be a way, from a third party perspective, so as to be cognizant of the kind of things that reside in the house. Types and typing is a concept which realizes this concept. A typed language or a strongly typed language is one where the type of a variable has to be declared so as to avoid any wrong dealings of the value during run time. For example, Java is a strongly typed language. If I need to use two integers for addition, I would explicitly have to mention them as an integer:- &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre style=&amp;quot;width:20px;&amp;quot;&amp;gt;&lt;br /&gt;
  int integer1;&lt;br /&gt;
  int integer2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we can’t then re-initialize it to any other type in its defined scope.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  integer1 = “Hello World”;  // cannot map an int to a String&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the case of non-typed languages, say Ruby, or Visual Basic, etc. We don’t need to specify a type. &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  def variable1;&lt;br /&gt;
  def variable2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, it could be initialized with anything,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
as well as &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = “Good morning Vietnam”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Classes===&lt;br /&gt;
&lt;br /&gt;
A class is a “type” of variable specification. The difference between a class and a regular primitive integer, character, etc is that a class:-&lt;br /&gt;
&lt;br /&gt;
# consists of one or more primitive or non-primitive variables&lt;br /&gt;
# is a pre-defined structure&lt;br /&gt;
# defines methods which operate on the internal state of the object&lt;br /&gt;
&lt;br /&gt;
The Type of Class is “Class”, just like the Type of integer is “integer” in case of strongly typed languages. &lt;br /&gt;
&lt;br /&gt;
For example, in case of Java:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;“The types of the Java programming language are divided into two categories: primitive types and reference types. The primitive types are the boolean type and the numeric types. The numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double. The reference types are class types, interface types, and array types. There is also a special null type. An object is a dynamically created instance of a class type or a dynamically created array. The values of a reference type are references to objects. All objects, including arrays, support the methods of class Object . String literals are represented by String objects .” [2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, as mentioned before, in Java, there are two “Types”:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type:lower-roman&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Primitive Type&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Reference Type&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Classes, Interfaces, Arrays are all consolidations of Primitive types, so they just need to “point” to or reference the primitive ones, hence the name.&lt;br /&gt;
It is sometimes confusing and difficult to come up with a clear and robust distinction between Types and Classes. One might think &amp;quot;Class to be a Type of Type&amp;quot;. &lt;br /&gt;
It is however important to know that in strict Object Oriented Languages, Type is a union of Classes and Primitives. This rule, more or less consistent (with some deviations where primitives are treated as classes). &lt;br /&gt;
 &lt;br /&gt;
==Types and Classes in Languages==&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
Ruby claims to be a strong object oriented language. It is object oriented to the extent that every thing is an object. Primitive datatypes are objects, and we can make use of the object oriented techniques on even the primitives. As mentioned before, Ruby is a dynamic typed language, as the type is bound at compile time. Everything in Ruby has a class. Every class in Ruby is inherited from class Class. &lt;br /&gt;
&lt;br /&gt;
Type in Ruby is well defined as well. Using self inspection (reflection), we can find out whether a name is a Class, or a method. Let us see this in action:- &lt;br /&gt;
&lt;br /&gt;
The first thing that comes to a one’s mind is something like :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
&amp;quot;hello&amp;quot;.class #=&amp;gt; String&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
But have you thought of your class as an object? Well that seems odd, but that’s how ruby works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
class Foo;end  #=&amp;gt; nil&lt;br /&gt;
Foo.class #=&amp;gt; Class&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What does the above snippet of code mean exactly?&lt;br /&gt;
It means 2 things : Foo is a constant and that constant holds(refers to) an object of Class type.&lt;br /&gt;
&lt;br /&gt;
Let us prove that:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Foo = Class.new&lt;br /&gt;
(irb):8 warning: already initialized constant Foo&lt;br /&gt;
=&amp;gt; Foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
As you can see, we got a warning because we tried to initialize the constant Foo again.&lt;br /&gt;
&lt;br /&gt;
So ,when you define some class ‘Foo’ in ruby, all you are doing is:&lt;br /&gt;
1-instantiating an object of type Class.&lt;br /&gt;
2-initializing a constant Foo that refers to that created object .&lt;br /&gt;
&lt;br /&gt;
So, when we say “object” ,then we do mean any object; an object of Class type, or any object of any type.[3]&lt;br /&gt;
&lt;br /&gt;
===Java===&lt;br /&gt;
&lt;br /&gt;
As mentioned before, Java is a strongly typed language. The type of data needs to be declared before using. The types of &amp;quot;types&amp;quot; in Java are :&lt;br /&gt;
   * Primitive Types:-  boolean and numeric. The numeric types are the integral types byte, short, int, long, and char, and the         &lt;br /&gt;
     floating-point types float and double. &lt;br /&gt;
   * Reference Types:- class types, interface types and array types. [2] &lt;br /&gt;
&lt;br /&gt;
Java is an object-oriented language, but it does make a clear distinction between the primitive type and Classes. int, float, char etc. are primitives, and the other data types other than the primitives are references. It is an interesting distinction to note, because of the differences in method calling system in different languages. Java makes a distinction in &amp;quot;calling-by-value&amp;quot; when a primitive is passed as a parameter, and &amp;quot;calling-by-reference&amp;quot; when an object is passed. In fact, if a primitive is passed, a call by value is invoked, but when a Class object is passed, only a reference is passed to the object. &lt;br /&gt;
&lt;br /&gt;
For a more language specific treatment of types and classes, you can refer: http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_6_ap &lt;br /&gt;
&lt;br /&gt;
==Discussion of Issues==&lt;br /&gt;
Okay, so you're about to write a program and you need to represent data somehow.  Should you use a primitive type?  What about a class?  There are several features that are handed to you with each.&lt;br /&gt;
&lt;br /&gt;
=== Primitive Types ===&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Simplicity =====&lt;br /&gt;
In strongly typed languages, primitive types are ideal for data which doesn't necessarily need to be partitioned into several smaller components.  If you are looking to store and represent a simple throw-away integer for looping, for example, there's little reason why one would want to construct a class for this throw-away integer purpose.&lt;br /&gt;
&lt;br /&gt;
Primitive types are also often times coupled with native operations, handed to you by the language.  For example, in Java, variables of type int are automatically given operations such as addition, subtraction, multiplication, and so on.  These operations work as follows:&lt;br /&gt;
# Receive both inputs&lt;br /&gt;
# Cast if necessary (for example, from an int to a double)&lt;br /&gt;
# Perform calculation&lt;br /&gt;
# Return result&lt;br /&gt;
&lt;br /&gt;
It is important to note that the primitive types themselves are left ''unchanged'', and the result is returned from the operation, giving the programmer the ability to place the result elsewhere.&lt;br /&gt;
&lt;br /&gt;
===== Efficiency =====&lt;br /&gt;
In efficiency-critical applications, primitive types and their operations are oftentimes mapped directly to hardware-supported equivalents, thus operations can be performed very quickly.  This style of downgrading the logic to more so the hardware level has been replaced over the years for general applications, since improvements to hardware components have eradicated the once-imperative necessity to program efficiently.  Another point of view concerning efficiency could be from development time: if the program one is writing doesn't require complex design, it would be quicker to use the language's built-in types instead of taking the time to design a class to do the same feature.&lt;br /&gt;
&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Single-state storage =====&lt;br /&gt;
One large disadvantages to primitive types are that they are generally capable of only holding a single dimension state.  This limitation requires the programmer to use other variables in conjunction if they desire to hold more than one field of data.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Since primitive types do not allow you to encapsulate your data, if you ever desire to change the behavior of your program, you are forced to manually check each use of the variable for enforcement.&lt;br /&gt;
&lt;br /&gt;
For example, suppose you have a system designed in Java that maintains an integer value which represents the number of books you have in a library.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
int numBooks;&lt;br /&gt;
...&lt;br /&gt;
numBooks = 0;&lt;br /&gt;
...&lt;br /&gt;
numBooks++;&lt;br /&gt;
...&lt;br /&gt;
numBooks--;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A few days later, you realize that you should probably refactor your system to maintain a log of when this variable updates.  You immediately face a problem since, as it is, your code directly manipulates a single-state type integer.  Without resorting to a more object-oriented solution, you would have to update each location in the code of where a change takes place in order to establish this bookkeeping (pun intended).&lt;br /&gt;
&amp;lt;code id=&amp;quot;bookKeeping&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public static void integerValueChanged(){&lt;br /&gt;
  // records that the value has been changed&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public static void main(String[]args){&lt;br /&gt;
  int numBooks;&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks = 0;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks++;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks--;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To generalize this concept, it is oftentimes necessary to modify &amp;quot;what happens&amp;quot; when something is updated, and this cannot be easily accomplished by merely using primitive types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Class Types ===&lt;br /&gt;
Classes to the rescue!  Classes give programmers the ability to construct complex data types that are also capable of defining their own operations, all while keeping the details and specifics black-boxed outsize of where the class will be used in the code.&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Multi-dimensional Storage =====&lt;br /&gt;
Contrasting to primitive types, classes allow programmers to couple a varying number of fields.  Grouping fields of data into a single class, then instantiating such an object and manipulating it is much more convenient than keeping track of several individual variables.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Oftentimes it is necessary to refactor a system to execute code when a change happens.  In object-land, we are able to do this through the ability to control what happens in our methods.&lt;br /&gt;
&lt;br /&gt;
Taking our [[#bookKeeping| example from above]], we can give a quick example of how a class could be defined to handle the situation much more elegantly.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public class RecordedNumber{&lt;br /&gt;
  // The integer value, kept concealed in the class&lt;br /&gt;
  private int value;&lt;br /&gt;
&lt;br /&gt;
  public RecordedNumber(int value){&lt;br /&gt;
    this.value = value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public int getValue(){&lt;br /&gt;
    return value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public void setValue(int newValue){&lt;br /&gt;
    // code to do any necessary recording.&lt;br /&gt;
    ...&lt;br /&gt;
    this.value = newValue;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class MyExample{&lt;br /&gt;
  public static void main(String[]args){&lt;br /&gt;
    RecordedNumber numBooks = new RecordedNumber(0);&lt;br /&gt;
    ...&lt;br /&gt;
    numBooks.setValue(4); // the object handles all necessary bookkeeping&lt;br /&gt;
    ...&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Code-reuse =====&lt;br /&gt;
Another nice feature to class-types encapsulate the concept surrounding code re-usability, especially in topics such as inheritance.  Classes allow the programmer to enhance an already existing class-type to be more specific, which in turn can prevent excessive code duplication.&lt;br /&gt;
&lt;br /&gt;
===== Application Structure =====&lt;br /&gt;
Designing an application in a object-oriented / class-specific style can reduce the challenges of designing and building a difficult system into merely making objects successfully interact.  It is from this concept that languages such as [http://en.wikipedia.org/wiki/Unified_Modeling_Language Unified Modeling Language (UML)] have been created, allowing software engineers to build around the notion of classes and their relationships to one another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Speed Considerations =====&lt;br /&gt;
In computational-intensive applications, objects built from classes tend to be less efficient than primitive data types built around procedural context.  This is due in part because of the object's creation, since it isn't supported directly hardware level.  Consideration is placed more so on good-design and coding-practices when implementing functionality around classes.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== Complexity =====&lt;br /&gt;
Oftentimes one doesn't need the functionality provided by classes to handle the problem they are trying to solve.  Consequently, such an unnecessary use oftentimes over-complicates the principle design and may add unnecessary burdens to maintain the code.  This regard is more so geared towards small-programs where objects and classes may not be the best fit for their implementation.  Examples of this situation vary, since it is highly opinionated, but are more so an example of bad design in an object-oriented sense: to quote Albert Einstein, &amp;quot;Everything should be made as simple as possible, but no simpler.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[1] http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html&lt;br /&gt;
&lt;br /&gt;
[2] Java:- Types, Values and Variables&lt;br /&gt;
    http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html&lt;br /&gt;
[3] Ruby Reflection ,http://www.khelll.com/blog/ruby/ruby-reflection/&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39339</id>
		<title>CSC/ECE 517 Fall 2010/ch3 4b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39339"/>
		<updated>2010-10-21T05:44:44Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Types vs Classes'''&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: #F2F2F2; border: solid thin black; padding: 5px;&amp;quot;&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.  This topic was covered three years ago (http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007), but all of the articles considered one language after the other, in a set of examples rather than a discussion of issues.  Make sure that you discuss the issues, using languages as examples rather than making language the primary means of organizing the chapter.&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Overall s.png|right|frame|Relationship between Type and Class]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
It is often that we talk about types, strongly typed, weakly typed, classes. To make it clear,  let us look into it clearly. Every programming language has a way to define a variable. A variable is a named address location which stores a particular value. &lt;br /&gt;
&lt;br /&gt;
[[Image:Connection s.png|right|thumb|Classes are a 'type' that can combine other types.]]&lt;br /&gt;
&lt;br /&gt;
===Types===&lt;br /&gt;
&lt;br /&gt;
Time for an analogy? Imagine a variable to be a vacant house. It could have animals, humans, robots, or another smaller house, or whatever you can think of. There has to be a way, from a third party perspective, so as to be cognizant of the kind of things that reside in the house. Types and typing is a concept which realizes this concept. A typed language or a strongly typed language is one where the type of a variable has to be declared so as to avoid any wrong dealings of the value during run time. For example, Java is a strongly typed language. If I need to use two integers for addition, I would explicitly have to mention them as an integer:- &lt;br /&gt;
&amp;lt;code style=&amp;quot;width:20px;&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  int integer1;&lt;br /&gt;
  int integer2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we can’t then re-initialize it to any other type in its defined scope.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  integer1 = “Hello World”;  // cannot map an int to a String&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the case of non-typed languages, say Ruby, or Visual Basic, etc. We don’t need to specify a type. &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  def variable1;&lt;br /&gt;
  def variable2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, it could be initialized with anything,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
as well as &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = “Good morning Vietnam”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Classes===&lt;br /&gt;
&lt;br /&gt;
A class is a “type” of variable specification. The difference between a class and a regular primitive integer, character, etc is that a class:-&lt;br /&gt;
&lt;br /&gt;
# consists of one or more primitive or non-primitive variables&lt;br /&gt;
# is a pre-defined structure&lt;br /&gt;
# defines methods which operate on the internal state of the object&lt;br /&gt;
&lt;br /&gt;
The Type of Class is “Class”, just like the Type of integer is “integer” in case of strongly typed languages. &lt;br /&gt;
&lt;br /&gt;
For example, in case of Java:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;“The types of the Java programming language are divided into two categories: primitive types and reference types. The primitive types are the boolean type and the numeric types. The numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double. The reference types are class types, interface types, and array types. There is also a special null type. An object is a dynamically created instance of a class type or a dynamically created array. The values of a reference type are references to objects. All objects, including arrays, support the methods of class Object . String literals are represented by String objects .” [2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, as mentioned before, in Java, there are two “Types”:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type:lower-roman&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Primitive Type&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Reference Type&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Classes, Interfaces, Arrays are all consolidations of Primitive types, so they just need to “point” to or reference the primitive ones, hence the name.&lt;br /&gt;
It is sometimes confusing and difficult to come up with a clear and robust distinction between Types and Classes. One might think &amp;quot;Class to be a Type of Type&amp;quot;. &lt;br /&gt;
It is however important to know that in strict Object Oriented Languages, Type is a union of Classes and Primitives. This rule, more or less consistent (with some deviations where primitives are treated as classes). &lt;br /&gt;
 &lt;br /&gt;
==Types and Classes in Languages==&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
Ruby claims to be a strong object oriented language. It is object oriented to the extent that every thing is an object. Primitive datatypes are objects, and we can make use of the object oriented techniques on even the primitives. As mentioned before, Ruby is a dynamic typed language, as the type is bound at compile time. Everything in Ruby has a class. Every class in Ruby is inherited from class Class. &lt;br /&gt;
&lt;br /&gt;
Type in Ruby is well defined as well. Using self inspection (reflection), we can find out whether a name is a Class, or a method. Let us see this in action:- &lt;br /&gt;
&lt;br /&gt;
The first thing that comes to a one’s mind is something like :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
&amp;quot;hello&amp;quot;.class #=&amp;gt; String&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
But have you thought of your class as an object? Well that seems odd, but that’s how ruby works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
class Foo;end  #=&amp;gt; nil&lt;br /&gt;
Foo.class #=&amp;gt; Class&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What does the above snippet of code mean exactly?&lt;br /&gt;
It means 2 things : Foo is a constant and that constant holds(refers to) an object of Class type.&lt;br /&gt;
&lt;br /&gt;
Let us prove that:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Foo = Class.new&lt;br /&gt;
(irb):8 warning: already initialized constant Foo&lt;br /&gt;
=&amp;gt; Foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
As you can see, we got a warning because we tried to initialize the constant Foo again.&lt;br /&gt;
&lt;br /&gt;
So ,when you define some class ‘Foo’ in ruby, all you are doing is:&lt;br /&gt;
1-instantiating an object of type Class.&lt;br /&gt;
2-initializing a constant Foo that refers to that created object .&lt;br /&gt;
&lt;br /&gt;
So, when we say “object” ,then we do mean any object; an object of Class type, or any object of any type.[3]&lt;br /&gt;
&lt;br /&gt;
===Java===&lt;br /&gt;
&lt;br /&gt;
As mentioned before, Java is a strongly typed language. The type of data needs to be declared before using. The types of &amp;quot;types&amp;quot; in Java are :&lt;br /&gt;
   * Primitive Types:-  boolean and numeric. The numeric types are the integral types byte, short, int, long, and char, and the         &lt;br /&gt;
     floating-point types float and double. &lt;br /&gt;
   * Reference Types:- class types, interface types and array types. [2] &lt;br /&gt;
&lt;br /&gt;
Java is an object-oriented language, but it does make a clear distinction between the primitive type and Classes. int, float, char etc. are primitives, and the other data types other than the primitives are references. It is an interesting distinction to note, because of the differences in method calling system in different languages. Java makes a distinction in &amp;quot;calling-by-value&amp;quot; when a primitive is passed as a parameter, and &amp;quot;calling-by-reference&amp;quot; when an object is passed. In fact, if a primitive is passed, a call by value is invoked, but when a Class object is passed, only a reference is passed to the object. &lt;br /&gt;
&lt;br /&gt;
For a more language specific treatment of types and classes, you can refer: http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_6_ap &lt;br /&gt;
&lt;br /&gt;
==Discussion of Issues==&lt;br /&gt;
Okay, so you're about to write a program and you need to represent data somehow.  Should you use a primitive type?  What about a class?  There are several features that are handed to you with each.&lt;br /&gt;
&lt;br /&gt;
=== Primitive Types ===&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Simplicity =====&lt;br /&gt;
In strongly typed languages, primitive types are ideal for data which doesn't necessarily need to be partitioned into several smaller components.  If you are looking to store and represent a simple throw-away integer for looping, for example, there's little reason why one would want to construct a class for this throw-away integer purpose.&lt;br /&gt;
&lt;br /&gt;
Primitive types are also often times coupled with native operations, handed to you by the language.  For example, in Java, variables of type int are automatically given operations such as addition, subtraction, multiplication, and so on.  These operations work as follows:&lt;br /&gt;
# Receive both inputs&lt;br /&gt;
# Cast if necessary (for example, from an int to a double)&lt;br /&gt;
# Perform calculation&lt;br /&gt;
# Return result&lt;br /&gt;
&lt;br /&gt;
It is important to note that the primitive types themselves are left ''unchanged'', and the result is returned from the operation, giving the programmer the ability to place the result elsewhere.&lt;br /&gt;
&lt;br /&gt;
===== Efficiency =====&lt;br /&gt;
In efficiency-critical applications, primitive types and their operations are oftentimes mapped directly to hardware-supported equivalents, thus operations can be performed very quickly.  This style of downgrading the logic to more so the hardware level has been replaced over the years for general applications, since improvements to hardware components have eradicated the once-imperative necessity to program efficiently.  Another point of view concerning efficiency could be from development time: if the program one is writing doesn't require complex design, it would be quicker to use the language's built-in types instead of taking the time to design a class to do the same feature.&lt;br /&gt;
&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Single-state storage =====&lt;br /&gt;
One large disadvantages to primitive types are that they are generally capable of only holding a single dimension state.  This limitation requires the programmer to use other variables in conjunction if they desire to hold more than one field of data.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Since primitive types do not allow you to encapsulate your data, if you ever desire to change the behavior of your program, you are forced to manually check each use of the variable for enforcement.&lt;br /&gt;
&lt;br /&gt;
For example, suppose you have a system designed in Java that maintains an integer value which represents the number of books you have in a library.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
int numBooks;&lt;br /&gt;
...&lt;br /&gt;
numBooks = 0;&lt;br /&gt;
...&lt;br /&gt;
numBooks++;&lt;br /&gt;
...&lt;br /&gt;
numBooks--;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A few days later, you realize that you should probably refactor your system to maintain a log of when this variable updates.  You immediately face a problem since, as it is, your code directly manipulates a single-state type integer.  Without resorting to a more object-oriented solution, you would have to update each location in the code of where a change takes place in order to establish this bookkeeping (pun intended).&lt;br /&gt;
&amp;lt;code id=&amp;quot;bookKeeping&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public static void integerValueChanged(){&lt;br /&gt;
  // records that the value has been changed&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public static void main(String[]args){&lt;br /&gt;
  int numBooks;&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks = 0;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks++;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks--;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To generalize this concept, it is oftentimes necessary to modify &amp;quot;what happens&amp;quot; when something is updated, and this cannot be easily accomplished by merely using primitive types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Class Types ===&lt;br /&gt;
Classes to the rescue!  Classes give programmers the ability to construct complex data types that are also capable of defining their own operations, all while keeping the details and specifics black-boxed outsize of where the class will be used in the code.&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Multi-dimensional Storage =====&lt;br /&gt;
Contrasting to primitive types, classes allow programmers to couple a varying number of fields.  Grouping fields of data into a single class, then instantiating such an object and manipulating it is much more convenient than keeping track of several individual variables.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Oftentimes it is necessary to refactor a system to execute code when a change happens.  In object-land, we are able to do this through the ability to control what happens in our methods.&lt;br /&gt;
&lt;br /&gt;
Taking our [[#bookKeeping| example from above]], we can give a quick example of how a class could be defined to handle the situation much more elegantly.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public class RecordedNumber{&lt;br /&gt;
  // The integer value, kept concealed in the class&lt;br /&gt;
  private int value;&lt;br /&gt;
&lt;br /&gt;
  public RecordedNumber(int value){&lt;br /&gt;
    this.value = value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public int getValue(){&lt;br /&gt;
    return value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public void setValue(int newValue){&lt;br /&gt;
    // code to do any necessary recording.&lt;br /&gt;
    ...&lt;br /&gt;
    this.value = newValue;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class MyExample{&lt;br /&gt;
  public static void main(String[]args){&lt;br /&gt;
    RecordedNumber numBooks = new RecordedNumber(0);&lt;br /&gt;
    ...&lt;br /&gt;
    numBooks.setValue(4); // the object handles all necessary bookkeeping&lt;br /&gt;
    ...&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Code-reuse =====&lt;br /&gt;
Another nice feature to class-types encapsulate the concept surrounding code re-usability, especially in topics such as inheritance.  Classes allow the programmer to enhance an already existing class-type to be more specific, which in turn can prevent excessive code duplication.&lt;br /&gt;
&lt;br /&gt;
===== Application Structure =====&lt;br /&gt;
Designing an application in a object-oriented / class-specific style can reduce the challenges of designing and building a difficult system into merely making objects successfully interact.  It is from this concept that languages such as [http://en.wikipedia.org/wiki/Unified_Modeling_Language Unified Modeling Language (UML)] have been created, allowing software engineers to build around the notion of classes and their relationships to one another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Speed Considerations =====&lt;br /&gt;
In computational-intensive applications, objects built from classes tend to be less efficient than primitive data types built around procedural context.  This is due in part because of the object's creation, since it isn't supported directly hardware level.  Consideration is placed more so on good-design and coding-practices when implementing functionality around classes.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== Complexity =====&lt;br /&gt;
Oftentimes one doesn't need the functionality provided by classes to handle the problem they are trying to solve.  Consequently, such an unnecessary use oftentimes over-complicates the principle design and may add unnecessary burdens to maintain the code.  This regard is more so geared towards small-programs where objects and classes may not be the best fit for their implementation.  Examples of this situation vary, since it is highly opinionated, but are more so an example of bad design in an object-oriented sense: to quote Albert Einstein, &amp;quot;Everything should be made as simple as possible, but no simpler.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[1] http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html&lt;br /&gt;
&lt;br /&gt;
[2] Java:- Types, Values and Variables&lt;br /&gt;
    http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html&lt;br /&gt;
[3] Ruby Reflection ,http://www.khelll.com/blog/ruby/ruby-reflection/&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39338</id>
		<title>CSC/ECE 517 Fall 2010/ch3 4b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39338"/>
		<updated>2010-10-21T05:44:27Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Types vs Classes'''&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: #F2F2F2; border: solid thin black; padding: 5px;&amp;quot;&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.  This topic was covered three years ago (http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007), but all of the articles considered one language after the other, in a set of examples rather than a discussion of issues.  Make sure that you discuss the issues, using languages as examples rather than making language the primary means of organizing the chapter.&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Overall s.png|right|frame|Relationship between Type and Class]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
It is often that we talk about types, strongly typed, weakly typed, classes. To make it clear,  let us look into it clearly. Every programming language has a way to define a variable. A variable is a named address location which stores a particular value. &lt;br /&gt;
&lt;br /&gt;
[[Image:Connection s.png|right|thumb|Classes are a 'type' that can combine other types.]]&lt;br /&gt;
&lt;br /&gt;
===Types===&lt;br /&gt;
&lt;br /&gt;
Time for an analogy? Imagine a variable to be a vacant house. It could have animals, humans, robots, or another smaller house, or whatever you can think of. There has to be a way, from a third party perspective, so as to be cognizant of the kind of things that reside in the house. Types and typing is a concept which realizes this concept. A typed language or a strongly typed language is one where the type of a variable has to be declared so as to avoid any wrong dealings of the value during run time. For example, Java is a strongly typed language. If I need to use two integers for addition, I would explicitly have to mention them as an integer:- &lt;br /&gt;
&amp;lt;code style=&amp;quot;width:200px;&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  int integer1;&lt;br /&gt;
  int integer2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we can’t then re-initialize it to any other type in its defined scope.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  integer1 = “Hello World”;  // cannot map an int to a String&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the case of non-typed languages, say Ruby, or Visual Basic, etc. We don’t need to specify a type. &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  def variable1;&lt;br /&gt;
  def variable2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, it could be initialized with anything,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
as well as &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = “Good morning Vietnam”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Classes===&lt;br /&gt;
&lt;br /&gt;
A class is a “type” of variable specification. The difference between a class and a regular primitive integer, character, etc is that a class:-&lt;br /&gt;
&lt;br /&gt;
# consists of one or more primitive or non-primitive variables&lt;br /&gt;
# is a pre-defined structure&lt;br /&gt;
# defines methods which operate on the internal state of the object&lt;br /&gt;
&lt;br /&gt;
The Type of Class is “Class”, just like the Type of integer is “integer” in case of strongly typed languages. &lt;br /&gt;
&lt;br /&gt;
For example, in case of Java:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;“The types of the Java programming language are divided into two categories: primitive types and reference types. The primitive types are the boolean type and the numeric types. The numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double. The reference types are class types, interface types, and array types. There is also a special null type. An object is a dynamically created instance of a class type or a dynamically created array. The values of a reference type are references to objects. All objects, including arrays, support the methods of class Object . String literals are represented by String objects .” [2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, as mentioned before, in Java, there are two “Types”:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type:lower-roman&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Primitive Type&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Reference Type&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Classes, Interfaces, Arrays are all consolidations of Primitive types, so they just need to “point” to or reference the primitive ones, hence the name.&lt;br /&gt;
It is sometimes confusing and difficult to come up with a clear and robust distinction between Types and Classes. One might think &amp;quot;Class to be a Type of Type&amp;quot;. &lt;br /&gt;
It is however important to know that in strict Object Oriented Languages, Type is a union of Classes and Primitives. This rule, more or less consistent (with some deviations where primitives are treated as classes). &lt;br /&gt;
 &lt;br /&gt;
==Types and Classes in Languages==&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
Ruby claims to be a strong object oriented language. It is object oriented to the extent that every thing is an object. Primitive datatypes are objects, and we can make use of the object oriented techniques on even the primitives. As mentioned before, Ruby is a dynamic typed language, as the type is bound at compile time. Everything in Ruby has a class. Every class in Ruby is inherited from class Class. &lt;br /&gt;
&lt;br /&gt;
Type in Ruby is well defined as well. Using self inspection (reflection), we can find out whether a name is a Class, or a method. Let us see this in action:- &lt;br /&gt;
&lt;br /&gt;
The first thing that comes to a one’s mind is something like :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
&amp;quot;hello&amp;quot;.class #=&amp;gt; String&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
But have you thought of your class as an object? Well that seems odd, but that’s how ruby works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
class Foo;end  #=&amp;gt; nil&lt;br /&gt;
Foo.class #=&amp;gt; Class&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What does the above snippet of code mean exactly?&lt;br /&gt;
It means 2 things : Foo is a constant and that constant holds(refers to) an object of Class type.&lt;br /&gt;
&lt;br /&gt;
Let us prove that:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Foo = Class.new&lt;br /&gt;
(irb):8 warning: already initialized constant Foo&lt;br /&gt;
=&amp;gt; Foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
As you can see, we got a warning because we tried to initialize the constant Foo again.&lt;br /&gt;
&lt;br /&gt;
So ,when you define some class ‘Foo’ in ruby, all you are doing is:&lt;br /&gt;
1-instantiating an object of type Class.&lt;br /&gt;
2-initializing a constant Foo that refers to that created object .&lt;br /&gt;
&lt;br /&gt;
So, when we say “object” ,then we do mean any object; an object of Class type, or any object of any type.[3]&lt;br /&gt;
&lt;br /&gt;
===Java===&lt;br /&gt;
&lt;br /&gt;
As mentioned before, Java is a strongly typed language. The type of data needs to be declared before using. The types of &amp;quot;types&amp;quot; in Java are :&lt;br /&gt;
   * Primitive Types:-  boolean and numeric. The numeric types are the integral types byte, short, int, long, and char, and the         &lt;br /&gt;
     floating-point types float and double. &lt;br /&gt;
   * Reference Types:- class types, interface types and array types. [2] &lt;br /&gt;
&lt;br /&gt;
Java is an object-oriented language, but it does make a clear distinction between the primitive type and Classes. int, float, char etc. are primitives, and the other data types other than the primitives are references. It is an interesting distinction to note, because of the differences in method calling system in different languages. Java makes a distinction in &amp;quot;calling-by-value&amp;quot; when a primitive is passed as a parameter, and &amp;quot;calling-by-reference&amp;quot; when an object is passed. In fact, if a primitive is passed, a call by value is invoked, but when a Class object is passed, only a reference is passed to the object. &lt;br /&gt;
&lt;br /&gt;
For a more language specific treatment of types and classes, you can refer: http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_6_ap &lt;br /&gt;
&lt;br /&gt;
==Discussion of Issues==&lt;br /&gt;
Okay, so you're about to write a program and you need to represent data somehow.  Should you use a primitive type?  What about a class?  There are several features that are handed to you with each.&lt;br /&gt;
&lt;br /&gt;
=== Primitive Types ===&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Simplicity =====&lt;br /&gt;
In strongly typed languages, primitive types are ideal for data which doesn't necessarily need to be partitioned into several smaller components.  If you are looking to store and represent a simple throw-away integer for looping, for example, there's little reason why one would want to construct a class for this throw-away integer purpose.&lt;br /&gt;
&lt;br /&gt;
Primitive types are also often times coupled with native operations, handed to you by the language.  For example, in Java, variables of type int are automatically given operations such as addition, subtraction, multiplication, and so on.  These operations work as follows:&lt;br /&gt;
# Receive both inputs&lt;br /&gt;
# Cast if necessary (for example, from an int to a double)&lt;br /&gt;
# Perform calculation&lt;br /&gt;
# Return result&lt;br /&gt;
&lt;br /&gt;
It is important to note that the primitive types themselves are left ''unchanged'', and the result is returned from the operation, giving the programmer the ability to place the result elsewhere.&lt;br /&gt;
&lt;br /&gt;
===== Efficiency =====&lt;br /&gt;
In efficiency-critical applications, primitive types and their operations are oftentimes mapped directly to hardware-supported equivalents, thus operations can be performed very quickly.  This style of downgrading the logic to more so the hardware level has been replaced over the years for general applications, since improvements to hardware components have eradicated the once-imperative necessity to program efficiently.  Another point of view concerning efficiency could be from development time: if the program one is writing doesn't require complex design, it would be quicker to use the language's built-in types instead of taking the time to design a class to do the same feature.&lt;br /&gt;
&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Single-state storage =====&lt;br /&gt;
One large disadvantages to primitive types are that they are generally capable of only holding a single dimension state.  This limitation requires the programmer to use other variables in conjunction if they desire to hold more than one field of data.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Since primitive types do not allow you to encapsulate your data, if you ever desire to change the behavior of your program, you are forced to manually check each use of the variable for enforcement.&lt;br /&gt;
&lt;br /&gt;
For example, suppose you have a system designed in Java that maintains an integer value which represents the number of books you have in a library.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
int numBooks;&lt;br /&gt;
...&lt;br /&gt;
numBooks = 0;&lt;br /&gt;
...&lt;br /&gt;
numBooks++;&lt;br /&gt;
...&lt;br /&gt;
numBooks--;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A few days later, you realize that you should probably refactor your system to maintain a log of when this variable updates.  You immediately face a problem since, as it is, your code directly manipulates a single-state type integer.  Without resorting to a more object-oriented solution, you would have to update each location in the code of where a change takes place in order to establish this bookkeeping (pun intended).&lt;br /&gt;
&amp;lt;code id=&amp;quot;bookKeeping&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public static void integerValueChanged(){&lt;br /&gt;
  // records that the value has been changed&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public static void main(String[]args){&lt;br /&gt;
  int numBooks;&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks = 0;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks++;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks--;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To generalize this concept, it is oftentimes necessary to modify &amp;quot;what happens&amp;quot; when something is updated, and this cannot be easily accomplished by merely using primitive types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Class Types ===&lt;br /&gt;
Classes to the rescue!  Classes give programmers the ability to construct complex data types that are also capable of defining their own operations, all while keeping the details and specifics black-boxed outsize of where the class will be used in the code.&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Multi-dimensional Storage =====&lt;br /&gt;
Contrasting to primitive types, classes allow programmers to couple a varying number of fields.  Grouping fields of data into a single class, then instantiating such an object and manipulating it is much more convenient than keeping track of several individual variables.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Oftentimes it is necessary to refactor a system to execute code when a change happens.  In object-land, we are able to do this through the ability to control what happens in our methods.&lt;br /&gt;
&lt;br /&gt;
Taking our [[#bookKeeping| example from above]], we can give a quick example of how a class could be defined to handle the situation much more elegantly.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public class RecordedNumber{&lt;br /&gt;
  // The integer value, kept concealed in the class&lt;br /&gt;
  private int value;&lt;br /&gt;
&lt;br /&gt;
  public RecordedNumber(int value){&lt;br /&gt;
    this.value = value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public int getValue(){&lt;br /&gt;
    return value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public void setValue(int newValue){&lt;br /&gt;
    // code to do any necessary recording.&lt;br /&gt;
    ...&lt;br /&gt;
    this.value = newValue;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class MyExample{&lt;br /&gt;
  public static void main(String[]args){&lt;br /&gt;
    RecordedNumber numBooks = new RecordedNumber(0);&lt;br /&gt;
    ...&lt;br /&gt;
    numBooks.setValue(4); // the object handles all necessary bookkeeping&lt;br /&gt;
    ...&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Code-reuse =====&lt;br /&gt;
Another nice feature to class-types encapsulate the concept surrounding code re-usability, especially in topics such as inheritance.  Classes allow the programmer to enhance an already existing class-type to be more specific, which in turn can prevent excessive code duplication.&lt;br /&gt;
&lt;br /&gt;
===== Application Structure =====&lt;br /&gt;
Designing an application in a object-oriented / class-specific style can reduce the challenges of designing and building a difficult system into merely making objects successfully interact.  It is from this concept that languages such as [http://en.wikipedia.org/wiki/Unified_Modeling_Language Unified Modeling Language (UML)] have been created, allowing software engineers to build around the notion of classes and their relationships to one another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Speed Considerations =====&lt;br /&gt;
In computational-intensive applications, objects built from classes tend to be less efficient than primitive data types built around procedural context.  This is due in part because of the object's creation, since it isn't supported directly hardware level.  Consideration is placed more so on good-design and coding-practices when implementing functionality around classes.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== Complexity =====&lt;br /&gt;
Oftentimes one doesn't need the functionality provided by classes to handle the problem they are trying to solve.  Consequently, such an unnecessary use oftentimes over-complicates the principle design and may add unnecessary burdens to maintain the code.  This regard is more so geared towards small-programs where objects and classes may not be the best fit for their implementation.  Examples of this situation vary, since it is highly opinionated, but are more so an example of bad design in an object-oriented sense: to quote Albert Einstein, &amp;quot;Everything should be made as simple as possible, but no simpler.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[1] http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html&lt;br /&gt;
&lt;br /&gt;
[2] Java:- Types, Values and Variables&lt;br /&gt;
    http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html&lt;br /&gt;
[3] Ruby Reflection ,http://www.khelll.com/blog/ruby/ruby-reflection/&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39337</id>
		<title>CSC/ECE 517 Fall 2010/ch3 4b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39337"/>
		<updated>2010-10-21T05:43:57Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Types vs Classes'''&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: #F2F2F2; border: solid thin black; padding: 5px;&amp;quot;&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.  This topic was covered three years ago (http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007), but all of the articles considered one language after the other, in a set of examples rather than a discussion of issues.  Make sure that you discuss the issues, using languages as examples rather than making language the primary means of organizing the chapter.&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Overall s.png|right|frame|Relationship between Type and Class]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
It is often that we talk about types, strongly typed, weakly typed, classes. To make it clear,  let us look into it clearly. Every programming language has a way to define a variable. A variable is a named address location which stores a particular value. &lt;br /&gt;
&lt;br /&gt;
[[Image:Connection s.png|right|thumb|Classes are a 'type' that can combine other types.]]&lt;br /&gt;
&lt;br /&gt;
===Types===&lt;br /&gt;
&lt;br /&gt;
Time for an analogy? Imagine a variable to be a vacant house. It could have animals, humans, robots, or another smaller house, or whatever you can think of. There has to be a way, from a third party perspective, so as to be cognizant of the kind of things that reside in the house. Types and typing is a concept which realizes this concept. A typed language or a strongly typed language is one where the type of a variable has to be declared so as to avoid any wrong dealings of the value during run time. For example, Java is a strongly typed language. If I need to use two integers for addition, I would explicitly have to mention them as an integer:- &lt;br /&gt;
&amp;lt;code style=&amp;quot;width:30em;&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  int integer1;&lt;br /&gt;
  int integer2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we can’t then re-initialize it to any other type in its defined scope.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  integer1 = “Hello World”;  // cannot map an int to a String&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the case of non-typed languages, say Ruby, or Visual Basic, etc. We don’t need to specify a type. &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  def variable1;&lt;br /&gt;
  def variable2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, it could be initialized with anything,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
as well as &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = “Good morning Vietnam”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Classes===&lt;br /&gt;
&lt;br /&gt;
A class is a “type” of variable specification. The difference between a class and a regular primitive integer, character, etc is that a class:-&lt;br /&gt;
&lt;br /&gt;
# consists of one or more primitive or non-primitive variables&lt;br /&gt;
# is a pre-defined structure&lt;br /&gt;
# defines methods which operate on the internal state of the object&lt;br /&gt;
&lt;br /&gt;
The Type of Class is “Class”, just like the Type of integer is “integer” in case of strongly typed languages. &lt;br /&gt;
&lt;br /&gt;
For example, in case of Java:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;“The types of the Java programming language are divided into two categories: primitive types and reference types. The primitive types are the boolean type and the numeric types. The numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double. The reference types are class types, interface types, and array types. There is also a special null type. An object is a dynamically created instance of a class type or a dynamically created array. The values of a reference type are references to objects. All objects, including arrays, support the methods of class Object . String literals are represented by String objects .” [2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, as mentioned before, in Java, there are two “Types”:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type:lower-roman&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Primitive Type&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Reference Type&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Classes, Interfaces, Arrays are all consolidations of Primitive types, so they just need to “point” to or reference the primitive ones, hence the name.&lt;br /&gt;
It is sometimes confusing and difficult to come up with a clear and robust distinction between Types and Classes. One might think &amp;quot;Class to be a Type of Type&amp;quot;. &lt;br /&gt;
It is however important to know that in strict Object Oriented Languages, Type is a union of Classes and Primitives. This rule, more or less consistent (with some deviations where primitives are treated as classes). &lt;br /&gt;
 &lt;br /&gt;
==Types and Classes in Languages==&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
Ruby claims to be a strong object oriented language. It is object oriented to the extent that every thing is an object. Primitive datatypes are objects, and we can make use of the object oriented techniques on even the primitives. As mentioned before, Ruby is a dynamic typed language, as the type is bound at compile time. Everything in Ruby has a class. Every class in Ruby is inherited from class Class. &lt;br /&gt;
&lt;br /&gt;
Type in Ruby is well defined as well. Using self inspection (reflection), we can find out whether a name is a Class, or a method. Let us see this in action:- &lt;br /&gt;
&lt;br /&gt;
The first thing that comes to a one’s mind is something like :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
&amp;quot;hello&amp;quot;.class #=&amp;gt; String&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
But have you thought of your class as an object? Well that seems odd, but that’s how ruby works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
class Foo;end  #=&amp;gt; nil&lt;br /&gt;
Foo.class #=&amp;gt; Class&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What does the above snippet of code mean exactly?&lt;br /&gt;
It means 2 things : Foo is a constant and that constant holds(refers to) an object of Class type.&lt;br /&gt;
&lt;br /&gt;
Let us prove that:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Foo = Class.new&lt;br /&gt;
(irb):8 warning: already initialized constant Foo&lt;br /&gt;
=&amp;gt; Foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
As you can see, we got a warning because we tried to initialize the constant Foo again.&lt;br /&gt;
&lt;br /&gt;
So ,when you define some class ‘Foo’ in ruby, all you are doing is:&lt;br /&gt;
1-instantiating an object of type Class.&lt;br /&gt;
2-initializing a constant Foo that refers to that created object .&lt;br /&gt;
&lt;br /&gt;
So, when we say “object” ,then we do mean any object; an object of Class type, or any object of any type.[3]&lt;br /&gt;
&lt;br /&gt;
===Java===&lt;br /&gt;
&lt;br /&gt;
As mentioned before, Java is a strongly typed language. The type of data needs to be declared before using. The types of &amp;quot;types&amp;quot; in Java are :&lt;br /&gt;
   * Primitive Types:-  boolean and numeric. The numeric types are the integral types byte, short, int, long, and char, and the         &lt;br /&gt;
     floating-point types float and double. &lt;br /&gt;
   * Reference Types:- class types, interface types and array types. [2] &lt;br /&gt;
&lt;br /&gt;
Java is an object-oriented language, but it does make a clear distinction between the primitive type and Classes. int, float, char etc. are primitives, and the other data types other than the primitives are references. It is an interesting distinction to note, because of the differences in method calling system in different languages. Java makes a distinction in &amp;quot;calling-by-value&amp;quot; when a primitive is passed as a parameter, and &amp;quot;calling-by-reference&amp;quot; when an object is passed. In fact, if a primitive is passed, a call by value is invoked, but when a Class object is passed, only a reference is passed to the object. &lt;br /&gt;
&lt;br /&gt;
For a more language specific treatment of types and classes, you can refer: http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_6_ap &lt;br /&gt;
&lt;br /&gt;
==Discussion of Issues==&lt;br /&gt;
Okay, so you're about to write a program and you need to represent data somehow.  Should you use a primitive type?  What about a class?  There are several features that are handed to you with each.&lt;br /&gt;
&lt;br /&gt;
=== Primitive Types ===&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Simplicity =====&lt;br /&gt;
In strongly typed languages, primitive types are ideal for data which doesn't necessarily need to be partitioned into several smaller components.  If you are looking to store and represent a simple throw-away integer for looping, for example, there's little reason why one would want to construct a class for this throw-away integer purpose.&lt;br /&gt;
&lt;br /&gt;
Primitive types are also often times coupled with native operations, handed to you by the language.  For example, in Java, variables of type int are automatically given operations such as addition, subtraction, multiplication, and so on.  These operations work as follows:&lt;br /&gt;
# Receive both inputs&lt;br /&gt;
# Cast if necessary (for example, from an int to a double)&lt;br /&gt;
# Perform calculation&lt;br /&gt;
# Return result&lt;br /&gt;
&lt;br /&gt;
It is important to note that the primitive types themselves are left ''unchanged'', and the result is returned from the operation, giving the programmer the ability to place the result elsewhere.&lt;br /&gt;
&lt;br /&gt;
===== Efficiency =====&lt;br /&gt;
In efficiency-critical applications, primitive types and their operations are oftentimes mapped directly to hardware-supported equivalents, thus operations can be performed very quickly.  This style of downgrading the logic to more so the hardware level has been replaced over the years for general applications, since improvements to hardware components have eradicated the once-imperative necessity to program efficiently.  Another point of view concerning efficiency could be from development time: if the program one is writing doesn't require complex design, it would be quicker to use the language's built-in types instead of taking the time to design a class to do the same feature.&lt;br /&gt;
&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Single-state storage =====&lt;br /&gt;
One large disadvantages to primitive types are that they are generally capable of only holding a single dimension state.  This limitation requires the programmer to use other variables in conjunction if they desire to hold more than one field of data.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Since primitive types do not allow you to encapsulate your data, if you ever desire to change the behavior of your program, you are forced to manually check each use of the variable for enforcement.&lt;br /&gt;
&lt;br /&gt;
For example, suppose you have a system designed in Java that maintains an integer value which represents the number of books you have in a library.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
int numBooks;&lt;br /&gt;
...&lt;br /&gt;
numBooks = 0;&lt;br /&gt;
...&lt;br /&gt;
numBooks++;&lt;br /&gt;
...&lt;br /&gt;
numBooks--;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A few days later, you realize that you should probably refactor your system to maintain a log of when this variable updates.  You immediately face a problem since, as it is, your code directly manipulates a single-state type integer.  Without resorting to a more object-oriented solution, you would have to update each location in the code of where a change takes place in order to establish this bookkeeping (pun intended).&lt;br /&gt;
&amp;lt;code id=&amp;quot;bookKeeping&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public static void integerValueChanged(){&lt;br /&gt;
  // records that the value has been changed&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public static void main(String[]args){&lt;br /&gt;
  int numBooks;&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks = 0;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks++;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks--;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To generalize this concept, it is oftentimes necessary to modify &amp;quot;what happens&amp;quot; when something is updated, and this cannot be easily accomplished by merely using primitive types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Class Types ===&lt;br /&gt;
Classes to the rescue!  Classes give programmers the ability to construct complex data types that are also capable of defining their own operations, all while keeping the details and specifics black-boxed outsize of where the class will be used in the code.&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Multi-dimensional Storage =====&lt;br /&gt;
Contrasting to primitive types, classes allow programmers to couple a varying number of fields.  Grouping fields of data into a single class, then instantiating such an object and manipulating it is much more convenient than keeping track of several individual variables.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Oftentimes it is necessary to refactor a system to execute code when a change happens.  In object-land, we are able to do this through the ability to control what happens in our methods.&lt;br /&gt;
&lt;br /&gt;
Taking our [[#bookKeeping| example from above]], we can give a quick example of how a class could be defined to handle the situation much more elegantly.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public class RecordedNumber{&lt;br /&gt;
  // The integer value, kept concealed in the class&lt;br /&gt;
  private int value;&lt;br /&gt;
&lt;br /&gt;
  public RecordedNumber(int value){&lt;br /&gt;
    this.value = value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public int getValue(){&lt;br /&gt;
    return value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public void setValue(int newValue){&lt;br /&gt;
    // code to do any necessary recording.&lt;br /&gt;
    ...&lt;br /&gt;
    this.value = newValue;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class MyExample{&lt;br /&gt;
  public static void main(String[]args){&lt;br /&gt;
    RecordedNumber numBooks = new RecordedNumber(0);&lt;br /&gt;
    ...&lt;br /&gt;
    numBooks.setValue(4); // the object handles all necessary bookkeeping&lt;br /&gt;
    ...&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Code-reuse =====&lt;br /&gt;
Another nice feature to class-types encapsulate the concept surrounding code re-usability, especially in topics such as inheritance.  Classes allow the programmer to enhance an already existing class-type to be more specific, which in turn can prevent excessive code duplication.&lt;br /&gt;
&lt;br /&gt;
===== Application Structure =====&lt;br /&gt;
Designing an application in a object-oriented / class-specific style can reduce the challenges of designing and building a difficult system into merely making objects successfully interact.  It is from this concept that languages such as [http://en.wikipedia.org/wiki/Unified_Modeling_Language Unified Modeling Language (UML)] have been created, allowing software engineers to build around the notion of classes and their relationships to one another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Speed Considerations =====&lt;br /&gt;
In computational-intensive applications, objects built from classes tend to be less efficient than primitive data types built around procedural context.  This is due in part because of the object's creation, since it isn't supported directly hardware level.  Consideration is placed more so on good-design and coding-practices when implementing functionality around classes.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== Complexity =====&lt;br /&gt;
Oftentimes one doesn't need the functionality provided by classes to handle the problem they are trying to solve.  Consequently, such an unnecessary use oftentimes over-complicates the principle design and may add unnecessary burdens to maintain the code.  This regard is more so geared towards small-programs where objects and classes may not be the best fit for their implementation.  Examples of this situation vary, since it is highly opinionated, but are more so an example of bad design in an object-oriented sense: to quote Albert Einstein, &amp;quot;Everything should be made as simple as possible, but no simpler.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[1] http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html&lt;br /&gt;
&lt;br /&gt;
[2] Java:- Types, Values and Variables&lt;br /&gt;
    http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html&lt;br /&gt;
[3] Ruby Reflection ,http://www.khelll.com/blog/ruby/ruby-reflection/&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39336</id>
		<title>CSC/ECE 517 Fall 2010/ch3 4b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39336"/>
		<updated>2010-10-21T05:40:44Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Types vs Classes'''&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: #F2F2F2; border: solid thin black; padding: 5px;&amp;quot;&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.  This topic was covered three years ago (http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007), but all of the articles considered one language after the other, in a set of examples rather than a discussion of issues.  Make sure that you discuss the issues, using languages as examples rather than making language the primary means of organizing the chapter.&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Overall s.png|right|frame|Relationship between Type and Class]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
It is often that we talk about types, strongly typed, weakly typed, classes. To make it clear,  let us look into it clearly. Every programming language has a way to define a variable. A variable is a named address location which stores a particular value. &lt;br /&gt;
&lt;br /&gt;
[[Image:Connection s.png|right|thumb|Classes are a 'type' that can combine other types.]]&lt;br /&gt;
&lt;br /&gt;
===Types===&lt;br /&gt;
&lt;br /&gt;
Time for an analogy? Imagine a variable to be a vacant house. It could have animals, humans, robots, or another smaller house, or whatever you can think of. There has to be a way, from a third party perspective, so as to be cognizant of the kind of things that reside in the house. Types and typing is a concept which realizes this concept. A typed language or a strongly typed language is one where the type of a variable has to be declared so as to avoid any wrong dealings of the value during run time. For example, Java is a strongly typed language. If I need to use two integers for addition, I would explicitly have to mention them as an integer:- &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  int integer1;&lt;br /&gt;
  int integer2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we can’t then re-initialize it to any other type in its defined scope.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  integer1 = “Hello World”;  // cannot map an int to a String&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the case of non-typed languages, say Ruby, or Visual Basic, etc. We don’t need to specify a type. &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  def variable1;&lt;br /&gt;
  def variable2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, it could be initialized with anything,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
as well as &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = “Good morning Vietnam”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Classes===&lt;br /&gt;
&lt;br /&gt;
A class is a “type” of variable specification. The difference between a class and a regular primitive integer, character, etc is that a class:-&lt;br /&gt;
&lt;br /&gt;
# consists of one or more primitive or non-primitive variables&lt;br /&gt;
# is a pre-defined structure&lt;br /&gt;
# defines methods which operate on the internal state of the object&lt;br /&gt;
&lt;br /&gt;
The Type of Class is “Class”, just like the Type of integer is “integer” in case of strongly typed languages. &lt;br /&gt;
&lt;br /&gt;
For example, in case of Java:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;“The types of the Java programming language are divided into two categories: primitive types and reference types. The primitive types are the boolean type and the numeric types. The numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double. The reference types are class types, interface types, and array types. There is also a special null type. An object is a dynamically created instance of a class type or a dynamically created array. The values of a reference type are references to objects. All objects, including arrays, support the methods of class Object . String literals are represented by String objects .” [2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, as mentioned before, in Java, there are two “Types”:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type:lower-roman&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Primitive Type&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Reference Type&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Classes, Interfaces, Arrays are all consolidations of Primitive types, so they just need to “point” to or reference the primitive ones, hence the name.&lt;br /&gt;
It is sometimes confusing and difficult to come up with a clear and robust distinction between Types and Classes. One might think &amp;quot;Class to be a Type of Type&amp;quot;. &lt;br /&gt;
It is however important to know that in strict Object Oriented Languages, Type is a union of Classes and Primitives. This rule, more or less consistent (with some deviations where primitives are treated as classes). &lt;br /&gt;
 &lt;br /&gt;
==Types and Classes in Languages==&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
Ruby claims to be a strong object oriented language. It is object oriented to the extent that every thing is an object. Primitive datatypes are objects, and we can make use of the object oriented techniques on even the primitives. As mentioned before, Ruby is a dynamic typed language, as the type is bound at compile time. Everything in Ruby has a class. Every class in Ruby is inherited from class Class. &lt;br /&gt;
&lt;br /&gt;
Type in Ruby is well defined as well. Using self inspection (reflection), we can find out whether a name is a Class, or a method. Let us see this in action:- &lt;br /&gt;
&lt;br /&gt;
The first thing that comes to a one’s mind is something like :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
&amp;quot;hello&amp;quot;.class #=&amp;gt; String&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
But have you thought of your class as an object? Well that seems odd, but that’s how ruby works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
class Foo;end  #=&amp;gt; nil&lt;br /&gt;
Foo.class #=&amp;gt; Class&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What does the above snippet of code mean exactly?&lt;br /&gt;
It means 2 things : Foo is a constant and that constant holds(refers to) an object of Class type.&lt;br /&gt;
&lt;br /&gt;
Let us prove that:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Foo = Class.new&lt;br /&gt;
(irb):8 warning: already initialized constant Foo&lt;br /&gt;
=&amp;gt; Foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
As you can see, we got a warning because we tried to initialize the constant Foo again.&lt;br /&gt;
&lt;br /&gt;
So ,when you define some class ‘Foo’ in ruby, all you are doing is:&lt;br /&gt;
1-instantiating an object of type Class.&lt;br /&gt;
2-initializing a constant Foo that refers to that created object .&lt;br /&gt;
&lt;br /&gt;
So, when we say “object” ,then we do mean any object; an object of Class type, or any object of any type.[3]&lt;br /&gt;
&lt;br /&gt;
===Java===&lt;br /&gt;
&lt;br /&gt;
As mentioned before, Java is a strongly typed language. The type of data needs to be declared before using. The types of &amp;quot;types&amp;quot; in Java are :&lt;br /&gt;
   * Primitive Types:-  boolean and numeric. The numeric types are the integral types byte, short, int, long, and char, and the         &lt;br /&gt;
     floating-point types float and double. &lt;br /&gt;
   * Reference Types:- class types, interface types and array types. [2] &lt;br /&gt;
&lt;br /&gt;
Java is an object-oriented language, but it does make a clear distinction between the primitive type and Classes. int, float, char etc. are primitives, and the other data types other than the primitives are references. It is an interesting distinction to note, because of the differences in method calling system in different languages. Java makes a distinction in &amp;quot;calling-by-value&amp;quot; when a primitive is passed as a parameter, and &amp;quot;calling-by-reference&amp;quot; when an object is passed. In fact, if a primitive is passed, a call by value is invoked, but when a Class object is passed, only a reference is passed to the object. &lt;br /&gt;
&lt;br /&gt;
For a more language specific treatment of types and classes, you can refer: http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_6_ap &lt;br /&gt;
&lt;br /&gt;
==Discussion of Issues==&lt;br /&gt;
Okay, so you're about to write a program and you need to represent data somehow.  Should you use a primitive type?  What about a class?  There are several features that are handed to you with each.&lt;br /&gt;
&lt;br /&gt;
=== Primitive Types ===&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Simplicity =====&lt;br /&gt;
In strongly typed languages, primitive types are ideal for data which doesn't necessarily need to be partitioned into several smaller components.  If you are looking to store and represent a simple throw-away integer for looping, for example, there's little reason why one would want to construct a class for this throw-away integer purpose.&lt;br /&gt;
&lt;br /&gt;
Primitive types are also often times coupled with native operations, handed to you by the language.  For example, in Java, variables of type int are automatically given operations such as addition, subtraction, multiplication, and so on.  These operations work as follows:&lt;br /&gt;
# Receive both inputs&lt;br /&gt;
# Cast if necessary (for example, from an int to a double)&lt;br /&gt;
# Perform calculation&lt;br /&gt;
# Return result&lt;br /&gt;
&lt;br /&gt;
It is important to note that the primitive types themselves are left ''unchanged'', and the result is returned from the operation, giving the programmer the ability to place the result elsewhere.&lt;br /&gt;
&lt;br /&gt;
===== Efficiency =====&lt;br /&gt;
In efficiency-critical applications, primitive types and their operations are oftentimes mapped directly to hardware-supported equivalents, thus operations can be performed very quickly.  This style of downgrading the logic to more so the hardware level has been replaced over the years for general applications, since improvements to hardware components have eradicated the once-imperative necessity to program efficiently.  Another point of view concerning efficiency could be from development time: if the program one is writing doesn't require complex design, it would be quicker to use the language's built-in types instead of taking the time to design a class to do the same feature.&lt;br /&gt;
&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Single-state storage =====&lt;br /&gt;
One large disadvantages to primitive types are that they are generally capable of only holding a single dimension state.  This limitation requires the programmer to use other variables in conjunction if they desire to hold more than one field of data.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Since primitive types do not allow you to encapsulate your data, if you ever desire to change the behavior of your program, you are forced to manually check each use of the variable for enforcement.&lt;br /&gt;
&lt;br /&gt;
For example, suppose you have a system designed in Java that maintains an integer value which represents the number of books you have in a library.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
int numBooks;&lt;br /&gt;
...&lt;br /&gt;
numBooks = 0;&lt;br /&gt;
...&lt;br /&gt;
numBooks++;&lt;br /&gt;
...&lt;br /&gt;
numBooks--;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A few days later, you realize that you should probably refactor your system to maintain a log of when this variable updates.  You immediately face a problem since, as it is, your code directly manipulates a single-state type integer.  Without resorting to a more object-oriented solution, you would have to update each location in the code of where a change takes place in order to establish this bookkeeping (pun intended).&lt;br /&gt;
&amp;lt;code id=&amp;quot;bookKeeping&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public static void integerValueChanged(){&lt;br /&gt;
  // records that the value has been changed&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public static void main(String[]args){&lt;br /&gt;
  int numBooks;&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks = 0;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks++;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks--;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To generalize this concept, it is oftentimes necessary to modify &amp;quot;what happens&amp;quot; when something is updated, and this cannot be easily accomplished by merely using primitive types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Class Types ===&lt;br /&gt;
Classes to the rescue!  Classes give programmers the ability to construct complex data types that are also capable of defining their own operations, all while keeping the details and specifics black-boxed outsize of where the class will be used in the code.&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Multi-dimensional Storage =====&lt;br /&gt;
Contrasting to primitive types, classes allow programmers to couple a varying number of fields.  Grouping fields of data into a single class, then instantiating such an object and manipulating it is much more convenient than keeping track of several individual variables.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Oftentimes it is necessary to refactor a system to execute code when a change happens.  In object-land, we are able to do this through the ability to control what happens in our methods.&lt;br /&gt;
&lt;br /&gt;
Taking our [[#bookKeeping| example from above]], we can give a quick example of how a class could be defined to handle the situation much more elegantly.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public class RecordedNumber{&lt;br /&gt;
  // The integer value, kept concealed in the class&lt;br /&gt;
  private int value;&lt;br /&gt;
&lt;br /&gt;
  public RecordedNumber(int value){&lt;br /&gt;
    this.value = value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public int getValue(){&lt;br /&gt;
    return value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public void setValue(int newValue){&lt;br /&gt;
    // code to do any necessary recording.&lt;br /&gt;
    ...&lt;br /&gt;
    this.value = newValue;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class MyExample{&lt;br /&gt;
  public static void main(String[]args){&lt;br /&gt;
    RecordedNumber numBooks = new RecordedNumber(0);&lt;br /&gt;
    ...&lt;br /&gt;
    numBooks.setValue(4); // the object handles all necessary bookkeeping&lt;br /&gt;
    ...&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Code-reuse =====&lt;br /&gt;
Another nice feature to class-types encapsulate the concept surrounding code re-usability, especially in topics such as inheritance.  Classes allow the programmer to enhance an already existing class-type to be more specific, which in turn can prevent excessive code duplication.&lt;br /&gt;
&lt;br /&gt;
===== Application Structure =====&lt;br /&gt;
Designing an application in a object-oriented / class-specific style can reduce the challenges of designing and building a difficult system into merely making objects successfully interact.  It is from this concept that languages such as [http://en.wikipedia.org/wiki/Unified_Modeling_Language Unified Modeling Language (UML)] have been created, allowing software engineers to build around the notion of classes and their relationships to one another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Speed Considerations =====&lt;br /&gt;
In computational-intensive applications, objects built from classes tend to be less efficient than primitive data types built around procedural context.  This is due in part because of the object's creation, since it isn't supported directly hardware level.  Consideration is placed more so on good-design and coding-practices when implementing functionality around classes.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== Complexity =====&lt;br /&gt;
Oftentimes one doesn't need the functionality provided by classes to handle the problem they are trying to solve.  Consequently, such an unnecessary use oftentimes over-complicates the principle design and may add unnecessary burdens to maintain the code.  This regard is more so geared towards small-programs where objects and classes may not be the best fit for their implementation.  Examples of this situation vary, since it is highly opinionated, but are more so an example of bad design in an object-oriented sense: to quote Albert Einstein, &amp;quot;Everything should be made as simple as possible, but no simpler.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[1] http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html&lt;br /&gt;
&lt;br /&gt;
[2] Java:- Types, Values and Variables&lt;br /&gt;
    http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html&lt;br /&gt;
[3] Ruby Reflection ,http://www.khelll.com/blog/ruby/ruby-reflection/&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39335</id>
		<title>CSC/ECE 517 Fall 2010/ch3 4b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39335"/>
		<updated>2010-10-21T05:37:43Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Types vs Classes'''&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: #F2F2F2; border: solid thin black; padding: 5px;&amp;quot;&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.  This topic was covered three years ago (http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007), but all of the articles considered one language after the other, in a set of examples rather than a discussion of issues.  Make sure that you discuss the issues, using languages as examples rather than making language the primary means of organizing the chapter.&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Overall s.png|right|frame|Relationship between Type and Class]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
It is often that we talk about types, strongly typed, weakly typed, classes. To make it clear,  let us look into it clearly. Every programming language has a way to define a variable. A variable is a named address location which stores a particular value. &lt;br /&gt;
&lt;br /&gt;
[[Image:Connection s.png|right|thumb|Classes are a 'type' that can combine other types.]]&lt;br /&gt;
&lt;br /&gt;
===Types===&lt;br /&gt;
&lt;br /&gt;
Time for an analogy? Imagine a variable to be a vacant house. It could have animals, humans, robots, or another smaller house, or whatever you can think of. There has to be a way, from a third party perspective, so as to be cognizant of the kind of things that reside in the house. Types and typing is a concept which realizes this concept. A typed language or a strongly typed language is one where the type of a variable has to be declared so as to avoid any wrong dealings of the value during run time. For example, Java is a strongly typed language. If I need to use two integers for addition, I would explicitly have to mention them as an integer:- &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  int integer1;&lt;br /&gt;
  int integer2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we can’t then re-initialize it to any other type in its defined scope.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  integer1 = “Hello World”;  // cannot map an int to a String&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the case of non-typed languages, say Ruby, or Visual Basic, etc. We don’t need to specify a type. &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  def variable1;&lt;br /&gt;
  def variable2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, it could be initialized with anything,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
as well as &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = “Good morning Vietnam”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Classes===&lt;br /&gt;
&lt;br /&gt;
A class is a “type” of variable specification. The difference between a class and a regular primitive integer, character, etc is that a class:-&lt;br /&gt;
&lt;br /&gt;
# consists of one or more primitive or non-primitive variables&lt;br /&gt;
# is a pre-defined structure&lt;br /&gt;
# defines methods which operate on the internal state of the object&lt;br /&gt;
&lt;br /&gt;
The Type of Class is “Class”, just like the Type of integer is “integer” in case of strongly typed languages. &lt;br /&gt;
&lt;br /&gt;
For example, in case of Java:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;“The types of the Java programming language are divided into two categories: primitive types and reference types. The primitive types are the boolean type and the numeric types. The numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double. The reference types are class types, interface types, and array types. There is also a special null type. An object is a dynamically created instance of a class type or a dynamically created array. The values of a reference type are references to objects. All objects, including arrays, support the methods of class Object . String literals are represented by String objects .” [2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, as mentioned before, in Java, there are two “Types”:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type:lower-roman&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Primitive Type&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Reference Type&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Classes, Interfaces, Arrays are all consolidations of Primitive types, so they just need to “point” to or reference the primitive ones, hence the name.&lt;br /&gt;
It is sometimes confusing and difficult to come up with a clear and robust distinction between Types and Classes. One might think &amp;quot;Class to be a Type of Type&amp;quot;. &lt;br /&gt;
It is however important to know that in strict Object Oriented Languages, Type is a union of Classes and Primitives. This rule, more or less consistent (with some deviations where primitives are treated as classes). &lt;br /&gt;
 &lt;br /&gt;
==Types and Classes in Languages==&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
Ruby claims to be a strong object oriented language. It is object oriented to the extent that every thing is an object. Primitive datatypes are objects, and we can make use of the object oriented techniques on even the primitives. As mentioned before, Ruby is a dynamic typed language, as the type is bound at compile time. Everything in Ruby has a class. Every class in Ruby is inherited from class Class. &lt;br /&gt;
&lt;br /&gt;
Type in Ruby is well defined as well. Using self inspection (reflection), we can find out whether a name is a Class, or a method. Let us see this in action:- &lt;br /&gt;
&lt;br /&gt;
The first thing that comes to a one’s mind is something like :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
&amp;quot;hello&amp;quot;.class #=&amp;gt; String&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
But have you thought of your class as an object? Well that seems odd, but that’s how ruby works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
class Foo;end  #=&amp;gt; nil&lt;br /&gt;
Foo.class #=&amp;gt; Class&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What does the above snippet of code mean exactly?&lt;br /&gt;
It means 2 things : Foo is a constant and that constant holds(refers to) an object of Class type.&lt;br /&gt;
&lt;br /&gt;
Let us prove that:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Foo = Class.new&lt;br /&gt;
(irb):8 warning: already initialized constant Foo&lt;br /&gt;
=&amp;gt; Foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
As you can see, we got a warning because we tried to initialize the constant Foo again.&lt;br /&gt;
&lt;br /&gt;
So ,when you define some class ‘Foo’ in ruby, all you are doing is:&lt;br /&gt;
1-instantiating an object of type Class.&lt;br /&gt;
2-initializing a constant Foo that refers to that created object .&lt;br /&gt;
&lt;br /&gt;
So, when we say “object” ,then we do mean any object; an object of Class type, or any object of any type.[3]&lt;br /&gt;
&lt;br /&gt;
===Java===&lt;br /&gt;
&lt;br /&gt;
As mentioned before, Java is a strongly typed language. The type of data needs to be declared before using. The types of &amp;quot;types&amp;quot; in Java are :&lt;br /&gt;
   * Primitive Types:-  boolean and numeric. The numeric types are the integral types byte, short, int, long, and char, and the         &lt;br /&gt;
     floating-point types float and double. &lt;br /&gt;
   * Reference Types:- class types, interface types and array types. [2] &lt;br /&gt;
&lt;br /&gt;
Java is an object-oriented language, but it does make a clear distinction between the primitive type and Classes. int, float, char etc. are primitives, and the other data types other than the primitives are references. It is an interesting distinction to note, because of the differences in method calling system in different languages. Java makes a distinction in &amp;quot;calling-by-value&amp;quot; when a primitive is passed as a parameter, and &amp;quot;calling-by-reference&amp;quot; when an object is passed. In fact, if a primitive is passed, a call by value is invoked, but when a Class object is passed, only a reference is passed to the object. &lt;br /&gt;
&lt;br /&gt;
For a more language specific treatment of types and classes, you can refer: http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_6_ap &lt;br /&gt;
&lt;br /&gt;
==Discussion of Issues==&lt;br /&gt;
Okay, so you're about to write a program and you need to represent data somehow.  Should you use a primitive type?  What about a class?  There are several features that are handed to you with each.&lt;br /&gt;
&lt;br /&gt;
=== Primitive Types ===&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Simplicity =====&lt;br /&gt;
In strongly typed languages, primitive types are ideal for data which doesn't necessarily need to be partitioned into several smaller components.  If you are looking to store and represent a simple throw-away integer for looping, for example, there's little reason why one would want to construct a class for this throw-away integer purpose.&lt;br /&gt;
&lt;br /&gt;
Primitive types are also often times coupled with native operations, handed to you by the language.  For example, in Java, variables of type int are automatically given operations such as addition, subtraction, multiplication, and so on.  These operations work as follows:&lt;br /&gt;
# Receive both inputs&lt;br /&gt;
# Cast if necessary (for example, from an int to a double)&lt;br /&gt;
# Perform calculation&lt;br /&gt;
# Return result&lt;br /&gt;
&lt;br /&gt;
It is important to note that the primitive types themselves are left ''unchanged'', and the result is returned from the operation, giving the programmer the ability to place the result elsewhere.&lt;br /&gt;
&lt;br /&gt;
===== Efficiency =====&lt;br /&gt;
In efficiency-critical applications, primitive types and their operations are oftentimes mapped directly to hardware-supported equivalents, thus operations can be performed very quickly.  This style of downgrading the logic to more so the hardware level has been replaced over the years for general applications, since improvements to hardware components have eradicated the once-imperative necessity to program efficiently.  Another point of view concerning efficiency could be from development time: if the program one is writing doesn't require complex design, it would be quicker to use the language's built-in types instead of taking the time to design a class to do the same feature.&lt;br /&gt;
&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Single-state storage =====&lt;br /&gt;
One large disadvantages to primitive types are that they are generally capable of only holding a single dimension state.  This limitation requires the programmer to use other variables in conjunction if they desire to hold more than one field of data.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Since primitive types do not allow you to encapsulate your data, if you ever desire to change the behavior of your program, you are forced to manually check each use of the variable for enforcement.&lt;br /&gt;
&lt;br /&gt;
For example, suppose you have a system designed in Java that maintains an integer value which represents the number of books you have in a library.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
int numBooks;&lt;br /&gt;
...&lt;br /&gt;
numBooks = 0;&lt;br /&gt;
...&lt;br /&gt;
numBooks++;&lt;br /&gt;
...&lt;br /&gt;
numBooks--;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A few days later, you realize that you should probably refactor your system to maintain a log of when this variable updates.  You immediately face a problem since, as it is, your code directly manipulates a single-state type integer.  Without resorting to a more object-oriented solution, you would have to update each location in the code of where a change takes place in order to establish this bookkeeping (pun intended).&lt;br /&gt;
&amp;lt;code id=&amp;quot;bookKeeping&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public static void integerValueChanged(){&lt;br /&gt;
  // records that the value has been changed&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public static void main(String[]args){&lt;br /&gt;
  int numBooks;&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks = 0;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks++;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks--;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To generalize this concept, it is oftentimes necessary to modify &amp;quot;what happens&amp;quot; when something is updated, and this cannot be easily accomplished by merely using primitive types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Class Types ===&lt;br /&gt;
Classes to the rescue!  Classes give programmers the ability to construct complex data types that are also capable of defining their own operations, all while keeping the details and specifics black-boxed outsize of where the class will be used in the code.&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Multi-dimensional Storage =====&lt;br /&gt;
Contrasting to primitive types, classes allow programmers to couple a varying number of fields.  Grouping fields of data into a single class, then instantiating such an object and manipulating it is much more convenient than keeping track of several individual variables.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Oftentimes it is necessary to refactor a system to execute code when a change happens.  In object-land, we are able to do this through the ability to control what happens in our methods.&lt;br /&gt;
&lt;br /&gt;
Taking our [[#bookKeeping| example from above]], we can give a quick example of how a class could be defined to handle the situation much more elegantly.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public class RecordedNumber{&lt;br /&gt;
  // The integer value, kept concealed in the class&lt;br /&gt;
  private int value;&lt;br /&gt;
&lt;br /&gt;
  public RecordedNumber(int value){&lt;br /&gt;
    this.value = value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public int getValue(){&lt;br /&gt;
    return value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public void setValue(int newValue){&lt;br /&gt;
    // code to do any necessary recording.&lt;br /&gt;
    ...&lt;br /&gt;
    this.value = newValue;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class MyExample{&lt;br /&gt;
  public static void main(String[]args){&lt;br /&gt;
    RecordedNumber numBooks = new RecordedNumber(0);&lt;br /&gt;
    ...&lt;br /&gt;
    numBooks.setValue(4); // the object handles all necessary bookkeeping&lt;br /&gt;
    ...&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Code-reuse =====&lt;br /&gt;
Another nice feature to class-types encapsulate the concept surrounding code re-usability, especially in topics such as inheritance.  Classes allow the programmer to enhance an already existing class-type to be more specific, which in turn can prevent excessive code duplication.&lt;br /&gt;
&lt;br /&gt;
===== Application Structure =====&lt;br /&gt;
Designing an application in a object-oriented / class-specific style can reduce the challenges of designing and building a difficult system into merely making objects successfully interact.  It is from this concept that languages such as [http://en.wikipedia.org/wiki/Unified_Modeling_Language Unified Modeling Language (UML)] have been created, allowing software engineers to build around the notion of classes and their relationships to one another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Speed Considerations =====&lt;br /&gt;
In computational-intensive applications, objects built from classes tend to be less efficient than primitive data types built around procedural context.  This is due in part because of the object's creation, since it isn't supported directly hardware level.  Consideration is placed more so on good-design and coding-practices when implementing functionality around classes.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== Complexity =====&lt;br /&gt;
Oftentimes one doesn't need the functionality provided by classes to handle the problem they are trying to solve.  Consequently, such an unnecessary use oftentimes over-complicates the principle design and may add unnecessary burdens to maintain the code.  This regard is more so geared towards small-programs where objects and classes may not be the best fit for their implementation.  Examples of this situation vary, since it is highly opinionated, but are more so an example of bad design in an object-oriented sense: to quote Albert Einstein, &amp;quot;Everything should be made as simple as possible, but no simpler.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== C =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[1] http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html&lt;br /&gt;
&lt;br /&gt;
[2] Java:- Types, Values and Variables&lt;br /&gt;
    http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html&lt;br /&gt;
[3] Ruby Reflection ,http://www.khelll.com/blog/ruby/ruby-reflection/&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39334</id>
		<title>CSC/ECE 517 Fall 2010/ch3 4b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39334"/>
		<updated>2010-10-21T05:34:13Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Types vs Classes'''&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: #F2F2F2; border: solid thin black; padding: 5px;&amp;quot;&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.  This topic was covered three years ago (http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007), but all of the articles considered one language after the other, in a set of examples rather than a discussion of issues.  Make sure that you discuss the issues, using languages as examples rather than making language the primary means of organizing the chapter.&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Overall s.png|right|frame|Relationship between Type and Class]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
It is often that we talk about types, strongly typed, weakly typed, classes. To make it clear,  let us look into it clearly. Every programming language has a way to define a variable. A variable is a named address location which stores a particular value. &lt;br /&gt;
&lt;br /&gt;
[[Image:Connection s.png|right|thumb|Classes are a 'type' that can combine other types.]]&lt;br /&gt;
&lt;br /&gt;
===Types===&lt;br /&gt;
&lt;br /&gt;
Time for an analogy? Imagine a variable to be a vacant house. It could have animals, humans, robots, or another smaller house, or whatever you can think of. There has to be a way, from a third party perspective, so as to be cognizant of the kind of things that reside in the house. Types and typing is a concept which realizes this concept. A typed language or a strongly typed language is one where the type of a variable has to be declared so as to avoid any wrong dealings of the value during run time. For example, Java is a strongly typed language. If I need to use two integers for addition, I would explicitly have to mention them as an integer:- &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  int integer1;&lt;br /&gt;
  int integer2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we can’t then re-initialize it to any other type in its defined scope.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  integer1 = “Hello World”;  // cannot map an int to a String&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the case of non-typed languages, say Ruby, or Visual Basic, etc. We don’t need to specify a type. &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  def variable1;&lt;br /&gt;
  def variable2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, it could be initialized with anything,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
as well as &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = “Good morning Vietnam”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Classes===&lt;br /&gt;
&lt;br /&gt;
A class is a “type” of variable specification. The difference between a class and a regular primitive integer, character, etc is that a class:-&lt;br /&gt;
&lt;br /&gt;
# consists of one or more primitive or non-primitive variables&lt;br /&gt;
# is a pre-defined structure&lt;br /&gt;
# defines methods which operate on the internal state of the object&lt;br /&gt;
&lt;br /&gt;
The Type of Class is “Class”, just like the Type of integer is “integer” in case of strongly typed languages. &lt;br /&gt;
&lt;br /&gt;
For example, in case of Java:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;“The types of the Java programming language are divided into two categories: primitive types and reference types. The primitive types are the boolean type and the numeric types. The numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double. The reference types are class types, interface types, and array types. There is also a special null type. An object is a dynamically created instance of a class type or a dynamically created array. The values of a reference type are references to objects. All objects, including arrays, support the methods of class Object . String literals are represented by String objects .” [2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, as mentioned before, in Java, there are two “Types”:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type:lower-roman&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Primitive Type&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Reference Type&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Classes, Interfaces, Arrays are all consolidations of Primitive types, so they just need to “point” to or reference the primitive ones, hence the name.&lt;br /&gt;
It is sometimes confusing and difficult to come up with a clear and robust distinction between Types and Classes. One might think &amp;quot;Class to be a Type of Type&amp;quot;. &lt;br /&gt;
It is however important to know that in strict Object Oriented Languages, Type is a union of Classes and Primitives. This rule, more or less consistent (with some deviations where primitives are treated as classes). &lt;br /&gt;
 &lt;br /&gt;
==Types and Classes in Languages==&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
Ruby claims to be a strong object oriented language. It is object oriented to the extent that every thing is an object. Primitive datatypes are objects, and we can make use of the object oriented techniques on even the primitives. As mentioned before, Ruby is a dynamic typed language, as the type is bound at compile time. Everything in Ruby has a class. Every class in Ruby is inherited from class Class. &lt;br /&gt;
&lt;br /&gt;
Type in Ruby is well defined as well. Using self inspection (reflection), we can find out whether a name is a Class, or a method. Let us see this in action:- &lt;br /&gt;
&lt;br /&gt;
The first thing that comes to a one’s mind is something like :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
&amp;quot;hello&amp;quot;.class #=&amp;gt; String&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
But have you thought of your class as an object? Well that seems odd, but that’s how ruby works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
class Foo;end  #=&amp;gt; nil&lt;br /&gt;
Foo.class #=&amp;gt; Class&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What does the above snippet of code mean exactly?&lt;br /&gt;
It means 2 things : Foo is a constant and that constant holds(refers to) an object of Class type.&lt;br /&gt;
&lt;br /&gt;
Let us prove that:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Foo = Class.new&lt;br /&gt;
(irb):8 warning: already initialized constant Foo&lt;br /&gt;
=&amp;gt; Foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
As you can see, we got a warning because we tried to initialize the constant Foo again.&lt;br /&gt;
&lt;br /&gt;
So ,when you define some class ‘Foo’ in ruby, all you are doing is:&lt;br /&gt;
1-instantiating an object of type Class.&lt;br /&gt;
2-initializing a constant Foo that refers to that created object .&lt;br /&gt;
&lt;br /&gt;
So, when we say “object” ,then we do mean any object; an object of Class type, or any object of any type.[3]&lt;br /&gt;
&lt;br /&gt;
===Java===&lt;br /&gt;
&lt;br /&gt;
As mentioned before, Java is a strongly typed language. The type of data needs to be declared before using. The types of &amp;quot;types&amp;quot; in Java are :&lt;br /&gt;
   * Primitive Types:-  boolean and numeric. The numeric types are the integral types byte, short, int, long, and char, and the         &lt;br /&gt;
     floating-point types float and double. &lt;br /&gt;
   * Reference Types:- class types, interface types and array types. [2] &lt;br /&gt;
&lt;br /&gt;
Java is an object-oriented language, but it does make a clear distinction between the primitive type and Classes. int, float, char etc. are primitives, and the other data types other than the primitives are references. It is an interesting distinction to note, because of the differences in method calling system in different languages. Java makes a distinction in &amp;quot;calling-by-value&amp;quot; when a primitive is passed as a parameter, and &amp;quot;calling-by-reference&amp;quot; when an object is passed. In fact, if a primitive is passed, a call by value is invoked, but when a Class object is passed, only a reference is passed to the object. &lt;br /&gt;
&lt;br /&gt;
For a more language specific treatment of types and classes, you can refer: http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_6_ap &lt;br /&gt;
&lt;br /&gt;
==Discussion of Issues==&lt;br /&gt;
Okay, so you're about to write a program and you need to represent data somehow.  Should you use a primitive type?  What about a class?  There are several features that are handed to you with each.&lt;br /&gt;
&lt;br /&gt;
=== Primitive Types ===&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Simplicity =====&lt;br /&gt;
In strongly typed languages, primitive types are ideal for data which doesn't necessarily need to be partitioned into several smaller components.  If you are looking to store and represent a simple throw-away integer for looping, for example, there's little reason why one would want to construct a class for this throw-away integer purpose.&lt;br /&gt;
&lt;br /&gt;
Primitive types are also often times coupled with native operations, handed to you by the language.  For example, in Java, variables of type int are automatically given operations such as addition, subtraction, multiplication, and so on.  These operations work as follows:&lt;br /&gt;
# Receive both inputs&lt;br /&gt;
# Cast if necessary (for example, from an int to a double)&lt;br /&gt;
# Perform calculation&lt;br /&gt;
# Return result&lt;br /&gt;
&lt;br /&gt;
It is important to note that the primitive types themselves are left ''unchanged'', and the result is returned from the operation, giving the programmer the ability to place the result elsewhere.&lt;br /&gt;
&lt;br /&gt;
===== Efficiency =====&lt;br /&gt;
In efficiency-critical applications, primitive types and their operations are oftentimes mapped directly to hardware-supported equivalents, thus operations can be performed very quickly.  This style of downgrading the logic to more so the hardware level has been replaced over the years for general applications, since improvements to hardware components have eradicated the once-imperative necessity to program efficiently.  Another point of view concerning efficiency could be from development time: if the program one is writing doesn't require complex design, it would be quicker to use the language's built-in types instead of taking the time to design a class to do the same feature.&lt;br /&gt;
&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Single-state storage =====&lt;br /&gt;
One large disadvantages to primitive types are that they are generally capable of only holding a single dimension state.  This limitation requires the programmer to use other variables in conjunction if they desire to hold more than one field of data.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Since primitive types do not allow you to encapsulate your data, if you ever desire to change the behavior of your program, you are forced to manually check each use of the variable for enforcement.&lt;br /&gt;
&lt;br /&gt;
For example, suppose you have a system designed in Java that maintains an integer value which represents the number of books you have in a library.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
int numBooks;&lt;br /&gt;
...&lt;br /&gt;
numBooks = 0;&lt;br /&gt;
...&lt;br /&gt;
numBooks++;&lt;br /&gt;
...&lt;br /&gt;
numBooks--;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A few days later, you realize that you should probably refactor your system to maintain a log of when this variable updates.  You immediately face a problem since, as it is, your code directly manipulates a single-state type integer.  Without resorting to a more object-oriented solution, you would have to update each location in the code of where a change takes place in order to establish this bookkeeping (pun intended).&lt;br /&gt;
&amp;lt;code id=&amp;quot;bookKeeping&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public static void integerValueChanged(){&lt;br /&gt;
  // records that the value has been changed&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public static void main(String[]args){&lt;br /&gt;
  int numBooks;&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks = 0;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks++;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks--;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To generalize this concept, it is oftentimes necessary to modify &amp;quot;what happens&amp;quot; when something is updated, and this cannot be easily accomplished by merely using primitive types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Class Types ===&lt;br /&gt;
Classes to the rescue!  Classes give programmers the ability to construct complex data types that are also capable of defining their own operations, all while keeping the details and specifics black-boxed outsize of where the class will be used in the code.&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Multi-dimensional Storage =====&lt;br /&gt;
Contrasting to primitive types, classes allow programmers to couple a varying number of fields.  Grouping fields of data into a single class, then instantiating such an object and manipulating it is much more convenient than keeping track of several individual variables.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Oftentimes it is necessary to refactor a system to execute code when a change happens.  In object-land, we are able to do this through the ability to control what happens in our methods.&lt;br /&gt;
&lt;br /&gt;
Taking our [[#bookKeeping| example from above]], we can give a quick example of how a class could be defined to handle the situation much more elegantly.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public class RecordedNumber{&lt;br /&gt;
  // The integer value, kept concealed in the class&lt;br /&gt;
  private int value;&lt;br /&gt;
&lt;br /&gt;
  public RecordedNumber(int value){&lt;br /&gt;
    this.value = value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public int getValue(){&lt;br /&gt;
    return value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public void setValue(int newValue){&lt;br /&gt;
    // code to do any necessary recording.&lt;br /&gt;
    ...&lt;br /&gt;
    this.value = newValue;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class MyExample{&lt;br /&gt;
  public static void main(String[]args){&lt;br /&gt;
    RecordedNumber numBooks = new RecordedNumber(0);&lt;br /&gt;
    ...&lt;br /&gt;
    numBooks.setValue(4); // the object handles all necessary bookkeeping&lt;br /&gt;
    ...&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Code-reuse =====&lt;br /&gt;
Another nice feature to class-types encapsulate the concept surrounding code re-usability, especially in topics such as inheritance.  Classes allow the programmer to enhance an already existing class-type to be more specific, which in turn can prevent excessive code duplication.&lt;br /&gt;
&lt;br /&gt;
===== Application Structure =====&lt;br /&gt;
Designing an application in a object-oriented / class-specific style can reduce the challenges of designing and building a difficult system into merely making objects successfully interact.  It is from this concept that languages such as [http://en.wikipedia.org/wiki/Unified_Modeling_Language Unified Modeling Language (UML)] have been created, allowing software engineers to build around the notion of classes and their relationships to one another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Speed Considerations =====&lt;br /&gt;
In computational-intensive applications, objects built from classes tend to be less efficient than primitive data types built around procedural context.  This is due in part because of the object's creation, since it isn't supported directly hardware level.  Consideration is placed more so on good-design and coding-practices when implementing functionality around classes.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== Complexity =====&lt;br /&gt;
Oftentimes one doesn't need the functionality provided by classes to handle the problem they are trying to solve.  Consequently, such an unnecessary use oftentimes over-complicates the principle design and may add unnecessary burdens to maintain the code.  Examples of this situation vary, since it is highly opinionated, but are more so an example of bad design in an object-oriented sense: to quote Albert Einstein, &amp;quot;Everything should be made as simple as possible, but no simpler.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== C =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[1] http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html&lt;br /&gt;
&lt;br /&gt;
[2] Java:- Types, Values and Variables&lt;br /&gt;
    http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html&lt;br /&gt;
[3] Ruby Reflection ,http://www.khelll.com/blog/ruby/ruby-reflection/&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39333</id>
		<title>CSC/ECE 517 Fall 2010/ch3 4b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39333"/>
		<updated>2010-10-21T05:26:00Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Types vs Classes'''&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: #F2F2F2; border: solid thin black; padding: 5px;&amp;quot;&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.  This topic was covered three years ago (http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007), but all of the articles considered one language after the other, in a set of examples rather than a discussion of issues.  Make sure that you discuss the issues, using languages as examples rather than making language the primary means of organizing the chapter.&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Overall s.png|right|frame|Relationship between Type and Class]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
It is often that we talk about types, strongly typed, weakly typed, classes. To make it clear,  let us look into it clearly. Every programming language has a way to define a variable. A variable is a named address location which stores a particular value. &lt;br /&gt;
&lt;br /&gt;
[[Image:Connection s.png|right|thumb|Classes are a 'type' that can combine other types.]]&lt;br /&gt;
&lt;br /&gt;
===Types===&lt;br /&gt;
&lt;br /&gt;
Time for an analogy? Imagine a variable to be a vacant house. It could have animals, humans, robots, or another smaller house, or whatever you can think of. There has to be a way, from a third party perspective, so as to be cognizant of the kind of things that reside in the house. Types and typing is a concept which realizes this concept. A typed language or a strongly typed language is one where the type of a variable has to be declared so as to avoid any wrong dealings of the value during run time. For example, Java is a strongly typed language. If I need to use two integers for addition, I would explicitly have to mention them as an integer:- &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  int integer1;&lt;br /&gt;
  int integer2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we can’t then re-initialize it to any other type in its defined scope.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  integer1 = “Hello World”;  // cannot map an int to a String&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the case of non-typed languages, say Ruby, or Visual Basic, etc. We don’t need to specify a type. &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  def variable1;&lt;br /&gt;
  def variable2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, it could be initialized with anything,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
as well as &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = “Good morning Vietnam”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Classes===&lt;br /&gt;
&lt;br /&gt;
A class is a “type” of variable specification. The difference between a class and a regular primitive integer, character, etc is that a class:-&lt;br /&gt;
&lt;br /&gt;
# consists of one or more primitive or non-primitive variables&lt;br /&gt;
# is a pre-defined structure&lt;br /&gt;
# defines methods which operate on the internal state of the object&lt;br /&gt;
&lt;br /&gt;
The Type of Class is “Class”, just like the Type of integer is “integer” in case of strongly typed languages. &lt;br /&gt;
&lt;br /&gt;
For example, in case of Java:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;“The types of the Java programming language are divided into two categories: primitive types and reference types. The primitive types are the boolean type and the numeric types. The numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double. The reference types are class types, interface types, and array types. There is also a special null type. An object is a dynamically created instance of a class type or a dynamically created array. The values of a reference type are references to objects. All objects, including arrays, support the methods of class Object . String literals are represented by String objects .” [2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, as mentioned before, in Java, there are two “Types”:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type:lower-roman&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Primitive Type&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Reference Type&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Classes, Interfaces, Arrays are all consolidations of Primitive types, so they just need to “point” to or reference the primitive ones, hence the name.&lt;br /&gt;
It is sometimes confusing and difficult to come up with a clear and robust distinction between Types and Classes. One might think &amp;quot;Class to be a Type of Type&amp;quot;. &lt;br /&gt;
It is however important to know that in strict Object Oriented Languages, Type is a union of Classes and Primitives. This rule, more or less consistent (with some deviations where primitives are treated as classes). &lt;br /&gt;
 &lt;br /&gt;
==Types and Classes in Languages==&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
Ruby claims to be a strong object oriented language. It is object oriented to the extent that every thing is an object. Primitive datatypes are objects, and we can make use of the object oriented techniques on even the primitives. As mentioned before, Ruby is a dynamic typed language, as the type is bound at compile time. Everything in Ruby has a class. Every class in Ruby is inherited from class Class. &lt;br /&gt;
&lt;br /&gt;
Type in Ruby is well defined as well. Using self inspection (reflection), we can find out whether a name is a Class, or a method. Let us see this in action:- &lt;br /&gt;
&lt;br /&gt;
The first thing that comes to a one’s mind is something like :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
&amp;quot;hello&amp;quot;.class #=&amp;gt; String&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
But have you thought of your class as an object? Well that seems odd, but that’s how ruby works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
class Foo;end  #=&amp;gt; nil&lt;br /&gt;
Foo.class #=&amp;gt; Class&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What does the above snippet of code mean exactly?&lt;br /&gt;
It means 2 things : Foo is a constant and that constant holds(refers to) an object of Class type.&lt;br /&gt;
&lt;br /&gt;
Let us prove that:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Foo = Class.new&lt;br /&gt;
(irb):8 warning: already initialized constant Foo&lt;br /&gt;
=&amp;gt; Foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
As you can see, we got a warning because we tried to initialize the constant Foo again.&lt;br /&gt;
&lt;br /&gt;
So ,when you define some class ‘Foo’ in ruby, all you are doing is:&lt;br /&gt;
1-instantiating an object of type Class.&lt;br /&gt;
2-initializing a constant Foo that refers to that created object .&lt;br /&gt;
&lt;br /&gt;
So, when we say “object” ,then we do mean any object; an object of Class type, or any object of any type.[3]&lt;br /&gt;
&lt;br /&gt;
===Java===&lt;br /&gt;
&lt;br /&gt;
As mentioned before, Java is a strongly typed language. The type of data needs to be declared before using. The types of &amp;quot;types&amp;quot; in Java are :&lt;br /&gt;
   * Primitive Types:-  boolean and numeric. The numeric types are the integral types byte, short, int, long, and char, and the         &lt;br /&gt;
     floating-point types float and double. &lt;br /&gt;
   * Reference Types:- class types, interface types and array types. [2] &lt;br /&gt;
&lt;br /&gt;
Java is an object-oriented language, but it does make a clear distinction between the primitive type and Classes. int, float, char etc. are primitives, and the other data types other than the primitives are references. It is an interesting distinction to note, because of the differences in method calling system in different languages. Java makes a distinction in &amp;quot;calling-by-value&amp;quot; when a primitive is passed as a parameter, and &amp;quot;calling-by-reference&amp;quot; when an object is passed. In fact, if a primitive is passed, a call by value is invoked, but when a Class object is passed, only a reference is passed to the object. &lt;br /&gt;
&lt;br /&gt;
For a more language specific treatment of types and classes, you can refer: http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_6_ap &lt;br /&gt;
&lt;br /&gt;
==Discussion of Issues==&lt;br /&gt;
Okay, so you're about to write a program and you need to represent data somehow.  Should you use a primitive type?  What about a class?  There are several features that are handed to you with each.&lt;br /&gt;
&lt;br /&gt;
=== Primitive Types ===&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Simplicity =====&lt;br /&gt;
In strongly typed languages, primitive types are ideal for data which doesn't necessarily need to be partitioned into several smaller components.  If you are looking to store and represent a simple throw-away integer for looping, for example, there's little reason why one would want to construct a class for this throw-away integer purpose.&lt;br /&gt;
&lt;br /&gt;
Primitive types are also often times coupled with native operations, handed to you by the language.  For example, in Java, variables of type int are automatically given operations such as addition, subtraction, multiplication, and so on.  These operations work as follows:&lt;br /&gt;
# Receive both inputs&lt;br /&gt;
# Cast if necessary (for example, from an int to a double)&lt;br /&gt;
# Perform calculation&lt;br /&gt;
# Return result&lt;br /&gt;
&lt;br /&gt;
It is important to note that the primitive types themselves are left ''unchanged'', and the result is returned from the operation, giving the programmer the ability to place the result elsewhere.&lt;br /&gt;
&lt;br /&gt;
===== Efficiency =====&lt;br /&gt;
In efficiency-critical applications, primitive types and their operations are oftentimes mapped directly to hardware-supported equivalents, thus operations can be performed very quickly.  This style of downgrading the logic to more so the hardware level has been replaced over the years for general applications, since improvements to hardware components have eradicated the once-imperative necessity to program efficiently.  Another point of view concerning efficiency could be from development time: if the program one is writing doesn't require complex design, it would be quicker to use the language's built-in types instead of taking the time to design a class to do the same feature.&lt;br /&gt;
&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Single-state storage =====&lt;br /&gt;
One large disadvantages to primitive types are that they are generally capable of only holding a single dimension state.  This limitation requires the programmer to use other variables in conjunction if they desire to hold more than one field of data.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Since primitive types do not allow you to encapsulate your data, if you ever desire to change the behavior of your program, you are forced to manually check each use of the variable for enforcement.&lt;br /&gt;
&lt;br /&gt;
For example, suppose you have a system designed in Java that maintains an integer value which represents the number of books you have in a library.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
int numBooks;&lt;br /&gt;
...&lt;br /&gt;
numBooks = 0;&lt;br /&gt;
...&lt;br /&gt;
numBooks++;&lt;br /&gt;
...&lt;br /&gt;
numBooks--;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A few days later, you realize that you should probably refactor your system to maintain a log of when this variable updates.  You immediately face a problem since, as it is, your code directly manipulates a single-state type integer.  Without resorting to a more object-oriented solution, you would have to update each location in the code of where a change takes place in order to establish this bookkeeping (pun intended).&lt;br /&gt;
&amp;lt;code id=&amp;quot;bookKeeping&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public static void integerValueChanged(){&lt;br /&gt;
  // records that the value has been changed&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public static void main(String[]args){&lt;br /&gt;
  int numBooks;&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks = 0;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks++;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks--;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To generalize this concept, it is oftentimes necessary to modify &amp;quot;what happens&amp;quot; when something is updated, and this cannot be easily accomplished by merely using primitive types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Class Types ===&lt;br /&gt;
Classes to the rescue!  Classes give programmers the ability to construct complex data types that are also capable of defining their own operations, all while keeping the details and specifics black-boxed outsize of where the class will be used in the code.&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Multi-dimensional Storage =====&lt;br /&gt;
Contrasting to primitive types, classes allow programmers to couple a varying number of fields.  Grouping fields of data into a single class, then instantiating such an object and manipulating it is much more convenient than keeping track of several individual variables.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Oftentimes it is necessary to refactor a system to execute code when a change happens.  In object-land, we are able to do this through the ability to control what happens in our methods.&lt;br /&gt;
&lt;br /&gt;
Taking our [[#bookKeeping| example from above]], we can give a quick example of how a class could be defined to handle the situation much more elegantly.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public class RecordedNumber{&lt;br /&gt;
  // The integer value, kept concealed in the class&lt;br /&gt;
  private int value;&lt;br /&gt;
&lt;br /&gt;
  public RecordedNumber(int value){&lt;br /&gt;
    this.value = value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public int getValue(){&lt;br /&gt;
    return value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public void setValue(int newValue){&lt;br /&gt;
    // code to do any necessary recording.&lt;br /&gt;
    ...&lt;br /&gt;
    this.value = newValue;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class MyExample{&lt;br /&gt;
  public static void main(String[]args){&lt;br /&gt;
    RecordedNumber numBooks = new RecordedNumber(0);&lt;br /&gt;
    ...&lt;br /&gt;
    numBooks.setValue(4); // the object handles all necessary bookkeeping&lt;br /&gt;
    ...&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Code-reuse =====&lt;br /&gt;
Another nice feature to class-types encapsulate the concept surrounding code re-usability, especially in topics such as inheritance.  Classes allow the programmer to enhance an already existing class-type to be more specific, which in turn can prevent excessive code duplication.&lt;br /&gt;
&lt;br /&gt;
===== Application Structure =====&lt;br /&gt;
Designing an application in a object-oriented / class-specific style can reduce the challenges of designing and building a difficult system into merely making objects successfully interact.  It is from this concept that languages such as [http://en.wikipedia.org/wiki/Unified_Modeling_Language Unified Modeling Language (UML)] have been created, allowing software engineers to build around the notion of classes and their relationships to one another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Speed Considerations =====&lt;br /&gt;
In computational-intensive applications, objects built from classes tend to be less efficient than primitive data types built around procedural context.  This is due in part because of the object's creation, since it isn't supported directly hardware level.  Consideration is placed more so on good-design and coding-practices when implementing functionality around classes.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== B =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== C =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[1] http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html&lt;br /&gt;
&lt;br /&gt;
[2] Java:- Types, Values and Variables&lt;br /&gt;
    http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html&lt;br /&gt;
[3] Ruby Reflection ,http://www.khelll.com/blog/ruby/ruby-reflection/&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39332</id>
		<title>CSC/ECE 517 Fall 2010/ch3 4b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39332"/>
		<updated>2010-10-21T05:05:37Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Types vs Classes'''&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: #F2F2F2; border: solid thin black; padding: 5px;&amp;quot;&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.  This topic was covered three years ago (http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007), but all of the articles considered one language after the other, in a set of examples rather than a discussion of issues.  Make sure that you discuss the issues, using languages as examples rather than making language the primary means of organizing the chapter.&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Overall s.png|right|frame|Relationship between Type and Class]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
It is often that we talk about types, strongly typed, weakly typed, classes. To make it clear,  let us look into it clearly. Every programming language has a way to define a variable. A variable is a named address location which stores a particular value. &lt;br /&gt;
&lt;br /&gt;
[[Image:Connection s.png|right|thumb|Classes are a 'type' that can combine other types.]]&lt;br /&gt;
&lt;br /&gt;
===Types===&lt;br /&gt;
&lt;br /&gt;
Time for an analogy? Imagine a variable to be a vacant house. It could have animals, humans, robots, or another smaller house, or whatever you can think of. There has to be a way, from a third party perspective, so as to be cognizant of the kind of things that reside in the house. Types and typing is a concept which realizes this concept. A typed language or a strongly typed language is one where the type of a variable has to be declared so as to avoid any wrong dealings of the value during run time. For example, Java is a strongly typed language. If I need to use two integers for addition, I would explicitly have to mention them as an integer:- &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  int integer1;&lt;br /&gt;
  int integer2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we can’t then re-initialize it to any other type in its defined scope.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  integer1 = “Hello World”;  // cannot map an int to a String&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the case of non-typed languages, say Ruby, or Visual Basic, etc. We don’t need to specify a type. &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  def variable1;&lt;br /&gt;
  def variable2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, it could be initialized with anything,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
as well as &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = “Good morning Vietnam”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
are allowed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Classes===&lt;br /&gt;
&lt;br /&gt;
A class is a “type” of variable specification. The difference between a class and a regular primitive integer, character, etc is that a class:-&lt;br /&gt;
&lt;br /&gt;
# consists of one or more primitive or non-primitive variables&lt;br /&gt;
# is a pre-defined structure&lt;br /&gt;
# defines methods which operate on the internal state of the object&lt;br /&gt;
&lt;br /&gt;
The Type of Class is “Class”, just like the Type of integer is “integer” in case of strongly typed languages. &lt;br /&gt;
&lt;br /&gt;
For example, in case of Java:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;“The types of the Java programming language are divided into two categories: primitive types and reference types. The primitive types are the boolean type and the numeric types. The numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double. The reference types are class types, interface types, and array types. There is also a special null type. An object is a dynamically created instance of a class type or a dynamically created array. The values of a reference type are references to objects. All objects, including arrays, support the methods of class Object . String literals are represented by String objects .” [2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, as mentioned before, in Java, there are two “Types”:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type:lower-roman&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Primitive Type&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Reference Type&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Classes, Interfaces, Arrays are all consolidations of Primitive types, so they just need to “point” to or reference the primitive ones, hence the name.&lt;br /&gt;
It is sometimes confusing and difficult to come up with a clear and robust distinction between Types and Classes. One might think &amp;quot;Class to be a Type of Type&amp;quot;. &lt;br /&gt;
It is however important to know that in strict Object Oriented Languages, Type is a union of Classes and Primitives. This rule, more or less consistent (with some deviations where primitives are treated as classes). &lt;br /&gt;
 &lt;br /&gt;
==Types and Classes in Languages==&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
Ruby claims to be a strong object oriented language. It is object oriented to the extent that every thing is an object. Primitive datatypes are objects, and we can make use of the object oriented techniques on even the primitives. As mentioned before, Ruby is a dynamic typed language, as the type is bound at compile time. Everything in Ruby has a class. Every class in Ruby is inherited from class Class. &lt;br /&gt;
&lt;br /&gt;
Type in Ruby is well defined as well. Using self inspection (reflection), we can find out whether a name is a Class, or a method. Let us see this in action:- &lt;br /&gt;
&lt;br /&gt;
The first thing that comes to a one’s mind is something like :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
&amp;quot;hello&amp;quot;.class #=&amp;gt; String&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
But have you thought of your class as an object? Well that seems odd, but that’s how ruby works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
class Foo;end  #=&amp;gt; nil&lt;br /&gt;
Foo.class #=&amp;gt; Class&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What does the above snippet of code mean exactly?&lt;br /&gt;
It means 2 things : Foo is a constant and that constant holds(refers to) an object of Class type.&lt;br /&gt;
&lt;br /&gt;
Let us prove that:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Foo = Class.new&lt;br /&gt;
(irb):8 warning: already initialized constant Foo&lt;br /&gt;
=&amp;gt; Foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
As you can see, we got a warning because we tried to initialize the constant Foo again.&lt;br /&gt;
&lt;br /&gt;
So ,when you define some class ‘Foo’ in ruby, all you are doing is:&lt;br /&gt;
1-instantiating an object of type Class.&lt;br /&gt;
2-initializing a constant Foo that refers to that created object .&lt;br /&gt;
&lt;br /&gt;
So, when we say “object” ,then we do mean any object; an object of Class type, or any object of any type.[3]&lt;br /&gt;
&lt;br /&gt;
===Java===&lt;br /&gt;
&lt;br /&gt;
As mentioned before, Java is a strongly typed language. The type of data needs to be declared before using. The types of &amp;quot;types&amp;quot; in Java are :&lt;br /&gt;
   * Primitive Types:-  boolean and numeric. The numeric types are the integral types byte, short, int, long, and char, and the         &lt;br /&gt;
     floating-point types float and double. &lt;br /&gt;
   * Reference Types:- class types, interface types and array types. [2] &lt;br /&gt;
&lt;br /&gt;
Java is an object-oriented language, but it does make a clear distinction between the primitive type and Classes. int, float, char etc. are primitives, and the other data types other than the primitives are references. It is an interesting distinction to note, because of the differences in method calling system in different languages. Java makes a distinction in &amp;quot;calling-by-value&amp;quot; when a primitive is passed as a parameter, and &amp;quot;calling-by-reference&amp;quot; when an object is passed. In fact, if a primitive is passed, a call by value is invoked, but when a Class object is passed, only a reference is passed to the object. &lt;br /&gt;
&lt;br /&gt;
For a more language specific treatment of types and classes, you can refer: http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_6_ap &lt;br /&gt;
&lt;br /&gt;
==Discussion of Issues==&lt;br /&gt;
Okay, so you're about to write a program and you need to represent data somehow.  Should you use a primitive type?  What about a class?  There are several features that are handed to you with each.&lt;br /&gt;
&lt;br /&gt;
=== Primitive Types ===&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Simplicity =====&lt;br /&gt;
In strongly typed languages, primitive types are ideal for data which doesn't necessarily need to be partitioned into several smaller components.  If you are looking to store and represent a simple throw-away integer for looping, for example, there's little reason why one would want to construct a class for this throw-away integer purpose.&lt;br /&gt;
&lt;br /&gt;
Primitive types are also often times coupled with native operations, handed to you by the language.  For example, in Java, variables of type int are automatically given operations such as addition, subtraction, multiplication, and so on.  These operations work as follows:&lt;br /&gt;
# Receive both inputs&lt;br /&gt;
# Cast if necessary (for example, from an int to a double)&lt;br /&gt;
# Perform calculation&lt;br /&gt;
# Return result&lt;br /&gt;
&lt;br /&gt;
It is important to note that the primitive types themselves are left ''unchanged'', and the result is returned from the operation, giving the programmer the ability to place the result elsewhere.&lt;br /&gt;
&lt;br /&gt;
===== Efficiency =====&lt;br /&gt;
In efficiency-critical applications, primitive types and their operations are oftentimes mapped directly to hardware-supported equivalents, thus operations can be performed very quickly.  This style of downgrading the logic to more so the hardware level has been replaced over the years for general applications, since improvements to hardware components have eradicated the once-imperative necessity to program efficiently.  Another point of view concerning efficiency could be from development time: if the program one is writing doesn't require complex design, it would be quicker to use the language's built-in types instead of taking the time to design a class to do the same feature.&lt;br /&gt;
&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Single-state storage =====&lt;br /&gt;
One large disadvantages to primitive types are that they are generally capable of only holding a single dimension state.  This limitation requires the programmer to use other variables in conjunction if they desire to hold more than one field of data.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Since primitive types do not allow you to encapsulate your data, if you ever desire to change the behavior of your program, you are forced to manually check each use of the variable for enforcement.&lt;br /&gt;
&lt;br /&gt;
For example, suppose you have a system designed in Java that maintains an integer value which represents the number of books you have in a library.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
int numBooks;&lt;br /&gt;
...&lt;br /&gt;
numBooks = 0;&lt;br /&gt;
...&lt;br /&gt;
numBooks++;&lt;br /&gt;
...&lt;br /&gt;
numBooks--;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A few days later, you realize that you should probably refactor your system to maintain a log of when this variable updates.  You immediately face a problem since, as it is, your code directly manipulates a single-state type integer.  Without resorting to a more object-oriented solution, you would have to update each location in the code of where a change takes place in order to establish this bookkeeping (pun intended).&lt;br /&gt;
&amp;lt;code id=&amp;quot;bookKeeping&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public static void integerValueChanged(){&lt;br /&gt;
  // records that the value has been changed&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public static void main(String[]args){&lt;br /&gt;
  int numBooks;&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks = 0;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks++;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks--;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To generalize this concept, it is oftentimes necessary to modify &amp;quot;what happens&amp;quot; when something is updated, and this cannot be easily accomplished by merely using primitive types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Class Types ===&lt;br /&gt;
Classes to the rescue!  Classes give programmers the ability to construct complex data types that are also capable of defining their own operations, all while keeping the details and specifics black-boxed outsize of where the class will be used in the code.&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Multi-dimensional Storage =====&lt;br /&gt;
Contrasting to primitive types, classes allow programmers to couple a varying number of fields.  Grouping fields of data into a single class, then instantiating such an object and manipulating it is much more convenient than keeping track of several individual variables.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Oftentimes it is necessary to refactor a system to execute code when a change happens.  In object-land, we are able to do this through the ability to control what happens in our methods.&lt;br /&gt;
&lt;br /&gt;
Taking our [[#bookKeeping| example from above]], we can give a quick example of how a class could be defined to handle the situation much more elegantly.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public class RecordedNumber{&lt;br /&gt;
  // The integer value, kept concealed in the class&lt;br /&gt;
  private int value;&lt;br /&gt;
&lt;br /&gt;
  public RecordedNumber(int value){&lt;br /&gt;
    this.value = value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public int getValue(){&lt;br /&gt;
    return value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public void setValue(int newValue){&lt;br /&gt;
    // code to do any necessary recording.&lt;br /&gt;
    ...&lt;br /&gt;
    this.value = newValue;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class MyExample{&lt;br /&gt;
  public static void main(String[]args){&lt;br /&gt;
    RecordedNumber numBooks = new RecordedNumber(0);&lt;br /&gt;
    ...&lt;br /&gt;
    numBooks.setValue(4); // the object handles all necessary bookkeeping&lt;br /&gt;
    ...&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Code-reuse =====&lt;br /&gt;
Another nice feature to class-types encapsulate the concept surrounding code re-usability, especially in topics such as inheritance.  Classes allow the programmer to enhance an already existing class-type to be more specific, which in turn can prevent excessive code duplication.&lt;br /&gt;
&lt;br /&gt;
===== Application Structure =====&lt;br /&gt;
Designing an application in a object-oriented / class-specific style can reduce the challenges of designing and building a difficult system into merely making objects successfully interact.  It is from this concept that languages such as [http://en.wikipedia.org/wiki/Unified_Modeling_Language Unified Modeling Language (UML)] have been created, allowing software engineers to build around the notion of classes and their relationships to one another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Speed Considerations =====&lt;br /&gt;
In computational-intensive applications, objects built from classes tend to be less efficient than primitive data types built around procedural context.  This is due in part because of the object's creation, since it isn't supported directly hardware level.  Consideration is placed more so on good-design and coding-practices when implementing functionality around classes.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== B =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== C =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[1] http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html&lt;br /&gt;
&lt;br /&gt;
[2] Java:- Types, Values and Variables&lt;br /&gt;
    http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html&lt;br /&gt;
[3] Ruby Reflection ,http://www.khelll.com/blog/ruby/ruby-reflection/&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39306</id>
		<title>CSC/ECE 517 Fall 2010/ch3 4b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39306"/>
		<updated>2010-10-21T04:21:31Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Types vs Classes'''&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: #F2F2F2; border: solid thin black; padding: 5px;&amp;quot;&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.  This topic was covered three years ago (http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007), but all of the articles considered one language after the other, in a set of examples rather than a discussion of issues.  Make sure that you discuss the issues, using languages as examples rather than making language the primary means of organizing the chapter.&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Overall s.png|right|frame|Relationship between Type and Class]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
It is often that we talk about types, strongly typed, weakly typed, classes. To make it clear,  let us look into it clearly. Every programming language has a way to define a variable. A variable is a named address location which stores a particular value. &lt;br /&gt;
&lt;br /&gt;
[[Image:Connection s.png|right|thumb|Classes are a 'type' that can combine other types.]]&lt;br /&gt;
&lt;br /&gt;
===Types===&lt;br /&gt;
&lt;br /&gt;
Time for an analogy? Imagine a variable to be a vacant house. It could have animals, humans, robots, or another smaller house, or whatever you can think of. There has to be a way, from a third party perspective, so as to be cognizant of the kind of things that reside in the house. Types and typing is a concept which realizes this concept. A typed language or a strongly typed language is one where the type of a variable has to be declared so as to avoid any wrong dealings of the value during run time. For example, Java is a strongly typed language. If I need to use two integers for addition, I would explicitly have to mention them as an integer:- &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  int integer1;&lt;br /&gt;
  int integer2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we can’t then re-initialize it to any other type in its defined scope.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  integer1 = “Hello World”;  // cannot map an int to a String&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the case of non-typed languages, say Ruby, or Visual Basic, etc. We don’t need to specify a type. &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  def variable1;&lt;br /&gt;
  def variable2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, it could be initialized with anything,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
as well as &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = “Good morning Vietnam”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
are allowed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Classes===&lt;br /&gt;
&lt;br /&gt;
A class is a “type” of variable specification. The difference between a class and a regular primitive integer, character, etc is that a class:-&lt;br /&gt;
&lt;br /&gt;
# consists of one or more primitive or non-primitive variables&lt;br /&gt;
# is a pre-defined structure&lt;br /&gt;
# defines methods which operate on the internal state of the object&lt;br /&gt;
&lt;br /&gt;
The Type of Class is “Class”, just like the Type of integer is “integer” in case of strongly typed languages. &lt;br /&gt;
&lt;br /&gt;
For example, in case of Java:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;“The types of the Java programming language are divided into two categories: primitive types and reference types. The primitive types are the boolean type and the numeric types. The numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double. The reference types are class types, interface types, and array types. There is also a special null type. An object is a dynamically created instance of a class type or a dynamically created array. The values of a reference type are references to objects. All objects, including arrays, support the methods of class Object . String literals are represented by String objects .” [2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, as mentioned before, in Java, there are two “Types”:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type:lower-roman&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Primitive Type&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Reference Type&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Classes, Interfaces, Arrays are all consolidations of Primitive types, so they just need to “point” to or reference the primitive ones, hence the name.&lt;br /&gt;
It is sometimes confusing and difficult to come up with a clear and robust distinction between Types and Classes. One might think &amp;quot;Class to be a Type of Type&amp;quot;. &lt;br /&gt;
It is however important to know that in strict Object Oriented Languages, Type is a union of Classes and Primitives. This rule, more or less consistent (with some deviations where primitives are treated as classes). &lt;br /&gt;
 &lt;br /&gt;
==Types and Classes in Languages==&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
Ruby claims to be a strong object oriented language. It is object oriented to the extent that every thing is an object. Primitive datatypes are objects, and we can make use of the object oriented techniques on even the primitives. As mentioned before, Ruby is a dynamic typed language, as the type is bound at compile time. Everything in Ruby has a class. Every class in Ruby is inherited from class Class. &lt;br /&gt;
&lt;br /&gt;
Type in Ruby is well defined as well. Using self inspection (reflection), we can find out whether a name is a Class, or a method. Let us see this in action:- &lt;br /&gt;
&lt;br /&gt;
The first thing that comes to a one’s mind is something like :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
&amp;quot;hello&amp;quot;.class #=&amp;gt; String&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
But have you thought of your class as an object? Well that seems odd, but that’s how ruby works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
class Foo;end  #=&amp;gt; nil&lt;br /&gt;
Foo.class #=&amp;gt; Class&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What does the above snippet of code mean exactly?&lt;br /&gt;
It means 2 things : Foo is a constant and that constant holds(refers to) an object of Class type.&lt;br /&gt;
&lt;br /&gt;
Let us prove that:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Foo = Class.new&lt;br /&gt;
(irb):8 warning: already initialized constant Foo&lt;br /&gt;
=&amp;gt; Foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
As you can see, we got a warning because we tried to initialize the constant Foo again.&lt;br /&gt;
&lt;br /&gt;
So ,when you define some class ‘Foo’ in ruby, all you are doing is:&lt;br /&gt;
1-instantiating an object of type Class.&lt;br /&gt;
2-initializing a constant Foo that refers to that created object .&lt;br /&gt;
&lt;br /&gt;
So, when we say “object” ,then we do mean any object; an object of Class type, or any object of any type.[3]&lt;br /&gt;
&lt;br /&gt;
===Java===&lt;br /&gt;
&lt;br /&gt;
As mentioned before, Java is a strongly typed language. The type of data needs to be declared before using. The types of &amp;quot;types&amp;quot; in Java are :&lt;br /&gt;
   * Primitive Types:-  boolean and numeric. The numeric types are the integral types byte, short, int, long, and char, and the         &lt;br /&gt;
     floating-point types float and double. &lt;br /&gt;
   * Reference Types:- class types, interface types and array types. [2] &lt;br /&gt;
&lt;br /&gt;
Java is an object-oriented language, but it does make a clear distinction between the primitive type and Classes. int, float, char etc. are primitives, and the other data types other than the primitives are references. It is an interesting distinction to note, because of the differences in method calling system in different languages. Java makes a distinction in &amp;quot;calling-by-value&amp;quot; when a primitive is passed as a parameter, and &amp;quot;calling-by-reference&amp;quot; when an object is passed. In fact, if a primitive is passed, a call by value is invoked, but when a Class object is passed, only a reference is passed to the object. &lt;br /&gt;
&lt;br /&gt;
For a more language specific treatment of types and classes, you can refer: http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_6_ap &lt;br /&gt;
&lt;br /&gt;
==Discussion of Issues==&lt;br /&gt;
Okay, so you're about to write a program and you need to represent data somehow.  Should you use a primitive type?  What about a class?  There are several features that are handed to you with each.&lt;br /&gt;
&lt;br /&gt;
=== Primitive Types ===&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Simplicity =====&lt;br /&gt;
In strongly typed languages, primitive types are ideal for data which doesn't necessarily need to be partitioned into several smaller components.  If you are looking to store and represent a simple throw-away integer for looping, for example, there's little reason why one would want to construct a class for this purpose.&lt;br /&gt;
&lt;br /&gt;
Primitive types are also often times coupled with native operations, handed to you by the language.  For example, in Java, variables of type int are automatically given operations such as addition, subtraction, multiplication, and so on.  These operations work as follows:&lt;br /&gt;
# Receive both inputs&lt;br /&gt;
# Cast if necessary (for example, from an int to a double)&lt;br /&gt;
# Perform calculation&lt;br /&gt;
# Return result&lt;br /&gt;
&lt;br /&gt;
It is important to note that the primitive types themselves are left ''unchanged'', and the result is returned from the operation, giving the programmer the ability to place the result elsewhere.&lt;br /&gt;
&lt;br /&gt;
===== Efficiency =====&lt;br /&gt;
In efficiency-critical applications, primitive types and their operations are oftentimes mapped directly to hardware-supported equivalents, thus operations can be performed very quickly.  This style of downgrading the logic to more so the hardware level has been replaced over the years for general applications, since improvements to hardware components have eradicated the once-imperative necessity to program efficiently.  Another point of view concerning efficiency could be from development time: if the program one is writing doesn't require complex design, it would be quicker to use the language's built-in types instead of taking the time to design a class to do the same feature.&lt;br /&gt;
&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Single-state storage =====&lt;br /&gt;
One large disadvantages to primitive types are that they are generally capable of only holding a single dimension state.  This limitation requires the programmer to use other variables in conjunction if they desire to hold more than one field of data.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Since primitive types do not allow you to encapsulate your data, if you ever desire to change the behavior of your program, you are forced to manually check each use of the variable for enforcement.&lt;br /&gt;
&lt;br /&gt;
For example, suppose you have a system designed in Java that maintains an integer value which represents the number of books you have in a library.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
int numBooks;&lt;br /&gt;
...&lt;br /&gt;
numBooks = 0;&lt;br /&gt;
...&lt;br /&gt;
numBooks++;&lt;br /&gt;
...&lt;br /&gt;
numBooks--;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A few days later, you realize that you should probably refactor your system to maintain a log of when this variable updates.  You immediately face a problem since, as it is, your code directly manipulates a single-state type integer.  Without resorting to a more object-oriented solution, you would have to update each location in the code of where a change takes place in order to establish this bookkeeping (pun intended).&lt;br /&gt;
&amp;lt;code id=&amp;quot;bookKeeping&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public static void integerValueChanged(){&lt;br /&gt;
  // records that the value has been changed&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public static void main(String[]args){&lt;br /&gt;
  int numBooks;&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks = 0;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks++;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks--;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To generalize this concept, it is oftentimes necessary to modify &amp;quot;what happens&amp;quot; when something is updated, and this cannot be easily accomplished by merely using primitive types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Class Types ===&lt;br /&gt;
Classes to the rescue!  Classes give programmers the ability to construct complex data types that are also capable of defining their own operations, all while keeping the details and specifics black-boxed outsize of where the class will be used in the code.&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Multi-dimensional Storage =====&lt;br /&gt;
Contrasting to primitive types, classes allow programmers to couple a varying number of fields.  Grouping fields of data into a single class, then instantiating such an object and manipulating it is much more convenient than keeping track of several individual variables.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Oftentimes it is necessary to refactor a system to execute code when a change happens.  In object-land, we are able to do this through the ability to control what happens in our methods.&lt;br /&gt;
&lt;br /&gt;
Taking our [[#bookKeeping| example from above]], we can give a quick example of how a class could be defined to handle the situation much more elegantly.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public class RecordedNumber{&lt;br /&gt;
  // The integer value, kept concealed in the class&lt;br /&gt;
  private int value;&lt;br /&gt;
&lt;br /&gt;
  public RecordedNumber(int value){&lt;br /&gt;
    this.value = value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public int getValue(){&lt;br /&gt;
    return value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public void setValue(int newValue){&lt;br /&gt;
    // code to do any necessary recording.&lt;br /&gt;
    ...&lt;br /&gt;
    this.value = newValue;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class MyExample{&lt;br /&gt;
  public static void main(String[]args){&lt;br /&gt;
    RecordedNumber numBooks = new RecordedNumber(0);&lt;br /&gt;
    ...&lt;br /&gt;
    numBooks.setValue(4); // the object handles all necessary bookkeeping&lt;br /&gt;
    ...&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Code-reuse =====&lt;br /&gt;
Another nice feature to class-types encapsulate the concept surrounding code re-usability, especially in topics such as inheritance.  Classes allow the programmer to enhance an already existing class-type to be more specific, which in turn can prevent excessive code duplication.&lt;br /&gt;
&lt;br /&gt;
===== Application Structure =====&lt;br /&gt;
Designing an application in a object-oriented / class-specific style can reduce the challenges of designing and building a difficult system into merely making objects successfully interact.  It is from this concept that languages such as [http://en.wikipedia.org/wiki/Unified_Modeling_Language Unified Modeling Language (UML)] have been created, allowing software engineers to build around the notion of classes and their relationships to one another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Speed Considerations =====&lt;br /&gt;
In computational-intensive applications, objects built from classes tend to be less efficient than primitive data types built around procedural context.  This is due in part because of the object's creation, since it isn't supported directly hardware level.  Consideration is placed more so on good-design and coding-practices when implementing functionality around classes.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== B =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== C =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[1] http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html&lt;br /&gt;
&lt;br /&gt;
[2] Java:- Types, Values and Variables&lt;br /&gt;
    http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html&lt;br /&gt;
[3] Ruby Reflection ,http://www.khelll.com/blog/ruby/ruby-reflection/&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39305</id>
		<title>CSC/ECE 517 Fall 2010/ch3 4b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39305"/>
		<updated>2010-10-21T04:19:45Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Types vs Classes'''&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: #F2F2F2; border: solid thin black; padding: 5px;&amp;quot;&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.  This topic was covered three years ago (http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007), but all of the articles considered one language after the other, in a set of examples rather than a discussion of issues.  Make sure that you discuss the issues, using languages as examples rather than making language the primary means of organizing the chapter.&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Overall s.png|right|Relationship between Type and Class]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
It is often that we talk about types, strongly typed, weakly typed, classes. To make it clear,  let us look into it clearly. Every programming language has a way to define a variable. A variable is a named address location which stores a particular value. &lt;br /&gt;
&lt;br /&gt;
[[Image:Connection s.png|right|thumb|Classes are a 'type' that can combine other types.]]&lt;br /&gt;
&lt;br /&gt;
===Types===&lt;br /&gt;
&lt;br /&gt;
Time for an analogy? Imagine a variable to be a vacant house. It could have animals, humans, robots, or another smaller house, or whatever you can think of. There has to be a way, from a third party perspective, so as to be cognizant of the kind of things that reside in the house. Types and typing is a concept which realizes this concept. A typed language or a strongly typed language is one where the type of a variable has to be declared so as to avoid any wrong dealings of the value during run time. For example, Java is a strongly typed language. If I need to use two integers for addition, I would explicitly have to mention them as an integer:- &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  int integer1;&lt;br /&gt;
  int integer2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we can’t then re-initialize it to any other type in its defined scope.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  integer1 = “Hello World”;  // cannot map an int to a String&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the case of non-typed languages, say Ruby, or Visual Basic, etc. We don’t need to specify a type. &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  def variable1;&lt;br /&gt;
  def variable2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, it could be initialized with anything,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
as well as &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = “Good morning Vietnam”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
are allowed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Classes===&lt;br /&gt;
&lt;br /&gt;
A class is a “type” of variable specification. The difference between a class and a regular primitive integer, character, etc is that a class:-&lt;br /&gt;
&lt;br /&gt;
# consists of one or more primitive or non-primitive variables&lt;br /&gt;
# is a pre-defined structure&lt;br /&gt;
# defines methods which operate on the internal state of the object&lt;br /&gt;
&lt;br /&gt;
The Type of Class is “Class”, just like the Type of integer is “integer” in case of strongly typed languages. &lt;br /&gt;
&lt;br /&gt;
For example, in case of Java:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;“The types of the Java programming language are divided into two categories: primitive types and reference types. The primitive types are the boolean type and the numeric types. The numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double. The reference types are class types, interface types, and array types. There is also a special null type. An object is a dynamically created instance of a class type or a dynamically created array. The values of a reference type are references to objects. All objects, including arrays, support the methods of class Object . String literals are represented by String objects .” [2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, as mentioned before, in Java, there are two “Types”:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type:lower-roman&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Primitive Type&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Reference Type&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Classes, Interfaces, Arrays are all consolidations of Primitive types, so they just need to “point” to or reference the primitive ones, hence the name.&lt;br /&gt;
It is sometimes confusing and difficult to come up with a clear and robust distinction between Types and Classes. One might think &amp;quot;Class to be a Type of Type&amp;quot;. &lt;br /&gt;
It is however important to know that in strict Object Oriented Languages, Type is a union of Classes and Primitives. This rule, more or less consistent (with some deviations where primitives are treated as classes). &lt;br /&gt;
 &lt;br /&gt;
==Types and Classes in Languages==&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
Ruby claims to be a strong object oriented language. It is object oriented to the extent that every thing is an object. Primitive datatypes are objects, and we can make use of the object oriented techniques on even the primitives. As mentioned before, Ruby is a dynamic typed language, as the type is bound at compile time. Everything in Ruby has a class. Every class in Ruby is inherited from class Class. &lt;br /&gt;
&lt;br /&gt;
Type in Ruby is well defined as well. Using self inspection (reflection), we can find out whether a name is a Class, or a method. Let us see this in action:- &lt;br /&gt;
&lt;br /&gt;
The first thing that comes to a one’s mind is something like :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
&amp;quot;hello&amp;quot;.class #=&amp;gt; String&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
But have you thought of your class as an object? Well that seems odd, but that’s how ruby works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
class Foo;end  #=&amp;gt; nil&lt;br /&gt;
Foo.class #=&amp;gt; Class&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What does the above snippet of code mean exactly?&lt;br /&gt;
It means 2 things : Foo is a constant and that constant holds(refers to) an object of Class type.&lt;br /&gt;
&lt;br /&gt;
Let us prove that:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Foo = Class.new&lt;br /&gt;
(irb):8 warning: already initialized constant Foo&lt;br /&gt;
=&amp;gt; Foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
As you can see, we got a warning because we tried to initialize the constant Foo again.&lt;br /&gt;
&lt;br /&gt;
So ,when you define some class ‘Foo’ in ruby, all you are doing is:&lt;br /&gt;
1-instantiating an object of type Class.&lt;br /&gt;
2-initializing a constant Foo that refers to that created object .&lt;br /&gt;
&lt;br /&gt;
So, when we say “object” ,then we do mean any object; an object of Class type, or any object of any type.[3]&lt;br /&gt;
&lt;br /&gt;
===Java===&lt;br /&gt;
&lt;br /&gt;
As mentioned before, Java is a strongly typed language. The type of data needs to be declared before using. The types of &amp;quot;types&amp;quot; in Java are :&lt;br /&gt;
   * Primitive Types:-  boolean and numeric. The numeric types are the integral types byte, short, int, long, and char, and the         &lt;br /&gt;
     floating-point types float and double. &lt;br /&gt;
   * Reference Types:- class types, interface types and array types. [2] &lt;br /&gt;
&lt;br /&gt;
Java is an object-oriented language, but it does make a clear distinction between the primitive type and Classes. int, float, char etc. are primitives, and the other data types other than the primitives are references. It is an interesting distinction to note, because of the differences in method calling system in different languages. Java makes a distinction in &amp;quot;calling-by-value&amp;quot; when a primitive is passed as a parameter, and &amp;quot;calling-by-reference&amp;quot; when an object is passed. In fact, if a primitive is passed, a call by value is invoked, but when a Class object is passed, only a reference is passed to the object. &lt;br /&gt;
&lt;br /&gt;
For a more language specific treatment of types and classes, you can refer: http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_6_ap &lt;br /&gt;
&lt;br /&gt;
==Discussion of Issues==&lt;br /&gt;
Okay, so you're about to write a program and you need to represent data somehow.  Should you use a primitive type?  What about a class?  There are several features that are handed to you with each.&lt;br /&gt;
&lt;br /&gt;
=== Primitive Types ===&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Simplicity =====&lt;br /&gt;
In strongly typed languages, primitive types are ideal for data which doesn't necessarily need to be partitioned into several smaller components.  If you are looking to store and represent a simple throw-away integer for looping, for example, there's little reason why one would want to construct a class for this purpose.&lt;br /&gt;
&lt;br /&gt;
Primitive types are also often times coupled with native operations, handed to you by the language.  For example, in Java, variables of type int are automatically given operations such as addition, subtraction, multiplication, and so on.  These operations work as follows:&lt;br /&gt;
# Receive both inputs&lt;br /&gt;
# Cast if necessary (for example, from an int to a double)&lt;br /&gt;
# Perform calculation&lt;br /&gt;
# Return result&lt;br /&gt;
&lt;br /&gt;
It is important to note that the primitive types themselves are left ''unchanged'', and the result is returned from the operation, giving the programmer the ability to place the result elsewhere.&lt;br /&gt;
&lt;br /&gt;
===== Efficiency =====&lt;br /&gt;
In efficiency-critical applications, primitive types and their operations are oftentimes mapped directly to hardware-supported equivalents, thus operations can be performed very quickly.  This style of downgrading the logic to more so the hardware level has been replaced over the years for general applications, since improvements to hardware components have eradicated the once-imperative necessity to program efficiently.  Another point of view concerning efficiency could be from development time: if the program one is writing doesn't require complex design, it would be quicker to use the language's built-in types instead of taking the time to design a class to do the same feature.&lt;br /&gt;
&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Single-state storage =====&lt;br /&gt;
One large disadvantages to primitive types are that they are generally capable of only holding a single dimension state.  This limitation requires the programmer to use other variables in conjunction if they desire to hold more than one field of data.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Since primitive types do not allow you to encapsulate your data, if you ever desire to change the behavior of your program, you are forced to manually check each use of the variable for enforcement.&lt;br /&gt;
&lt;br /&gt;
For example, suppose you have a system designed in Java that maintains an integer value which represents the number of books you have in a library.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
int numBooks;&lt;br /&gt;
...&lt;br /&gt;
numBooks = 0;&lt;br /&gt;
...&lt;br /&gt;
numBooks++;&lt;br /&gt;
...&lt;br /&gt;
numBooks--;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A few days later, you realize that you should probably refactor your system to maintain a log of when this variable updates.  You immediately face a problem since, as it is, your code directly manipulates a single-state type integer.  Without resorting to a more object-oriented solution, you would have to update each location in the code of where a change takes place in order to establish this bookkeeping (pun intended).&lt;br /&gt;
&amp;lt;code id=&amp;quot;bookKeeping&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public static void integerValueChanged(){&lt;br /&gt;
  // records that the value has been changed&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public static void main(String[]args){&lt;br /&gt;
  int numBooks;&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks = 0;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks++;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks--;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To generalize this concept, it is oftentimes necessary to modify &amp;quot;what happens&amp;quot; when something is updated, and this cannot be easily accomplished by merely using primitive types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Class Types ===&lt;br /&gt;
Classes to the rescue!  Classes give programmers the ability to construct complex data types that are also capable of defining their own operations, all while keeping the details and specifics black-boxed outsize of where the class will be used in the code.&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Multi-dimensional Storage =====&lt;br /&gt;
Contrasting to primitive types, classes allow programmers to couple a varying number of fields.  Grouping fields of data into a single class, then instantiating such an object and manipulating it is much more convenient than keeping track of several individual variables.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Oftentimes it is necessary to refactor a system to execute code when a change happens.  In object-land, we are able to do this through the ability to control what happens in our methods.&lt;br /&gt;
&lt;br /&gt;
Taking our [[#bookKeeping| example from above]], we can give a quick example of how a class could be defined to handle the situation much more elegantly.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public class RecordedNumber{&lt;br /&gt;
  // The integer value, kept concealed in the class&lt;br /&gt;
  private int value;&lt;br /&gt;
&lt;br /&gt;
  public RecordedNumber(int value){&lt;br /&gt;
    this.value = value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public int getValue(){&lt;br /&gt;
    return value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public void setValue(int newValue){&lt;br /&gt;
    // code to do any necessary recording.&lt;br /&gt;
    ...&lt;br /&gt;
    this.value = newValue;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class MyExample{&lt;br /&gt;
  public static void main(String[]args){&lt;br /&gt;
    RecordedNumber numBooks = new RecordedNumber(0);&lt;br /&gt;
    ...&lt;br /&gt;
    numBooks.setValue(4); // the object handles all necessary bookkeeping&lt;br /&gt;
    ...&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Code-reuse =====&lt;br /&gt;
Another nice feature to class-types encapsulate the concept surrounding code re-usability, especially in topics such as inheritance.  Classes allow the programmer to enhance an already existing class-type to be more specific, which in turn can prevent excessive code duplication.&lt;br /&gt;
&lt;br /&gt;
===== Application Structure =====&lt;br /&gt;
Designing an application in a object-oriented / class-specific style can reduce the challenges of designing and building a difficult system into merely making objects successfully interact.  It is from this concept that languages such as [http://en.wikipedia.org/wiki/Unified_Modeling_Language Unified Modeling Language (UML)] have been created, allowing software engineers to build around the notion of classes and their relationships to one another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Speed Considerations =====&lt;br /&gt;
In computational-intensive applications, objects built from classes tend to be less efficient than primitive data types built around procedural context.  This is due in part because of the object's creation, since it isn't supported directly hardware level.  Consideration is placed more so on good-design and coding-practices when implementing functionality around classes.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== B =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== C =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[1] http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html&lt;br /&gt;
&lt;br /&gt;
[2] Java:- Types, Values and Variables&lt;br /&gt;
    http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html&lt;br /&gt;
[3] Ruby Reflection ,http://www.khelll.com/blog/ruby/ruby-reflection/&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39303</id>
		<title>CSC/ECE 517 Fall 2010/ch3 4b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39303"/>
		<updated>2010-10-21T04:16:07Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Types vs Classes'''&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: #F2F2F2; border: solid thin black; padding: 5px;&amp;quot;&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.  This topic was covered three years ago (http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007), but all of the articles considered one language after the other, in a set of examples rather than a discussion of issues.  Make sure that you discuss the issues, using languages as examples rather than making language the primary means of organizing the chapter.&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Overall s.png|right|upright|Relationship between Type and Class]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
It is often that we talk about types, strongly typed, weakly typed, classes. To make it clear,  let us look into it clearly. Every programming language has a way to define a variable. A variable is a named address location which stores a particular value. &lt;br /&gt;
&lt;br /&gt;
[[Image:Connection s.png|right|thumb|Classes are a 'type' that can combine other types.]]&lt;br /&gt;
&lt;br /&gt;
===Types===&lt;br /&gt;
&lt;br /&gt;
Time for an analogy? Imagine a variable to be a vacant house. It could have animals, humans, robots, or another smaller house, or whatever you can think of. There has to be a way, from a third party perspective, so as to be cognizant of the kind of things that reside in the house. Types and typing is a concept which realizes this concept. A typed language or a strongly typed language is one where the type of a variable has to be declared so as to avoid any wrong dealings of the value during run time. For example, Java is a strongly typed language. If I need to use two integers for addition, I would explicitly have to mention them as an integer:- &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  int integer1;&lt;br /&gt;
  int integer2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we can’t then re-initialize it to any other type in its defined scope.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  integer1 = “Hello World”;  // cannot map an int to a String&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the case of non-typed languages, say Ruby, or Visual Basic, etc. We don’t need to specify a type. &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  def variable1;&lt;br /&gt;
  def variable2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, it could be initialized with anything,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
as well as &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = “Good morning Vietnam”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
are allowed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Classes===&lt;br /&gt;
&lt;br /&gt;
A class is a “type” of variable specification. The difference between a class and a regular primitive integer, character, etc is that a class:-&lt;br /&gt;
&lt;br /&gt;
# consists of one or more primitive or non-primitive variables&lt;br /&gt;
# is a pre-defined structure&lt;br /&gt;
# defines methods which operate on the internal state of the object&lt;br /&gt;
&lt;br /&gt;
The Type of Class is “Class”, just like the Type of integer is “integer” in case of strongly typed languages. &lt;br /&gt;
&lt;br /&gt;
For example, in case of Java:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;“The types of the Java programming language are divided into two categories: primitive types and reference types. The primitive types are the boolean type and the numeric types. The numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double. The reference types are class types, interface types, and array types. There is also a special null type. An object is a dynamically created instance of a class type or a dynamically created array. The values of a reference type are references to objects. All objects, including arrays, support the methods of class Object . String literals are represented by String objects .” [2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, as mentioned before, in Java, there are two “Types”:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type:lower-roman&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Primitive Type&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Reference Type&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Classes, Interfaces, Arrays are all consolidations of Primitive types, so they just need to “point” to or reference the primitive ones, hence the name.&lt;br /&gt;
It is sometimes confusing and difficult to come up with a clear and robust distinction between Types and Classes. One might think &amp;quot;Class to be a Type of Type&amp;quot;. &lt;br /&gt;
It is however important to know that in strict Object Oriented Languages, Type is a union of Classes and Primitives. This rule, more or less consistent (with some deviations where primitives are treated as classes). &lt;br /&gt;
 &lt;br /&gt;
==Types and Classes in Languages==&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
Ruby claims to be a strong object oriented language. It is object oriented to the extent that every thing is an object. Primitive datatypes are objects, and we can make use of the object oriented techniques on even the primitives. As mentioned before, Ruby is a dynamic typed language, as the type is bound at compile time. Everything in Ruby has a class. Every class in Ruby is inherited from class Class. &lt;br /&gt;
&lt;br /&gt;
Type in Ruby is well defined as well. Using self inspection (reflection), we can find out whether a name is a Class, or a method. Let us see this in action:- &lt;br /&gt;
&lt;br /&gt;
The first thing that comes to a one’s mind is something like :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
&amp;quot;hello&amp;quot;.class #=&amp;gt; String&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
But have you thought of your class as an object? Well that seems odd, but that’s how ruby works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
class Foo;end  #=&amp;gt; nil&lt;br /&gt;
Foo.class #=&amp;gt; Class&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What does the above snippet of code mean exactly?&lt;br /&gt;
It means 2 things : Foo is a constant and that constant holds(refers to) an object of Class type.&lt;br /&gt;
&lt;br /&gt;
Let us prove that:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Foo = Class.new&lt;br /&gt;
(irb):8 warning: already initialized constant Foo&lt;br /&gt;
=&amp;gt; Foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
As you can see, we got a warning because we tried to initialize the constant Foo again.&lt;br /&gt;
&lt;br /&gt;
So ,when you define some class ‘Foo’ in ruby, all you are doing is:&lt;br /&gt;
1-instantiating an object of type Class.&lt;br /&gt;
2-initializing a constant Foo that refers to that created object .&lt;br /&gt;
&lt;br /&gt;
So, when we say “object” ,then we do mean any object; an object of Class type, or any object of any type.[3]&lt;br /&gt;
&lt;br /&gt;
===Java===&lt;br /&gt;
&lt;br /&gt;
As mentioned before, Java is a strongly typed language. The type of data needs to be declared before using. The types of &amp;quot;types&amp;quot; in Java are :&lt;br /&gt;
   * Primitive Types:-  boolean and numeric. The numeric types are the integral types byte, short, int, long, and char, and the         &lt;br /&gt;
     floating-point types float and double. &lt;br /&gt;
   * Reference Types:- class types, interface types and array types. [2] &lt;br /&gt;
&lt;br /&gt;
Java is an object-oriented language, but it does make a clear distinction between the primitive type and Classes. int, float, char etc. are primitives, and the other data types other than the primitives are references. It is an interesting distinction to note, because of the differences in method calling system in different languages. Java makes a distinction in &amp;quot;calling-by-value&amp;quot; when a primitive is passed as a parameter, and &amp;quot;calling-by-reference&amp;quot; when an object is passed. In fact, if a primitive is passed, a call by value is invoked, but when a Class object is passed, only a reference is passed to the object. &lt;br /&gt;
&lt;br /&gt;
For a more language specific treatment of types and classes, you can refer: http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_6_ap &lt;br /&gt;
&lt;br /&gt;
==Discussion of Issues==&lt;br /&gt;
Okay, so you're about to write a program and you need to represent data somehow.  Should you use a primitive type?  What about a class?  There are several features that are handed to you with each.&lt;br /&gt;
&lt;br /&gt;
=== Primitive Types ===&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Simplicity =====&lt;br /&gt;
In strongly typed languages, primitive types are ideal for data which doesn't necessarily need to be partitioned into several smaller components.  If you are looking to store and represent a simple throw-away integer for looping, for example, there's little reason why one would want to construct a class for this purpose.&lt;br /&gt;
&lt;br /&gt;
Primitive types are also often times coupled with native operations, handed to you by the language.  For example, in Java, variables of type int are automatically given operations such as addition, subtraction, multiplication, and so on.  These operations work as follows:&lt;br /&gt;
# Receive both inputs&lt;br /&gt;
# Cast if necessary (for example, from an int to a double)&lt;br /&gt;
# Perform calculation&lt;br /&gt;
# Return result&lt;br /&gt;
&lt;br /&gt;
It is important to note that the primitive types themselves are left ''unchanged'', and the result is returned from the operation, giving the programmer the ability to place the result elsewhere.&lt;br /&gt;
&lt;br /&gt;
===== Efficiency =====&lt;br /&gt;
In efficiency-critical applications, primitive types and their operations are oftentimes mapped directly to hardware-supported equivalents, thus operations can be performed very quickly.  This style of downgrading the logic to more so the hardware level has been replaced over the years for general applications, since improvements to hardware components have eradicated the once-imperative necessity to program efficiently.  Another point of view concerning efficiency could be from development time: if the program one is writing doesn't require complex design, it would be quicker to use the language's built-in types instead of taking the time to design a class to do the same feature.&lt;br /&gt;
&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Single-state storage =====&lt;br /&gt;
One large disadvantages to primitive types are that they are generally capable of only holding a single dimension state.  This limitation requires the programmer to use other variables in conjunction if they desire to hold more than one field of data.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Since primitive types do not allow you to encapsulate your data, if you ever desire to change the behavior of your program, you are forced to manually check each use of the variable for enforcement.&lt;br /&gt;
&lt;br /&gt;
For example, suppose you have a system designed in Java that maintains an integer value which represents the number of books you have in a library.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
int numBooks;&lt;br /&gt;
...&lt;br /&gt;
numBooks = 0;&lt;br /&gt;
...&lt;br /&gt;
numBooks++;&lt;br /&gt;
...&lt;br /&gt;
numBooks--;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A few days later, you realize that you should probably refactor your system to maintain a log of when this variable updates.  You immediately face a problem since, as it is, your code directly manipulates a single-state type integer.  Without resorting to a more object-oriented solution, you would have to update each location in the code of where a change takes place in order to establish this bookkeeping (pun intended).&lt;br /&gt;
&amp;lt;code id=&amp;quot;bookKeeping&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public static void integerValueChanged(){&lt;br /&gt;
  // records that the value has been changed&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public static void main(String[]args){&lt;br /&gt;
  int numBooks;&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks = 0;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks++;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks--;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To generalize this concept, it is oftentimes necessary to modify &amp;quot;what happens&amp;quot; when something is updated, and this cannot be easily accomplished by merely using primitive types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Class Types ===&lt;br /&gt;
Classes to the rescue!  Classes give programmers the ability to construct complex data types that are also capable of defining their own operations, all while keeping the details and specifics black-boxed outsize of where the class will be used in the code.&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Multi-dimensional Storage =====&lt;br /&gt;
Contrasting to primitive types, classes allow programmers to couple a varying number of fields.  Grouping fields of data into a single class, then instantiating such an object and manipulating it is much more convenient than keeping track of several individual variables.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Oftentimes it is necessary to refactor a system to execute code when a change happens.  In object-land, we are able to do this through the ability to control what happens in our methods.&lt;br /&gt;
&lt;br /&gt;
Taking our [[#bookKeeping| example from above]], we can give a quick example of how a class could be defined to handle the situation much more elegantly.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public class RecordedNumber{&lt;br /&gt;
  // The integer value, kept concealed in the class&lt;br /&gt;
  private int value;&lt;br /&gt;
&lt;br /&gt;
  public RecordedNumber(int value){&lt;br /&gt;
    this.value = value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public int getValue(){&lt;br /&gt;
    return value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public void setValue(int newValue){&lt;br /&gt;
    // code to do any necessary recording.&lt;br /&gt;
    ...&lt;br /&gt;
    this.value = newValue;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class MyExample{&lt;br /&gt;
  public static void main(String[]args){&lt;br /&gt;
    RecordedNumber numBooks = new RecordedNumber(0);&lt;br /&gt;
    ...&lt;br /&gt;
    numBooks.setValue(4); // the object handles all necessary bookkeeping&lt;br /&gt;
    ...&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Code-reuse =====&lt;br /&gt;
Another nice feature to class-types encapsulate the concept surrounding code re-usability, especially in topics such as inheritance.  Classes allow the programmer to enhance an already existing class-type to be more specific, which in turn can prevent excessive code duplication.&lt;br /&gt;
&lt;br /&gt;
===== Application Structure =====&lt;br /&gt;
Designing an application in a object-oriented / class-specific style can reduce the challenges of designing and building a difficult system into merely making objects successfully interact.  It is from this concept that languages such as [http://en.wikipedia.org/wiki/Unified_Modeling_Language Unified Modeling Language (UML)] have been created, allowing software engineers to build around the notion of classes and their relationships to one another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Speed Considerations =====&lt;br /&gt;
In computational-intensive applications, objects built from classes tend to be less efficient than primitive data types built around procedural context.  This is due in part because of the object's creation, since it isn't supported directly hardware level.  Consideration is placed more so on good-design and coding-practices when implementing functionality around classes.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== B =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== C =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[1] http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html&lt;br /&gt;
&lt;br /&gt;
[2] Java:- Types, Values and Variables&lt;br /&gt;
    http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html&lt;br /&gt;
[3] Ruby Reflection ,http://www.khelll.com/blog/ruby/ruby-reflection/&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39300</id>
		<title>CSC/ECE 517 Fall 2010/ch3 4b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39300"/>
		<updated>2010-10-21T04:14:53Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Types vs Classes'''&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: #F2F2F2; border: solid thin black; padding: 5px;&amp;quot;&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.  This topic was covered three years ago (http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007), but all of the articles considered one language after the other, in a set of examples rather than a discussion of issues.  Make sure that you discuss the issues, using languages as examples rather than making language the primary means of organizing the chapter.&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Overall s.png|right|upright|Relationship between Type and Class]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
It is often that we talk about types, strongly typed, weakly typed, classes. To make it clear,  let us look into it clearly. Every programming language has a way to define a variable. A variable is a named address location which stores a particular value. &lt;br /&gt;
&lt;br /&gt;
[[Image:Connection s.png|right|thumb|Types can be thought of as the set of classes ''union'' with primitive types given to a language.]]&lt;br /&gt;
&lt;br /&gt;
===Types===&lt;br /&gt;
&lt;br /&gt;
Time for an analogy? Imagine a variable to be a vacant house. It could have animals, humans, robots, or another smaller house, or whatever you can think of. There has to be a way, from a third party perspective, so as to be cognizant of the kind of things that reside in the house. Types and typing is a concept which realizes this concept. A typed language or a strongly typed language is one where the type of a variable has to be declared so as to avoid any wrong dealings of the value during run time. For example, Java is a strongly typed language. If I need to use two integers for addition, I would explicitly have to mention them as an integer:- &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  int integer1;&lt;br /&gt;
  int integer2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we can’t then re-initialize it to any other type in its defined scope.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  integer1 = “Hello World”;  // cannot map an int to a String&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the case of non-typed languages, say Ruby, or Visual Basic, etc. We don’t need to specify a type. &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  def variable1;&lt;br /&gt;
  def variable2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, it could be initialized with anything,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
as well as &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = “Good morning Vietnam”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
are allowed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Classes===&lt;br /&gt;
&lt;br /&gt;
A class is a “type” of variable specification. The difference between a class and a regular primitive integer, character, etc is that a class:-&lt;br /&gt;
&lt;br /&gt;
# consists of one or more primitive or non-primitive variables&lt;br /&gt;
# is a pre-defined structure&lt;br /&gt;
# defines methods which operate on the internal state of the object&lt;br /&gt;
&lt;br /&gt;
The Type of Class is “Class”, just like the Type of integer is “integer” in case of strongly typed languages. &lt;br /&gt;
&lt;br /&gt;
For example, in case of Java:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;“The types of the Java programming language are divided into two categories: primitive types and reference types. The primitive types are the boolean type and the numeric types. The numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double. The reference types are class types, interface types, and array types. There is also a special null type. An object is a dynamically created instance of a class type or a dynamically created array. The values of a reference type are references to objects. All objects, including arrays, support the methods of class Object . String literals are represented by String objects .” [2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, as mentioned before, in Java, there are two “Types”:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type:lower-roman&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Primitive Type&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Reference Type&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Classes, Interfaces, Arrays are all consolidations of Primitive types, so they just need to “point” to or reference the primitive ones, hence the name.&lt;br /&gt;
It is sometimes confusing and difficult to come up with a clear and robust distinction between Types and Classes. One might think &amp;quot;Class to be a Type of Type&amp;quot;. &lt;br /&gt;
It is however important to know that in strict Object Oriented Languages, Type is a union of Classes and Primitives. This rule, more or less consistent (with some deviations where primitives are treated as classes). &lt;br /&gt;
 &lt;br /&gt;
==Types and Classes in Languages==&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
Ruby claims to be a strong object oriented language. It is object oriented to the extent that every thing is an object. Primitive datatypes are objects, and we can make use of the object oriented techniques on even the primitives. As mentioned before, Ruby is a dynamic typed language, as the type is bound at compile time. Everything in Ruby has a class. Every class in Ruby is inherited from class Class. &lt;br /&gt;
&lt;br /&gt;
Type in Ruby is well defined as well. Using self inspection (reflection), we can find out whether a name is a Class, or a method. Let us see this in action:- &lt;br /&gt;
&lt;br /&gt;
The first thing that comes to a one’s mind is something like :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
&amp;quot;hello&amp;quot;.class #=&amp;gt; String&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
But have you thought of your class as an object? Well that seems odd, but that’s how ruby works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
class Foo;end  #=&amp;gt; nil&lt;br /&gt;
Foo.class #=&amp;gt; Class&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What does the above snippet of code mean exactly?&lt;br /&gt;
It means 2 things : Foo is a constant and that constant holds(refers to) an object of Class type.&lt;br /&gt;
&lt;br /&gt;
Let us prove that:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Foo = Class.new&lt;br /&gt;
(irb):8 warning: already initialized constant Foo&lt;br /&gt;
=&amp;gt; Foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
As you can see, we got a warning because we tried to initialize the constant Foo again.&lt;br /&gt;
&lt;br /&gt;
So ,when you define some class ‘Foo’ in ruby, all you are doing is:&lt;br /&gt;
1-instantiating an object of type Class.&lt;br /&gt;
2-initializing a constant Foo that refers to that created object .&lt;br /&gt;
&lt;br /&gt;
So, when we say “object” ,then we do mean any object; an object of Class type, or any object of any type.[3]&lt;br /&gt;
&lt;br /&gt;
===Java===&lt;br /&gt;
&lt;br /&gt;
As mentioned before, Java is a strongly typed language. The type of data needs to be declared before using. The types of &amp;quot;types&amp;quot; in Java are :&lt;br /&gt;
   * Primitive Types:-  boolean and numeric. The numeric types are the integral types byte, short, int, long, and char, and the         &lt;br /&gt;
     floating-point types float and double. &lt;br /&gt;
   * Reference Types:- class types, interface types and array types. [2] &lt;br /&gt;
&lt;br /&gt;
Java is an object-oriented language, but it does make a clear distinction between the primitive type and Classes. int, float, char etc. are primitives, and the other data types other than the primitives are references. It is an interesting distinction to note, because of the differences in method calling system in different languages. Java makes a distinction in &amp;quot;calling-by-value&amp;quot; when a primitive is passed as a parameter, and &amp;quot;calling-by-reference&amp;quot; when an object is passed. In fact, if a primitive is passed, a call by value is invoked, but when a Class object is passed, only a reference is passed to the object. &lt;br /&gt;
&lt;br /&gt;
For a more language specific treatment of types and classes, you can refer: http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_6_ap &lt;br /&gt;
&lt;br /&gt;
==Discussion of Issues==&lt;br /&gt;
Okay, so you're about to write a program and you need to represent data somehow.  Should you use a primitive type?  What about a class?  There are several features that are handed to you with each.&lt;br /&gt;
&lt;br /&gt;
=== Primitive Types ===&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Simplicity =====&lt;br /&gt;
In strongly typed languages, primitive types are ideal for data which doesn't necessarily need to be partitioned into several smaller components.  If you are looking to store and represent a simple throw-away integer for looping, for example, there's little reason why one would want to construct a class for this purpose.&lt;br /&gt;
&lt;br /&gt;
Primitive types are also often times coupled with native operations, handed to you by the language.  For example, in Java, variables of type int are automatically given operations such as addition, subtraction, multiplication, and so on.  These operations work as follows:&lt;br /&gt;
# Receive both inputs&lt;br /&gt;
# Cast if necessary (for example, from an int to a double)&lt;br /&gt;
# Perform calculation&lt;br /&gt;
# Return result&lt;br /&gt;
&lt;br /&gt;
It is important to note that the primitive types themselves are left ''unchanged'', and the result is returned from the operation, giving the programmer the ability to place the result elsewhere.&lt;br /&gt;
&lt;br /&gt;
===== Efficiency =====&lt;br /&gt;
In efficiency-critical applications, primitive types and their operations are oftentimes mapped directly to hardware-supported equivalents, thus operations can be performed very quickly.  This style of downgrading the logic to more so the hardware level has been replaced over the years for general applications, since improvements to hardware components have eradicated the once-imperative necessity to program efficiently.  Another point of view concerning efficiency could be from development time: if the program one is writing doesn't require complex design, it would be quicker to use the language's built-in types instead of taking the time to design a class to do the same feature.&lt;br /&gt;
&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Single-state storage =====&lt;br /&gt;
One large disadvantages to primitive types are that they are generally capable of only holding a single dimension state.  This limitation requires the programmer to use other variables in conjunction if they desire to hold more than one field of data.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Since primitive types do not allow you to encapsulate your data, if you ever desire to change the behavior of your program, you are forced to manually check each use of the variable for enforcement.&lt;br /&gt;
&lt;br /&gt;
For example, suppose you have a system designed in Java that maintains an integer value which represents the number of books you have in a library.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
int numBooks;&lt;br /&gt;
...&lt;br /&gt;
numBooks = 0;&lt;br /&gt;
...&lt;br /&gt;
numBooks++;&lt;br /&gt;
...&lt;br /&gt;
numBooks--;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A few days later, you realize that you should probably refactor your system to maintain a log of when this variable updates.  You immediately face a problem since, as it is, your code directly manipulates a single-state type integer.  Without resorting to a more object-oriented solution, you would have to update each location in the code of where a change takes place in order to establish this bookkeeping (pun intended).&lt;br /&gt;
&amp;lt;code id=&amp;quot;bookKeeping&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public static void integerValueChanged(){&lt;br /&gt;
  // records that the value has been changed&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public static void main(String[]args){&lt;br /&gt;
  int numBooks;&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks = 0;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks++;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks--;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To generalize this concept, it is oftentimes necessary to modify &amp;quot;what happens&amp;quot; when something is updated, and this cannot be easily accomplished by merely using primitive types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Class Types ===&lt;br /&gt;
Classes to the rescue!  Classes give programmers the ability to construct complex data types that are also capable of defining their own operations, all while keeping the details and specifics black-boxed outsize of where the class will be used in the code.&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Multi-dimensional Storage =====&lt;br /&gt;
Contrasting to primitive types, classes allow programmers to couple a varying number of fields.  Grouping fields of data into a single class, then instantiating such an object and manipulating it is much more convenient than keeping track of several individual variables.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Oftentimes it is necessary to refactor a system to execute code when a change happens.  In object-land, we are able to do this through the ability to control what happens in our methods.&lt;br /&gt;
&lt;br /&gt;
Taking our [[#bookKeeping| example from above]], we can give a quick example of how a class could be defined to handle the situation much more elegantly.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public class RecordedNumber{&lt;br /&gt;
  // The integer value, kept concealed in the class&lt;br /&gt;
  private int value;&lt;br /&gt;
&lt;br /&gt;
  public RecordedNumber(int value){&lt;br /&gt;
    this.value = value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public int getValue(){&lt;br /&gt;
    return value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public void setValue(int newValue){&lt;br /&gt;
    // code to do any necessary recording.&lt;br /&gt;
    ...&lt;br /&gt;
    this.value = newValue;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class MyExample{&lt;br /&gt;
  public static void main(String[]args){&lt;br /&gt;
    RecordedNumber numBooks = new RecordedNumber(0);&lt;br /&gt;
    ...&lt;br /&gt;
    numBooks.setValue(4); // the object handles all necessary bookkeeping&lt;br /&gt;
    ...&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Code-reuse =====&lt;br /&gt;
Another nice feature to class-types encapsulate the concept surrounding code re-usability, especially in topics such as inheritance.  Classes allow the programmer to enhance an already existing class-type to be more specific, which in turn can prevent excessive code duplication.&lt;br /&gt;
&lt;br /&gt;
===== Application Structure =====&lt;br /&gt;
Designing an application in a object-oriented / class-specific style can reduce the challenges of designing and building a difficult system into merely making objects successfully interact.  It is from this concept that languages such as [http://en.wikipedia.org/wiki/Unified_Modeling_Language Unified Modeling Language (UML)] have been created, allowing software engineers to build around the notion of classes and their relationships to one another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Speed Considerations =====&lt;br /&gt;
In computational-intensive applications, objects built from classes tend to be less efficient than primitive data types built around procedural context.  This is due in part because of the object's creation, since it isn't supported directly hardware level.  Consideration is placed more so on good-design and coding-practices when implementing functionality around classes.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== B =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== C =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[1] http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html&lt;br /&gt;
&lt;br /&gt;
[2] Java:- Types, Values and Variables&lt;br /&gt;
    http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html&lt;br /&gt;
[3] Ruby Reflection ,http://www.khelll.com/blog/ruby/ruby-reflection/&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39299</id>
		<title>CSC/ECE 517 Fall 2010/ch3 4b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39299"/>
		<updated>2010-10-21T04:14:05Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Types vs Classes'''&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: #F2F2F2; border: solid thin black; padding: 5px;&amp;quot;&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.  This topic was covered three years ago (http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007), but all of the articles considered one language after the other, in a set of examples rather than a discussion of issues.  Make sure that you discuss the issues, using languages as examples rather than making language the primary means of organizing the chapter.&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Overall s.png|right|upright|Relationship between Type and Class]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
It is often that we talk about types, strongly typed, weakly typed, classes. To make it clear,  let us look into it clearly. Every programming language has a way to define a variable. A variable is a named address location which stores a particular value. &lt;br /&gt;
&lt;br /&gt;
[[Image:Connection s.png|right|thumb|Types can be thought of as the set of classes combined with primitive types given to a language.]]&lt;br /&gt;
&lt;br /&gt;
===Types===&lt;br /&gt;
&lt;br /&gt;
Time for an analogy? Imagine a variable to be a vacant house. It could have animals, humans, robots, or another smaller house, or whatever you can think of. There has to be a way, from a third party perspective, so as to be cognizant of the kind of things that reside in the house. Types and typing is a concept which realizes this concept. A typed language or a strongly typed language is one where the type of a variable has to be declared so as to avoid any wrong dealings of the value during run time. For example, Java is a strongly typed language. If I need to use two integers for addition, I would explicitly have to mention them as an integer:- &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  int integer1;&lt;br /&gt;
  int integer2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we can’t then re-initialize it to any other type in its defined scope.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  integer1 = “Hello World”;  // cannot map an int to a String&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the case of non-typed languages, say Ruby, or Visual Basic, etc. We don’t need to specify a type. &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  def variable1;&lt;br /&gt;
  def variable2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, it could be initialized with anything,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
as well as &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = “Good morning Vietnam”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
are allowed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Classes===&lt;br /&gt;
&lt;br /&gt;
A class is a “type” of variable specification. The difference between a class and a regular primitive integer, character, etc is that a class:-&lt;br /&gt;
&lt;br /&gt;
# consists of one or more primitive or non-primitive variables&lt;br /&gt;
# is a pre-defined structure&lt;br /&gt;
# defines methods which operate on the internal state of the object&lt;br /&gt;
&lt;br /&gt;
The Type of Class is “Class”, just like the Type of integer is “integer” in case of strongly typed languages. &lt;br /&gt;
&lt;br /&gt;
For example, in case of Java:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;“The types of the Java programming language are divided into two categories: primitive types and reference types. The primitive types are the boolean type and the numeric types. The numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double. The reference types are class types, interface types, and array types. There is also a special null type. An object is a dynamically created instance of a class type or a dynamically created array. The values of a reference type are references to objects. All objects, including arrays, support the methods of class Object . String literals are represented by String objects .” [2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, as mentioned before, in Java, there are two “Types”:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type:lower-roman&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Primitive Type&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Reference Type&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Classes, Interfaces, Arrays are all consolidations of Primitive types, so they just need to “point” to or reference the primitive ones, hence the name.&lt;br /&gt;
It is sometimes confusing and difficult to come up with a clear and robust distinction between Types and Classes. One might think &amp;quot;Class to be a Type of Type&amp;quot;. &lt;br /&gt;
It is however important to know that in strict Object Oriented Languages, Type is a union of Classes and Primitives. This rule, more or less consistent (with some deviations where primitives are treated as classes). &lt;br /&gt;
 &lt;br /&gt;
==Types and Classes in Languages==&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
Ruby claims to be a strong object oriented language. It is object oriented to the extent that every thing is an object. Primitive datatypes are objects, and we can make use of the object oriented techniques on even the primitives. As mentioned before, Ruby is a dynamic typed language, as the type is bound at compile time. Everything in Ruby has a class. Every class in Ruby is inherited from class Class. &lt;br /&gt;
&lt;br /&gt;
Type in Ruby is well defined as well. Using self inspection (reflection), we can find out whether a name is a Class, or a method. Let us see this in action:- &lt;br /&gt;
&lt;br /&gt;
The first thing that comes to a one’s mind is something like :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
&amp;quot;hello&amp;quot;.class #=&amp;gt; String&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
But have you thought of your class as an object? Well that seems odd, but that’s how ruby works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
class Foo;end  #=&amp;gt; nil&lt;br /&gt;
Foo.class #=&amp;gt; Class&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What does the above snippet of code mean exactly?&lt;br /&gt;
It means 2 things : Foo is a constant and that constant holds(refers to) an object of Class type.&lt;br /&gt;
&lt;br /&gt;
Let us prove that:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Foo = Class.new&lt;br /&gt;
(irb):8 warning: already initialized constant Foo&lt;br /&gt;
=&amp;gt; Foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
As you can see, we got a warning because we tried to initialize the constant Foo again.&lt;br /&gt;
&lt;br /&gt;
So ,when you define some class ‘Foo’ in ruby, all you are doing is:&lt;br /&gt;
1-instantiating an object of type Class.&lt;br /&gt;
2-initializing a constant Foo that refers to that created object .&lt;br /&gt;
&lt;br /&gt;
So, when we say “object” ,then we do mean any object; an object of Class type, or any object of any type.[3]&lt;br /&gt;
&lt;br /&gt;
===Java===&lt;br /&gt;
&lt;br /&gt;
As mentioned before, Java is a strongly typed language. The type of data needs to be declared before using. The types of &amp;quot;types&amp;quot; in Java are :&lt;br /&gt;
   * Primitive Types:-  boolean and numeric. The numeric types are the integral types byte, short, int, long, and char, and the         &lt;br /&gt;
     floating-point types float and double. &lt;br /&gt;
   * Reference Types:- class types, interface types and array types. [2] &lt;br /&gt;
&lt;br /&gt;
Java is an object-oriented language, but it does make a clear distinction between the primitive type and Classes. int, float, char etc. are primitives, and the other data types other than the primitives are references. It is an interesting distinction to note, because of the differences in method calling system in different languages. Java makes a distinction in &amp;quot;calling-by-value&amp;quot; when a primitive is passed as a parameter, and &amp;quot;calling-by-reference&amp;quot; when an object is passed. In fact, if a primitive is passed, a call by value is invoked, but when a Class object is passed, only a reference is passed to the object. &lt;br /&gt;
&lt;br /&gt;
For a more language specific treatment of types and classes, you can refer: http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_6_ap &lt;br /&gt;
&lt;br /&gt;
==Discussion of Issues==&lt;br /&gt;
Okay, so you're about to write a program and you need to represent data somehow.  Should you use a primitive type?  What about a class?  There are several features that are handed to you with each.&lt;br /&gt;
&lt;br /&gt;
=== Primitive Types ===&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Simplicity =====&lt;br /&gt;
In strongly typed languages, primitive types are ideal for data which doesn't necessarily need to be partitioned into several smaller components.  If you are looking to store and represent a simple throw-away integer for looping, for example, there's little reason why one would want to construct a class for this purpose.&lt;br /&gt;
&lt;br /&gt;
Primitive types are also often times coupled with native operations, handed to you by the language.  For example, in Java, variables of type int are automatically given operations such as addition, subtraction, multiplication, and so on.  These operations work as follows:&lt;br /&gt;
# Receive both inputs&lt;br /&gt;
# Cast if necessary (for example, from an int to a double)&lt;br /&gt;
# Perform calculation&lt;br /&gt;
# Return result&lt;br /&gt;
&lt;br /&gt;
It is important to note that the primitive types themselves are left ''unchanged'', and the result is returned from the operation, giving the programmer the ability to place the result elsewhere.&lt;br /&gt;
&lt;br /&gt;
===== Efficiency =====&lt;br /&gt;
In efficiency-critical applications, primitive types and their operations are oftentimes mapped directly to hardware-supported equivalents, thus operations can be performed very quickly.  This style of downgrading the logic to more so the hardware level has been replaced over the years for general applications, since improvements to hardware components have eradicated the once-imperative necessity to program efficiently.  Another point of view concerning efficiency could be from development time: if the program one is writing doesn't require complex design, it would be quicker to use the language's built-in types instead of taking the time to design a class to do the same feature.&lt;br /&gt;
&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Single-state storage =====&lt;br /&gt;
One large disadvantages to primitive types are that they are generally capable of only holding a single dimension state.  This limitation requires the programmer to use other variables in conjunction if they desire to hold more than one field of data.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Since primitive types do not allow you to encapsulate your data, if you ever desire to change the behavior of your program, you are forced to manually check each use of the variable for enforcement.&lt;br /&gt;
&lt;br /&gt;
For example, suppose you have a system designed in Java that maintains an integer value which represents the number of books you have in a library.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
int numBooks;&lt;br /&gt;
...&lt;br /&gt;
numBooks = 0;&lt;br /&gt;
...&lt;br /&gt;
numBooks++;&lt;br /&gt;
...&lt;br /&gt;
numBooks--;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A few days later, you realize that you should probably refactor your system to maintain a log of when this variable updates.  You immediately face a problem since, as it is, your code directly manipulates a single-state type integer.  Without resorting to a more object-oriented solution, you would have to update each location in the code of where a change takes place in order to establish this bookkeeping (pun intended).&lt;br /&gt;
&amp;lt;code id=&amp;quot;bookKeeping&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public static void integerValueChanged(){&lt;br /&gt;
  // records that the value has been changed&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public static void main(String[]args){&lt;br /&gt;
  int numBooks;&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks = 0;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks++;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks--;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To generalize this concept, it is oftentimes necessary to modify &amp;quot;what happens&amp;quot; when something is updated, and this cannot be easily accomplished by merely using primitive types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Class Types ===&lt;br /&gt;
Classes to the rescue!  Classes give programmers the ability to construct complex data types that are also capable of defining their own operations, all while keeping the details and specifics black-boxed outsize of where the class will be used in the code.&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Multi-dimensional Storage =====&lt;br /&gt;
Contrasting to primitive types, classes allow programmers to couple a varying number of fields.  Grouping fields of data into a single class, then instantiating such an object and manipulating it is much more convenient than keeping track of several individual variables.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Oftentimes it is necessary to refactor a system to execute code when a change happens.  In object-land, we are able to do this through the ability to control what happens in our methods.&lt;br /&gt;
&lt;br /&gt;
Taking our [[#bookKeeping| example from above]], we can give a quick example of how a class could be defined to handle the situation much more elegantly.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public class RecordedNumber{&lt;br /&gt;
  // The integer value, kept concealed in the class&lt;br /&gt;
  private int value;&lt;br /&gt;
&lt;br /&gt;
  public RecordedNumber(int value){&lt;br /&gt;
    this.value = value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public int getValue(){&lt;br /&gt;
    return value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public void setValue(int newValue){&lt;br /&gt;
    // code to do any necessary recording.&lt;br /&gt;
    ...&lt;br /&gt;
    this.value = newValue;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class MyExample{&lt;br /&gt;
  public static void main(String[]args){&lt;br /&gt;
    RecordedNumber numBooks = new RecordedNumber(0);&lt;br /&gt;
    ...&lt;br /&gt;
    numBooks.setValue(4); // the object handles all necessary bookkeeping&lt;br /&gt;
    ...&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Code-reuse =====&lt;br /&gt;
Another nice feature to class-types encapsulate the concept surrounding code re-usability, especially in topics such as inheritance.  Classes allow the programmer to enhance an already existing class-type to be more specific, which in turn can prevent excessive code duplication.&lt;br /&gt;
&lt;br /&gt;
===== Application Structure =====&lt;br /&gt;
Designing an application in a object-oriented / class-specific style can reduce the challenges of designing and building a difficult system into merely making objects successfully interact.  It is from this concept that languages such as [http://en.wikipedia.org/wiki/Unified_Modeling_Language Unified Modeling Language (UML)] have been created, allowing software engineers to build around the notion of classes and their relationships to one another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Speed Considerations =====&lt;br /&gt;
In computational-intensive applications, objects built from classes tend to be less efficient than primitive data types built around procedural context.  This is due in part because of the object's creation, since it isn't supported directly hardware level.  Consideration is placed more so on good-design and coding-practices when implementing functionality around classes.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== B =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== C =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[1] http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html&lt;br /&gt;
&lt;br /&gt;
[2] Java:- Types, Values and Variables&lt;br /&gt;
    http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html&lt;br /&gt;
[3] Ruby Reflection ,http://www.khelll.com/blog/ruby/ruby-reflection/&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39298</id>
		<title>CSC/ECE 517 Fall 2010/ch3 4b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39298"/>
		<updated>2010-10-21T04:13:53Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Types vs Classes'''&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: #F2F2F2; border: solid thin black; padding: 5px;&amp;quot;&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.  This topic was covered three years ago (http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007), but all of the articles considered one language after the other, in a set of examples rather than a discussion of issues.  Make sure that you discuss the issues, using languages as examples rather than making language the primary means of organizing the chapter.&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Overall s.png|right|upright|thumb|Relationship between Type and Class]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
It is often that we talk about types, strongly typed, weakly typed, classes. To make it clear,  let us look into it clearly. Every programming language has a way to define a variable. A variable is a named address location which stores a particular value. &lt;br /&gt;
&lt;br /&gt;
[[Image:Connection s.png|right|Types can be thought of as the set of classes combined with primitive types given to a language.]]&lt;br /&gt;
&lt;br /&gt;
===Types===&lt;br /&gt;
&lt;br /&gt;
Time for an analogy? Imagine a variable to be a vacant house. It could have animals, humans, robots, or another smaller house, or whatever you can think of. There has to be a way, from a third party perspective, so as to be cognizant of the kind of things that reside in the house. Types and typing is a concept which realizes this concept. A typed language or a strongly typed language is one where the type of a variable has to be declared so as to avoid any wrong dealings of the value during run time. For example, Java is a strongly typed language. If I need to use two integers for addition, I would explicitly have to mention them as an integer:- &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  int integer1;&lt;br /&gt;
  int integer2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we can’t then re-initialize it to any other type in its defined scope.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  integer1 = “Hello World”;  // cannot map an int to a String&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the case of non-typed languages, say Ruby, or Visual Basic, etc. We don’t need to specify a type. &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  def variable1;&lt;br /&gt;
  def variable2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, it could be initialized with anything,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
as well as &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = “Good morning Vietnam”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
are allowed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Classes===&lt;br /&gt;
&lt;br /&gt;
A class is a “type” of variable specification. The difference between a class and a regular primitive integer, character, etc is that a class:-&lt;br /&gt;
&lt;br /&gt;
# consists of one or more primitive or non-primitive variables&lt;br /&gt;
# is a pre-defined structure&lt;br /&gt;
# defines methods which operate on the internal state of the object&lt;br /&gt;
&lt;br /&gt;
The Type of Class is “Class”, just like the Type of integer is “integer” in case of strongly typed languages. &lt;br /&gt;
&lt;br /&gt;
For example, in case of Java:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;“The types of the Java programming language are divided into two categories: primitive types and reference types. The primitive types are the boolean type and the numeric types. The numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double. The reference types are class types, interface types, and array types. There is also a special null type. An object is a dynamically created instance of a class type or a dynamically created array. The values of a reference type are references to objects. All objects, including arrays, support the methods of class Object . String literals are represented by String objects .” [2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, as mentioned before, in Java, there are two “Types”:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type:lower-roman&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Primitive Type&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Reference Type&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Classes, Interfaces, Arrays are all consolidations of Primitive types, so they just need to “point” to or reference the primitive ones, hence the name.&lt;br /&gt;
It is sometimes confusing and difficult to come up with a clear and robust distinction between Types and Classes. One might think &amp;quot;Class to be a Type of Type&amp;quot;. &lt;br /&gt;
It is however important to know that in strict Object Oriented Languages, Type is a union of Classes and Primitives. This rule, more or less consistent (with some deviations where primitives are treated as classes). &lt;br /&gt;
 &lt;br /&gt;
==Types and Classes in Languages==&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
Ruby claims to be a strong object oriented language. It is object oriented to the extent that every thing is an object. Primitive datatypes are objects, and we can make use of the object oriented techniques on even the primitives. As mentioned before, Ruby is a dynamic typed language, as the type is bound at compile time. Everything in Ruby has a class. Every class in Ruby is inherited from class Class. &lt;br /&gt;
&lt;br /&gt;
Type in Ruby is well defined as well. Using self inspection (reflection), we can find out whether a name is a Class, or a method. Let us see this in action:- &lt;br /&gt;
&lt;br /&gt;
The first thing that comes to a one’s mind is something like :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
&amp;quot;hello&amp;quot;.class #=&amp;gt; String&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
But have you thought of your class as an object? Well that seems odd, but that’s how ruby works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
class Foo;end  #=&amp;gt; nil&lt;br /&gt;
Foo.class #=&amp;gt; Class&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What does the above snippet of code mean exactly?&lt;br /&gt;
It means 2 things : Foo is a constant and that constant holds(refers to) an object of Class type.&lt;br /&gt;
&lt;br /&gt;
Let us prove that:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Foo = Class.new&lt;br /&gt;
(irb):8 warning: already initialized constant Foo&lt;br /&gt;
=&amp;gt; Foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
As you can see, we got a warning because we tried to initialize the constant Foo again.&lt;br /&gt;
&lt;br /&gt;
So ,when you define some class ‘Foo’ in ruby, all you are doing is:&lt;br /&gt;
1-instantiating an object of type Class.&lt;br /&gt;
2-initializing a constant Foo that refers to that created object .&lt;br /&gt;
&lt;br /&gt;
So, when we say “object” ,then we do mean any object; an object of Class type, or any object of any type.[3]&lt;br /&gt;
&lt;br /&gt;
===Java===&lt;br /&gt;
&lt;br /&gt;
As mentioned before, Java is a strongly typed language. The type of data needs to be declared before using. The types of &amp;quot;types&amp;quot; in Java are :&lt;br /&gt;
   * Primitive Types:-  boolean and numeric. The numeric types are the integral types byte, short, int, long, and char, and the         &lt;br /&gt;
     floating-point types float and double. &lt;br /&gt;
   * Reference Types:- class types, interface types and array types. [2] &lt;br /&gt;
&lt;br /&gt;
Java is an object-oriented language, but it does make a clear distinction between the primitive type and Classes. int, float, char etc. are primitives, and the other data types other than the primitives are references. It is an interesting distinction to note, because of the differences in method calling system in different languages. Java makes a distinction in &amp;quot;calling-by-value&amp;quot; when a primitive is passed as a parameter, and &amp;quot;calling-by-reference&amp;quot; when an object is passed. In fact, if a primitive is passed, a call by value is invoked, but when a Class object is passed, only a reference is passed to the object. &lt;br /&gt;
&lt;br /&gt;
For a more language specific treatment of types and classes, you can refer: http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_6_ap &lt;br /&gt;
&lt;br /&gt;
==Discussion of Issues==&lt;br /&gt;
Okay, so you're about to write a program and you need to represent data somehow.  Should you use a primitive type?  What about a class?  There are several features that are handed to you with each.&lt;br /&gt;
&lt;br /&gt;
=== Primitive Types ===&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Simplicity =====&lt;br /&gt;
In strongly typed languages, primitive types are ideal for data which doesn't necessarily need to be partitioned into several smaller components.  If you are looking to store and represent a simple throw-away integer for looping, for example, there's little reason why one would want to construct a class for this purpose.&lt;br /&gt;
&lt;br /&gt;
Primitive types are also often times coupled with native operations, handed to you by the language.  For example, in Java, variables of type int are automatically given operations such as addition, subtraction, multiplication, and so on.  These operations work as follows:&lt;br /&gt;
# Receive both inputs&lt;br /&gt;
# Cast if necessary (for example, from an int to a double)&lt;br /&gt;
# Perform calculation&lt;br /&gt;
# Return result&lt;br /&gt;
&lt;br /&gt;
It is important to note that the primitive types themselves are left ''unchanged'', and the result is returned from the operation, giving the programmer the ability to place the result elsewhere.&lt;br /&gt;
&lt;br /&gt;
===== Efficiency =====&lt;br /&gt;
In efficiency-critical applications, primitive types and their operations are oftentimes mapped directly to hardware-supported equivalents, thus operations can be performed very quickly.  This style of downgrading the logic to more so the hardware level has been replaced over the years for general applications, since improvements to hardware components have eradicated the once-imperative necessity to program efficiently.  Another point of view concerning efficiency could be from development time: if the program one is writing doesn't require complex design, it would be quicker to use the language's built-in types instead of taking the time to design a class to do the same feature.&lt;br /&gt;
&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Single-state storage =====&lt;br /&gt;
One large disadvantages to primitive types are that they are generally capable of only holding a single dimension state.  This limitation requires the programmer to use other variables in conjunction if they desire to hold more than one field of data.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Since primitive types do not allow you to encapsulate your data, if you ever desire to change the behavior of your program, you are forced to manually check each use of the variable for enforcement.&lt;br /&gt;
&lt;br /&gt;
For example, suppose you have a system designed in Java that maintains an integer value which represents the number of books you have in a library.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
int numBooks;&lt;br /&gt;
...&lt;br /&gt;
numBooks = 0;&lt;br /&gt;
...&lt;br /&gt;
numBooks++;&lt;br /&gt;
...&lt;br /&gt;
numBooks--;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A few days later, you realize that you should probably refactor your system to maintain a log of when this variable updates.  You immediately face a problem since, as it is, your code directly manipulates a single-state type integer.  Without resorting to a more object-oriented solution, you would have to update each location in the code of where a change takes place in order to establish this bookkeeping (pun intended).&lt;br /&gt;
&amp;lt;code id=&amp;quot;bookKeeping&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public static void integerValueChanged(){&lt;br /&gt;
  // records that the value has been changed&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public static void main(String[]args){&lt;br /&gt;
  int numBooks;&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks = 0;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks++;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks--;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To generalize this concept, it is oftentimes necessary to modify &amp;quot;what happens&amp;quot; when something is updated, and this cannot be easily accomplished by merely using primitive types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Class Types ===&lt;br /&gt;
Classes to the rescue!  Classes give programmers the ability to construct complex data types that are also capable of defining their own operations, all while keeping the details and specifics black-boxed outsize of where the class will be used in the code.&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Multi-dimensional Storage =====&lt;br /&gt;
Contrasting to primitive types, classes allow programmers to couple a varying number of fields.  Grouping fields of data into a single class, then instantiating such an object and manipulating it is much more convenient than keeping track of several individual variables.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Oftentimes it is necessary to refactor a system to execute code when a change happens.  In object-land, we are able to do this through the ability to control what happens in our methods.&lt;br /&gt;
&lt;br /&gt;
Taking our [[#bookKeeping| example from above]], we can give a quick example of how a class could be defined to handle the situation much more elegantly.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public class RecordedNumber{&lt;br /&gt;
  // The integer value, kept concealed in the class&lt;br /&gt;
  private int value;&lt;br /&gt;
&lt;br /&gt;
  public RecordedNumber(int value){&lt;br /&gt;
    this.value = value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public int getValue(){&lt;br /&gt;
    return value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public void setValue(int newValue){&lt;br /&gt;
    // code to do any necessary recording.&lt;br /&gt;
    ...&lt;br /&gt;
    this.value = newValue;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class MyExample{&lt;br /&gt;
  public static void main(String[]args){&lt;br /&gt;
    RecordedNumber numBooks = new RecordedNumber(0);&lt;br /&gt;
    ...&lt;br /&gt;
    numBooks.setValue(4); // the object handles all necessary bookkeeping&lt;br /&gt;
    ...&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Code-reuse =====&lt;br /&gt;
Another nice feature to class-types encapsulate the concept surrounding code re-usability, especially in topics such as inheritance.  Classes allow the programmer to enhance an already existing class-type to be more specific, which in turn can prevent excessive code duplication.&lt;br /&gt;
&lt;br /&gt;
===== Application Structure =====&lt;br /&gt;
Designing an application in a object-oriented / class-specific style can reduce the challenges of designing and building a difficult system into merely making objects successfully interact.  It is from this concept that languages such as [http://en.wikipedia.org/wiki/Unified_Modeling_Language Unified Modeling Language (UML)] have been created, allowing software engineers to build around the notion of classes and their relationships to one another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Speed Considerations =====&lt;br /&gt;
In computational-intensive applications, objects built from classes tend to be less efficient than primitive data types built around procedural context.  This is due in part because of the object's creation, since it isn't supported directly hardware level.  Consideration is placed more so on good-design and coding-practices when implementing functionality around classes.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== B =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== C =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[1] http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html&lt;br /&gt;
&lt;br /&gt;
[2] Java:- Types, Values and Variables&lt;br /&gt;
    http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html&lt;br /&gt;
[3] Ruby Reflection ,http://www.khelll.com/blog/ruby/ruby-reflection/&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39297</id>
		<title>CSC/ECE 517 Fall 2010/ch3 4b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39297"/>
		<updated>2010-10-21T04:13:08Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Types vs Classes'''&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: #F2F2F2; border: solid thin black; padding: 5px;&amp;quot;&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.  This topic was covered three years ago (http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007), but all of the articles considered one language after the other, in a set of examples rather than a discussion of issues.  Make sure that you discuss the issues, using languages as examples rather than making language the primary means of organizing the chapter.&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Overall s.png|right|upright|Relationship between Type and Class]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
It is often that we talk about types, strongly typed, weakly typed, classes. To make it clear,  let us look into it clearly. Every programming language has a way to define a variable. A variable is a named address location which stores a particular value. &lt;br /&gt;
&lt;br /&gt;
[[Image:Connection s.png|right|Types can be thought of as the set of classes combined with primitive types given to a language.]]&lt;br /&gt;
&lt;br /&gt;
===Types===&lt;br /&gt;
&lt;br /&gt;
Time for an analogy? Imagine a variable to be a vacant house. It could have animals, humans, robots, or another smaller house, or whatever you can think of. There has to be a way, from a third party perspective, so as to be cognizant of the kind of things that reside in the house. Types and typing is a concept which realizes this concept. A typed language or a strongly typed language is one where the type of a variable has to be declared so as to avoid any wrong dealings of the value during run time. For example, Java is a strongly typed language. If I need to use two integers for addition, I would explicitly have to mention them as an integer:- &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  int integer1;&lt;br /&gt;
  int integer2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we can’t then re-initialize it to any other type in its defined scope.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  integer1 = “Hello World”;  // cannot map an int to a String&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the case of non-typed languages, say Ruby, or Visual Basic, etc. We don’t need to specify a type. &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  def variable1;&lt;br /&gt;
  def variable2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, it could be initialized with anything,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
as well as &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = “Good morning Vietnam”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
are allowed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Classes===&lt;br /&gt;
&lt;br /&gt;
A class is a “type” of variable specification. The difference between a class and a regular primitive integer, character, etc is that a class:-&lt;br /&gt;
&lt;br /&gt;
# consists of one or more primitive or non-primitive variables&lt;br /&gt;
# is a pre-defined structure&lt;br /&gt;
# defines methods which operate on the internal state of the object&lt;br /&gt;
&lt;br /&gt;
The Type of Class is “Class”, just like the Type of integer is “integer” in case of strongly typed languages. &lt;br /&gt;
&lt;br /&gt;
For example, in case of Java:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;“The types of the Java programming language are divided into two categories: primitive types and reference types. The primitive types are the boolean type and the numeric types. The numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double. The reference types are class types, interface types, and array types. There is also a special null type. An object is a dynamically created instance of a class type or a dynamically created array. The values of a reference type are references to objects. All objects, including arrays, support the methods of class Object . String literals are represented by String objects .” [2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, as mentioned before, in Java, there are two “Types”:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type:lower-roman&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Primitive Type&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Reference Type&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Classes, Interfaces, Arrays are all consolidations of Primitive types, so they just need to “point” to or reference the primitive ones, hence the name.&lt;br /&gt;
It is sometimes confusing and difficult to come up with a clear and robust distinction between Types and Classes. One might think &amp;quot;Class to be a Type of Type&amp;quot;. &lt;br /&gt;
It is however important to know that in strict Object Oriented Languages, Type is a union of Classes and Primitives. This rule, more or less consistent (with some deviations where primitives are treated as classes). &lt;br /&gt;
 &lt;br /&gt;
==Types and Classes in Languages==&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
Ruby claims to be a strong object oriented language. It is object oriented to the extent that every thing is an object. Primitive datatypes are objects, and we can make use of the object oriented techniques on even the primitives. As mentioned before, Ruby is a dynamic typed language, as the type is bound at compile time. Everything in Ruby has a class. Every class in Ruby is inherited from class Class. &lt;br /&gt;
&lt;br /&gt;
Type in Ruby is well defined as well. Using self inspection (reflection), we can find out whether a name is a Class, or a method. Let us see this in action:- &lt;br /&gt;
&lt;br /&gt;
The first thing that comes to a one’s mind is something like :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
&amp;quot;hello&amp;quot;.class #=&amp;gt; String&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
But have you thought of your class as an object? Well that seems odd, but that’s how ruby works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
class Foo;end  #=&amp;gt; nil&lt;br /&gt;
Foo.class #=&amp;gt; Class&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What does the above snippet of code mean exactly?&lt;br /&gt;
It means 2 things : Foo is a constant and that constant holds(refers to) an object of Class type.&lt;br /&gt;
&lt;br /&gt;
Let us prove that:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Foo = Class.new&lt;br /&gt;
(irb):8 warning: already initialized constant Foo&lt;br /&gt;
=&amp;gt; Foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
As you can see, we got a warning because we tried to initialize the constant Foo again.&lt;br /&gt;
&lt;br /&gt;
So ,when you define some class ‘Foo’ in ruby, all you are doing is:&lt;br /&gt;
1-instantiating an object of type Class.&lt;br /&gt;
2-initializing a constant Foo that refers to that created object .&lt;br /&gt;
&lt;br /&gt;
So, when we say “object” ,then we do mean any object; an object of Class type, or any object of any type.[3]&lt;br /&gt;
&lt;br /&gt;
===Java===&lt;br /&gt;
&lt;br /&gt;
As mentioned before, Java is a strongly typed language. The type of data needs to be declared before using. The types of &amp;quot;types&amp;quot; in Java are :&lt;br /&gt;
   * Primitive Types:-  boolean and numeric. The numeric types are the integral types byte, short, int, long, and char, and the         &lt;br /&gt;
     floating-point types float and double. &lt;br /&gt;
   * Reference Types:- class types, interface types and array types. [2] &lt;br /&gt;
&lt;br /&gt;
Java is an object-oriented language, but it does make a clear distinction between the primitive type and Classes. int, float, char etc. are primitives, and the other data types other than the primitives are references. It is an interesting distinction to note, because of the differences in method calling system in different languages. Java makes a distinction in &amp;quot;calling-by-value&amp;quot; when a primitive is passed as a parameter, and &amp;quot;calling-by-reference&amp;quot; when an object is passed. In fact, if a primitive is passed, a call by value is invoked, but when a Class object is passed, only a reference is passed to the object. &lt;br /&gt;
&lt;br /&gt;
For a more language specific treatment of types and classes, you can refer: http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_6_ap &lt;br /&gt;
&lt;br /&gt;
==Discussion of Issues==&lt;br /&gt;
Okay, so you're about to write a program and you need to represent data somehow.  Should you use a primitive type?  What about a class?  There are several features that are handed to you with each.&lt;br /&gt;
&lt;br /&gt;
=== Primitive Types ===&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Simplicity =====&lt;br /&gt;
In strongly typed languages, primitive types are ideal for data which doesn't necessarily need to be partitioned into several smaller components.  If you are looking to store and represent a simple throw-away integer for looping, for example, there's little reason why one would want to construct a class for this purpose.&lt;br /&gt;
&lt;br /&gt;
Primitive types are also often times coupled with native operations, handed to you by the language.  For example, in Java, variables of type int are automatically given operations such as addition, subtraction, multiplication, and so on.  These operations work as follows:&lt;br /&gt;
# Receive both inputs&lt;br /&gt;
# Cast if necessary (for example, from an int to a double)&lt;br /&gt;
# Perform calculation&lt;br /&gt;
# Return result&lt;br /&gt;
&lt;br /&gt;
It is important to note that the primitive types themselves are left ''unchanged'', and the result is returned from the operation, giving the programmer the ability to place the result elsewhere.&lt;br /&gt;
&lt;br /&gt;
===== Efficiency =====&lt;br /&gt;
In efficiency-critical applications, primitive types and their operations are oftentimes mapped directly to hardware-supported equivalents, thus operations can be performed very quickly.  This style of downgrading the logic to more so the hardware level has been replaced over the years for general applications, since improvements to hardware components have eradicated the once-imperative necessity to program efficiently.  Another point of view concerning efficiency could be from development time: if the program one is writing doesn't require complex design, it would be quicker to use the language's built-in types instead of taking the time to design a class to do the same feature.&lt;br /&gt;
&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Single-state storage =====&lt;br /&gt;
One large disadvantages to primitive types are that they are generally capable of only holding a single dimension state.  This limitation requires the programmer to use other variables in conjunction if they desire to hold more than one field of data.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Since primitive types do not allow you to encapsulate your data, if you ever desire to change the behavior of your program, you are forced to manually check each use of the variable for enforcement.&lt;br /&gt;
&lt;br /&gt;
For example, suppose you have a system designed in Java that maintains an integer value which represents the number of books you have in a library.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
int numBooks;&lt;br /&gt;
...&lt;br /&gt;
numBooks = 0;&lt;br /&gt;
...&lt;br /&gt;
numBooks++;&lt;br /&gt;
...&lt;br /&gt;
numBooks--;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A few days later, you realize that you should probably refactor your system to maintain a log of when this variable updates.  You immediately face a problem since, as it is, your code directly manipulates a single-state type integer.  Without resorting to a more object-oriented solution, you would have to update each location in the code of where a change takes place in order to establish this bookkeeping (pun intended).&lt;br /&gt;
&amp;lt;code id=&amp;quot;bookKeeping&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public static void integerValueChanged(){&lt;br /&gt;
  // records that the value has been changed&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public static void main(String[]args){&lt;br /&gt;
  int numBooks;&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks = 0;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks++;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks--;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To generalize this concept, it is oftentimes necessary to modify &amp;quot;what happens&amp;quot; when something is updated, and this cannot be easily accomplished by merely using primitive types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Class Types ===&lt;br /&gt;
Classes to the rescue!  Classes give programmers the ability to construct complex data types that are also capable of defining their own operations, all while keeping the details and specifics black-boxed outsize of where the class will be used in the code.&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Multi-dimensional Storage =====&lt;br /&gt;
Contrasting to primitive types, classes allow programmers to couple a varying number of fields.  Grouping fields of data into a single class, then instantiating such an object and manipulating it is much more convenient than keeping track of several individual variables.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Oftentimes it is necessary to refactor a system to execute code when a change happens.  In object-land, we are able to do this through the ability to control what happens in our methods.&lt;br /&gt;
&lt;br /&gt;
Taking our [[#bookKeeping| example from above]], we can give a quick example of how a class could be defined to handle the situation much more elegantly.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public class RecordedNumber{&lt;br /&gt;
  // The integer value, kept concealed in the class&lt;br /&gt;
  private int value;&lt;br /&gt;
&lt;br /&gt;
  public RecordedNumber(int value){&lt;br /&gt;
    this.value = value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public int getValue(){&lt;br /&gt;
    return value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public void setValue(int newValue){&lt;br /&gt;
    // code to do any necessary recording.&lt;br /&gt;
    ...&lt;br /&gt;
    this.value = newValue;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class MyExample{&lt;br /&gt;
  public static void main(String[]args){&lt;br /&gt;
    RecordedNumber numBooks = new RecordedNumber(0);&lt;br /&gt;
    ...&lt;br /&gt;
    numBooks.setValue(4); // the object handles all necessary bookkeeping&lt;br /&gt;
    ...&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Code-reuse =====&lt;br /&gt;
Another nice feature to class-types encapsulate the concept surrounding code re-usability, especially in topics such as inheritance.  Classes allow the programmer to enhance an already existing class-type to be more specific, which in turn can prevent excessive code duplication.&lt;br /&gt;
&lt;br /&gt;
===== Application Structure =====&lt;br /&gt;
Designing an application in a object-oriented / class-specific style can reduce the challenges of designing and building a difficult system into merely making objects successfully interact.  It is from this concept that languages such as [http://en.wikipedia.org/wiki/Unified_Modeling_Language Unified Modeling Language (UML)] have been created, allowing software engineers to build around the notion of classes and their relationships to one another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Speed Considerations =====&lt;br /&gt;
In computational-intensive applications, objects built from classes tend to be less efficient than primitive data types built around procedural context.  This is due in part because of the object's creation, since it isn't supported directly hardware level.  Consideration is placed more so on good-design and coding-practices when implementing functionality around classes.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== B =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== C =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[1] http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html&lt;br /&gt;
&lt;br /&gt;
[2] Java:- Types, Values and Variables&lt;br /&gt;
    http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html&lt;br /&gt;
[3] Ruby Reflection ,http://www.khelll.com/blog/ruby/ruby-reflection/&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39296</id>
		<title>CSC/ECE 517 Fall 2010/ch3 4b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39296"/>
		<updated>2010-10-21T04:12:54Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Types vs Classes'''&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: lightgrey; border: solid thin #F2F2F2; padding: 5px;&amp;quot;&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.  This topic was covered three years ago (http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007), but all of the articles considered one language after the other, in a set of examples rather than a discussion of issues.  Make sure that you discuss the issues, using languages as examples rather than making language the primary means of organizing the chapter.&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Overall s.png|right|upright|Relationship between Type and Class]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
It is often that we talk about types, strongly typed, weakly typed, classes. To make it clear,  let us look into it clearly. Every programming language has a way to define a variable. A variable is a named address location which stores a particular value. &lt;br /&gt;
&lt;br /&gt;
[[Image:Connection s.png|right|Types can be thought of as the set of classes combined with primitive types given to a language.]]&lt;br /&gt;
&lt;br /&gt;
===Types===&lt;br /&gt;
&lt;br /&gt;
Time for an analogy? Imagine a variable to be a vacant house. It could have animals, humans, robots, or another smaller house, or whatever you can think of. There has to be a way, from a third party perspective, so as to be cognizant of the kind of things that reside in the house. Types and typing is a concept which realizes this concept. A typed language or a strongly typed language is one where the type of a variable has to be declared so as to avoid any wrong dealings of the value during run time. For example, Java is a strongly typed language. If I need to use two integers for addition, I would explicitly have to mention them as an integer:- &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  int integer1;&lt;br /&gt;
  int integer2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we can’t then re-initialize it to any other type in its defined scope.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  integer1 = “Hello World”;  // cannot map an int to a String&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the case of non-typed languages, say Ruby, or Visual Basic, etc. We don’t need to specify a type. &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  def variable1;&lt;br /&gt;
  def variable2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, it could be initialized with anything,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
as well as &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = “Good morning Vietnam”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
are allowed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Classes===&lt;br /&gt;
&lt;br /&gt;
A class is a “type” of variable specification. The difference between a class and a regular primitive integer, character, etc is that a class:-&lt;br /&gt;
&lt;br /&gt;
# consists of one or more primitive or non-primitive variables&lt;br /&gt;
# is a pre-defined structure&lt;br /&gt;
# defines methods which operate on the internal state of the object&lt;br /&gt;
&lt;br /&gt;
The Type of Class is “Class”, just like the Type of integer is “integer” in case of strongly typed languages. &lt;br /&gt;
&lt;br /&gt;
For example, in case of Java:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;“The types of the Java programming language are divided into two categories: primitive types and reference types. The primitive types are the boolean type and the numeric types. The numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double. The reference types are class types, interface types, and array types. There is also a special null type. An object is a dynamically created instance of a class type or a dynamically created array. The values of a reference type are references to objects. All objects, including arrays, support the methods of class Object . String literals are represented by String objects .” [2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, as mentioned before, in Java, there are two “Types”:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type:lower-roman&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Primitive Type&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Reference Type&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Classes, Interfaces, Arrays are all consolidations of Primitive types, so they just need to “point” to or reference the primitive ones, hence the name.&lt;br /&gt;
It is sometimes confusing and difficult to come up with a clear and robust distinction between Types and Classes. One might think &amp;quot;Class to be a Type of Type&amp;quot;. &lt;br /&gt;
It is however important to know that in strict Object Oriented Languages, Type is a union of Classes and Primitives. This rule, more or less consistent (with some deviations where primitives are treated as classes). &lt;br /&gt;
 &lt;br /&gt;
==Types and Classes in Languages==&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
Ruby claims to be a strong object oriented language. It is object oriented to the extent that every thing is an object. Primitive datatypes are objects, and we can make use of the object oriented techniques on even the primitives. As mentioned before, Ruby is a dynamic typed language, as the type is bound at compile time. Everything in Ruby has a class. Every class in Ruby is inherited from class Class. &lt;br /&gt;
&lt;br /&gt;
Type in Ruby is well defined as well. Using self inspection (reflection), we can find out whether a name is a Class, or a method. Let us see this in action:- &lt;br /&gt;
&lt;br /&gt;
The first thing that comes to a one’s mind is something like :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
&amp;quot;hello&amp;quot;.class #=&amp;gt; String&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
But have you thought of your class as an object? Well that seems odd, but that’s how ruby works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
class Foo;end  #=&amp;gt; nil&lt;br /&gt;
Foo.class #=&amp;gt; Class&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What does the above snippet of code mean exactly?&lt;br /&gt;
It means 2 things : Foo is a constant and that constant holds(refers to) an object of Class type.&lt;br /&gt;
&lt;br /&gt;
Let us prove that:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Foo = Class.new&lt;br /&gt;
(irb):8 warning: already initialized constant Foo&lt;br /&gt;
=&amp;gt; Foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
As you can see, we got a warning because we tried to initialize the constant Foo again.&lt;br /&gt;
&lt;br /&gt;
So ,when you define some class ‘Foo’ in ruby, all you are doing is:&lt;br /&gt;
1-instantiating an object of type Class.&lt;br /&gt;
2-initializing a constant Foo that refers to that created object .&lt;br /&gt;
&lt;br /&gt;
So, when we say “object” ,then we do mean any object; an object of Class type, or any object of any type.[3]&lt;br /&gt;
&lt;br /&gt;
===Java===&lt;br /&gt;
&lt;br /&gt;
As mentioned before, Java is a strongly typed language. The type of data needs to be declared before using. The types of &amp;quot;types&amp;quot; in Java are :&lt;br /&gt;
   * Primitive Types:-  boolean and numeric. The numeric types are the integral types byte, short, int, long, and char, and the         &lt;br /&gt;
     floating-point types float and double. &lt;br /&gt;
   * Reference Types:- class types, interface types and array types. [2] &lt;br /&gt;
&lt;br /&gt;
Java is an object-oriented language, but it does make a clear distinction between the primitive type and Classes. int, float, char etc. are primitives, and the other data types other than the primitives are references. It is an interesting distinction to note, because of the differences in method calling system in different languages. Java makes a distinction in &amp;quot;calling-by-value&amp;quot; when a primitive is passed as a parameter, and &amp;quot;calling-by-reference&amp;quot; when an object is passed. In fact, if a primitive is passed, a call by value is invoked, but when a Class object is passed, only a reference is passed to the object. &lt;br /&gt;
&lt;br /&gt;
For a more language specific treatment of types and classes, you can refer: http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_6_ap &lt;br /&gt;
&lt;br /&gt;
==Discussion of Issues==&lt;br /&gt;
Okay, so you're about to write a program and you need to represent data somehow.  Should you use a primitive type?  What about a class?  There are several features that are handed to you with each.&lt;br /&gt;
&lt;br /&gt;
=== Primitive Types ===&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Simplicity =====&lt;br /&gt;
In strongly typed languages, primitive types are ideal for data which doesn't necessarily need to be partitioned into several smaller components.  If you are looking to store and represent a simple throw-away integer for looping, for example, there's little reason why one would want to construct a class for this purpose.&lt;br /&gt;
&lt;br /&gt;
Primitive types are also often times coupled with native operations, handed to you by the language.  For example, in Java, variables of type int are automatically given operations such as addition, subtraction, multiplication, and so on.  These operations work as follows:&lt;br /&gt;
# Receive both inputs&lt;br /&gt;
# Cast if necessary (for example, from an int to a double)&lt;br /&gt;
# Perform calculation&lt;br /&gt;
# Return result&lt;br /&gt;
&lt;br /&gt;
It is important to note that the primitive types themselves are left ''unchanged'', and the result is returned from the operation, giving the programmer the ability to place the result elsewhere.&lt;br /&gt;
&lt;br /&gt;
===== Efficiency =====&lt;br /&gt;
In efficiency-critical applications, primitive types and their operations are oftentimes mapped directly to hardware-supported equivalents, thus operations can be performed very quickly.  This style of downgrading the logic to more so the hardware level has been replaced over the years for general applications, since improvements to hardware components have eradicated the once-imperative necessity to program efficiently.  Another point of view concerning efficiency could be from development time: if the program one is writing doesn't require complex design, it would be quicker to use the language's built-in types instead of taking the time to design a class to do the same feature.&lt;br /&gt;
&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Single-state storage =====&lt;br /&gt;
One large disadvantages to primitive types are that they are generally capable of only holding a single dimension state.  This limitation requires the programmer to use other variables in conjunction if they desire to hold more than one field of data.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Since primitive types do not allow you to encapsulate your data, if you ever desire to change the behavior of your program, you are forced to manually check each use of the variable for enforcement.&lt;br /&gt;
&lt;br /&gt;
For example, suppose you have a system designed in Java that maintains an integer value which represents the number of books you have in a library.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
int numBooks;&lt;br /&gt;
...&lt;br /&gt;
numBooks = 0;&lt;br /&gt;
...&lt;br /&gt;
numBooks++;&lt;br /&gt;
...&lt;br /&gt;
numBooks--;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A few days later, you realize that you should probably refactor your system to maintain a log of when this variable updates.  You immediately face a problem since, as it is, your code directly manipulates a single-state type integer.  Without resorting to a more object-oriented solution, you would have to update each location in the code of where a change takes place in order to establish this bookkeeping (pun intended).&lt;br /&gt;
&amp;lt;code id=&amp;quot;bookKeeping&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public static void integerValueChanged(){&lt;br /&gt;
  // records that the value has been changed&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public static void main(String[]args){&lt;br /&gt;
  int numBooks;&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks = 0;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks++;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks--;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To generalize this concept, it is oftentimes necessary to modify &amp;quot;what happens&amp;quot; when something is updated, and this cannot be easily accomplished by merely using primitive types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Class Types ===&lt;br /&gt;
Classes to the rescue!  Classes give programmers the ability to construct complex data types that are also capable of defining their own operations, all while keeping the details and specifics black-boxed outsize of where the class will be used in the code.&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Multi-dimensional Storage =====&lt;br /&gt;
Contrasting to primitive types, classes allow programmers to couple a varying number of fields.  Grouping fields of data into a single class, then instantiating such an object and manipulating it is much more convenient than keeping track of several individual variables.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Oftentimes it is necessary to refactor a system to execute code when a change happens.  In object-land, we are able to do this through the ability to control what happens in our methods.&lt;br /&gt;
&lt;br /&gt;
Taking our [[#bookKeeping| example from above]], we can give a quick example of how a class could be defined to handle the situation much more elegantly.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public class RecordedNumber{&lt;br /&gt;
  // The integer value, kept concealed in the class&lt;br /&gt;
  private int value;&lt;br /&gt;
&lt;br /&gt;
  public RecordedNumber(int value){&lt;br /&gt;
    this.value = value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public int getValue(){&lt;br /&gt;
    return value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public void setValue(int newValue){&lt;br /&gt;
    // code to do any necessary recording.&lt;br /&gt;
    ...&lt;br /&gt;
    this.value = newValue;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class MyExample{&lt;br /&gt;
  public static void main(String[]args){&lt;br /&gt;
    RecordedNumber numBooks = new RecordedNumber(0);&lt;br /&gt;
    ...&lt;br /&gt;
    numBooks.setValue(4); // the object handles all necessary bookkeeping&lt;br /&gt;
    ...&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Code-reuse =====&lt;br /&gt;
Another nice feature to class-types encapsulate the concept surrounding code re-usability, especially in topics such as inheritance.  Classes allow the programmer to enhance an already existing class-type to be more specific, which in turn can prevent excessive code duplication.&lt;br /&gt;
&lt;br /&gt;
===== Application Structure =====&lt;br /&gt;
Designing an application in a object-oriented / class-specific style can reduce the challenges of designing and building a difficult system into merely making objects successfully interact.  It is from this concept that languages such as [http://en.wikipedia.org/wiki/Unified_Modeling_Language Unified Modeling Language (UML)] have been created, allowing software engineers to build around the notion of classes and their relationships to one another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Speed Considerations =====&lt;br /&gt;
In computational-intensive applications, objects built from classes tend to be less efficient than primitive data types built around procedural context.  This is due in part because of the object's creation, since it isn't supported directly hardware level.  Consideration is placed more so on good-design and coding-practices when implementing functionality around classes.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== B =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== C =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[1] http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html&lt;br /&gt;
&lt;br /&gt;
[2] Java:- Types, Values and Variables&lt;br /&gt;
    http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html&lt;br /&gt;
[3] Ruby Reflection ,http://www.khelll.com/blog/ruby/ruby-reflection/&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39290</id>
		<title>CSC/ECE 517 Fall 2010/ch3 4b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39290"/>
		<updated>2010-10-21T04:10:29Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Types vs Classes'''&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: lightgrey; border: solid thin grey; padding: 5px;&amp;quot;&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.  This topic was covered three years ago (http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007), but all of the articles considered one language after the other, in a set of examples rather than a discussion of issues.  Make sure that you discuss the issues, using languages as examples rather than making language the primary means of organizing the chapter.&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Overall s.png|right|upright|Relationship between Type and Class]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
It is often that we talk about types, strongly typed, weakly typed, classes. To make it clear,  let us look into it clearly. Every programming language has a way to define a variable. A variable is a named address location which stores a particular value. &lt;br /&gt;
&lt;br /&gt;
[[Image:Connection s.png|right|Types can be thought of as the set of classes combined with primitive types given to a language.]]&lt;br /&gt;
&lt;br /&gt;
===Types===&lt;br /&gt;
&lt;br /&gt;
Time for an analogy? Imagine a variable to be a vacant house. It could have animals, humans, robots, or another smaller house, or whatever you can think of. There has to be a way, from a third party perspective, so as to be cognizant of the kind of things that reside in the house. Types and typing is a concept which realizes this concept. A typed language or a strongly typed language is one where the type of a variable has to be declared so as to avoid any wrong dealings of the value during run time. For example, Java is a strongly typed language. If I need to use two integers for addition, I would explicitly have to mention them as an integer:- &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  int integer1;&lt;br /&gt;
  int integer2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we can’t then re-initialize it to any other type in its defined scope.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  integer1 = “Hello World”;  // cannot map an int to a String&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the case of non-typed languages, say Ruby, or Visual Basic, etc. We don’t need to specify a type. &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  def variable1;&lt;br /&gt;
  def variable2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, it could be initialized with anything,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
as well as &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = “Good morning Vietnam”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
are allowed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Classes===&lt;br /&gt;
&lt;br /&gt;
A class is a “type” of variable specification. The difference between a class and a regular primitive integer, character, etc is that a class:-&lt;br /&gt;
&lt;br /&gt;
# consists of one or more primitive or non-primitive variables&lt;br /&gt;
# is a pre-defined structure&lt;br /&gt;
# defines methods which operate on the internal state of the object&lt;br /&gt;
&lt;br /&gt;
The Type of Class is “Class”, just like the Type of integer is “integer” in case of strongly typed languages. &lt;br /&gt;
&lt;br /&gt;
For example, in case of Java:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;“The types of the Java programming language are divided into two categories: primitive types and reference types. The primitive types are the boolean type and the numeric types. The numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double. The reference types are class types, interface types, and array types. There is also a special null type. An object is a dynamically created instance of a class type or a dynamically created array. The values of a reference type are references to objects. All objects, including arrays, support the methods of class Object . String literals are represented by String objects .” [2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, as mentioned before, in Java, there are two “Types”:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type:lower-roman&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Primitive Type&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Reference Type&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Classes, Interfaces, Arrays are all consolidations of Primitive types, so they just need to “point” to or reference the primitive ones, hence the name.&lt;br /&gt;
It is sometimes confusing and difficult to come up with a clear and robust distinction between Types and Classes. One might think &amp;quot;Class to be a Type of Type&amp;quot;. &lt;br /&gt;
It is however important to know that in strict Object Oriented Languages, Type is a union of Classes and Primitives. This rule, more or less consistent (with some deviations where primitives are treated as classes). &lt;br /&gt;
 &lt;br /&gt;
==Types and Classes in Languages==&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
Ruby claims to be a strong object oriented language. It is object oriented to the extent that every thing is an object. Primitive datatypes are objects, and we can make use of the object oriented techniques on even the primitives. As mentioned before, Ruby is a dynamic typed language, as the type is bound at compile time. Everything in Ruby has a class. Every class in Ruby is inherited from class Class. &lt;br /&gt;
&lt;br /&gt;
Type in Ruby is well defined as well. Using self inspection (reflection), we can find out whether a name is a Class, or a method. Let us see this in action:- &lt;br /&gt;
&lt;br /&gt;
The first thing that comes to a one’s mind is something like :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
&amp;quot;hello&amp;quot;.class #=&amp;gt; String&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
But have you thought of your class as an object? Well that seems odd, but that’s how ruby works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
class Foo;end  #=&amp;gt; nil&lt;br /&gt;
Foo.class #=&amp;gt; Class&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What does the above snippet of code mean exactly?&lt;br /&gt;
It means 2 things : Foo is a constant and that constant holds(refers to) an object of Class type.&lt;br /&gt;
&lt;br /&gt;
Let us prove that:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Foo = Class.new&lt;br /&gt;
(irb):8 warning: already initialized constant Foo&lt;br /&gt;
=&amp;gt; Foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
As you can see, we got a warning because we tried to initialize the constant Foo again.&lt;br /&gt;
&lt;br /&gt;
So ,when you define some class ‘Foo’ in ruby, all you are doing is:&lt;br /&gt;
1-instantiating an object of type Class.&lt;br /&gt;
2-initializing a constant Foo that refers to that created object .&lt;br /&gt;
&lt;br /&gt;
So, when we say “object” ,then we do mean any object; an object of Class type, or any object of any type.[3]&lt;br /&gt;
&lt;br /&gt;
===Java===&lt;br /&gt;
&lt;br /&gt;
As mentioned before, Java is a strongly typed language. The type of data needs to be declared before using. The types of &amp;quot;types&amp;quot; in Java are :&lt;br /&gt;
   * Primitive Types:-  boolean and numeric. The numeric types are the integral types byte, short, int, long, and char, and the         &lt;br /&gt;
     floating-point types float and double. &lt;br /&gt;
   * Reference Types:- class types, interface types and array types. [2] &lt;br /&gt;
&lt;br /&gt;
Java is an object-oriented language, but it does make a clear distinction between the primitive type and Classes. int, float, char etc. are primitives, and the other data types other than the primitives are references. It is an interesting distinction to note, because of the differences in method calling system in different languages. Java makes a distinction in &amp;quot;calling-by-value&amp;quot; when a primitive is passed as a parameter, and &amp;quot;calling-by-reference&amp;quot; when an object is passed. In fact, if a primitive is passed, a call by value is invoked, but when a Class object is passed, only a reference is passed to the object. &lt;br /&gt;
&lt;br /&gt;
For a more language specific treatment of types and classes, you can refer: http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_6_ap &lt;br /&gt;
&lt;br /&gt;
==Discussion of Issues==&lt;br /&gt;
Okay, so you're about to write a program and you need to represent data somehow.  Should you use a primitive type?  What about a class?  There are several features that are handed to you with each.&lt;br /&gt;
&lt;br /&gt;
=== Primitive Types ===&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Simplicity =====&lt;br /&gt;
In strongly typed languages, primitive types are ideal for data which doesn't necessarily need to be partitioned into several smaller components.  If you are looking to store and represent a simple throw-away integer for looping, for example, there's little reason why one would want to construct a class for this purpose.&lt;br /&gt;
&lt;br /&gt;
Primitive types are also often times coupled with native operations, handed to you by the language.  For example, in Java, variables of type int are automatically given operations such as addition, subtraction, multiplication, and so on.  These operations work as follows:&lt;br /&gt;
# Receive both inputs&lt;br /&gt;
# Cast if necessary (for example, from an int to a double)&lt;br /&gt;
# Perform calculation&lt;br /&gt;
# Return result&lt;br /&gt;
&lt;br /&gt;
It is important to note that the primitive types themselves are left ''unchanged'', and the result is returned from the operation, giving the programmer the ability to place the result elsewhere.&lt;br /&gt;
&lt;br /&gt;
===== Efficiency =====&lt;br /&gt;
In efficiency-critical applications, primitive types and their operations are oftentimes mapped directly to hardware-supported equivalents, thus operations can be performed very quickly.  This style of downgrading the logic to more so the hardware level has been replaced over the years for general applications, since improvements to hardware components have eradicated the once-imperative necessity to program efficiently.  Another point of view concerning efficiency could be from development time: if the program one is writing doesn't require complex design, it would be quicker to use the language's built-in types instead of taking the time to design a class to do the same feature.&lt;br /&gt;
&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Single-state storage =====&lt;br /&gt;
One large disadvantages to primitive types are that they are generally capable of only holding a single dimension state.  This limitation requires the programmer to use other variables in conjunction if they desire to hold more than one field of data.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Since primitive types do not allow you to encapsulate your data, if you ever desire to change the behavior of your program, you are forced to manually check each use of the variable for enforcement.&lt;br /&gt;
&lt;br /&gt;
For example, suppose you have a system designed in Java that maintains an integer value which represents the number of books you have in a library.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
int numBooks;&lt;br /&gt;
...&lt;br /&gt;
numBooks = 0;&lt;br /&gt;
...&lt;br /&gt;
numBooks++;&lt;br /&gt;
...&lt;br /&gt;
numBooks--;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A few days later, you realize that you should probably refactor your system to maintain a log of when this variable updates.  You immediately face a problem since, as it is, your code directly manipulates a single-state type integer.  Without resorting to a more object-oriented solution, you would have to update each location in the code of where a change takes place in order to establish this bookkeeping (pun intended).&lt;br /&gt;
&amp;lt;code id=&amp;quot;bookKeeping&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public static void integerValueChanged(){&lt;br /&gt;
  // records that the value has been changed&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public static void main(String[]args){&lt;br /&gt;
  int numBooks;&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks = 0;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks++;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks--;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To generalize this concept, it is oftentimes necessary to modify &amp;quot;what happens&amp;quot; when something is updated, and this cannot be easily accomplished by merely using primitive types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Class Types ===&lt;br /&gt;
Classes to the rescue!  Classes give programmers the ability to construct complex data types that are also capable of defining their own operations, all while keeping the details and specifics black-boxed outsize of where the class will be used in the code.&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Multi-dimensional Storage =====&lt;br /&gt;
Contrasting to primitive types, classes allow programmers to couple a varying number of fields.  Grouping fields of data into a single class, then instantiating such an object and manipulating it is much more convenient than keeping track of several individual variables.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Oftentimes it is necessary to refactor a system to execute code when a change happens.  In object-land, we are able to do this through the ability to control what happens in our methods.&lt;br /&gt;
&lt;br /&gt;
Taking our [[#bookKeeping| example from above]], we can give a quick example of how a class could be defined to handle the situation much more elegantly.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public class RecordedNumber{&lt;br /&gt;
  // The integer value, kept concealed in the class&lt;br /&gt;
  private int value;&lt;br /&gt;
&lt;br /&gt;
  public RecordedNumber(int value){&lt;br /&gt;
    this.value = value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public int getValue(){&lt;br /&gt;
    return value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public void setValue(int newValue){&lt;br /&gt;
    // code to do any necessary recording.&lt;br /&gt;
    ...&lt;br /&gt;
    this.value = newValue;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class MyExample{&lt;br /&gt;
  public static void main(String[]args){&lt;br /&gt;
    RecordedNumber numBooks = new RecordedNumber(0);&lt;br /&gt;
    ...&lt;br /&gt;
    numBooks.setValue(4); // the object handles all necessary bookkeeping&lt;br /&gt;
    ...&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Code-reuse =====&lt;br /&gt;
Another nice feature to class-types encapsulate the concept surrounding code re-usability, especially in topics such as inheritance.  Classes allow the programmer to enhance an already existing class-type to be more specific, which in turn can prevent excessive code duplication.&lt;br /&gt;
&lt;br /&gt;
===== Application Structure =====&lt;br /&gt;
Designing an application in a object-oriented / class-specific style can reduce the challenges of designing and building a difficult system into merely making objects successfully interact.  It is from this concept that languages such as [http://en.wikipedia.org/wiki/Unified_Modeling_Language Unified Modeling Language (UML)] have been created, allowing software engineers to build around the notion of classes and their relationships to one another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Speed Considerations =====&lt;br /&gt;
In computational-intensive applications, objects built from classes tend to be less efficient than primitive data types built around procedural context.  This is due in part because of the object's creation, since it isn't supported directly hardware level.  Consideration is placed more so on good-design and coding-practices when implementing functionality around classes.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== B =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== C =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[1] http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html&lt;br /&gt;
&lt;br /&gt;
[2] Java:- Types, Values and Variables&lt;br /&gt;
    http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html&lt;br /&gt;
[3] Ruby Reflection ,http://www.khelll.com/blog/ruby/ruby-reflection/&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39289</id>
		<title>CSC/ECE 517 Fall 2010/ch3 4b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39289"/>
		<updated>2010-10-21T04:10:17Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Types vs Classes'''&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: lightgrey; border: solid thin grey; padding: 20px;&amp;quot;&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.  This topic was covered three years ago (http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007), but all of the articles considered one language after the other, in a set of examples rather than a discussion of issues.  Make sure that you discuss the issues, using languages as examples rather than making language the primary means of organizing the chapter.&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Overall s.png|right|upright|Relationship between Type and Class]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
It is often that we talk about types, strongly typed, weakly typed, classes. To make it clear,  let us look into it clearly. Every programming language has a way to define a variable. A variable is a named address location which stores a particular value. &lt;br /&gt;
&lt;br /&gt;
[[Image:Connection s.png|right|Types can be thought of as the set of classes combined with primitive types given to a language.]]&lt;br /&gt;
&lt;br /&gt;
===Types===&lt;br /&gt;
&lt;br /&gt;
Time for an analogy? Imagine a variable to be a vacant house. It could have animals, humans, robots, or another smaller house, or whatever you can think of. There has to be a way, from a third party perspective, so as to be cognizant of the kind of things that reside in the house. Types and typing is a concept which realizes this concept. A typed language or a strongly typed language is one where the type of a variable has to be declared so as to avoid any wrong dealings of the value during run time. For example, Java is a strongly typed language. If I need to use two integers for addition, I would explicitly have to mention them as an integer:- &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  int integer1;&lt;br /&gt;
  int integer2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we can’t then re-initialize it to any other type in its defined scope.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  integer1 = “Hello World”;  // cannot map an int to a String&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the case of non-typed languages, say Ruby, or Visual Basic, etc. We don’t need to specify a type. &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  def variable1;&lt;br /&gt;
  def variable2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, it could be initialized with anything,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
as well as &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = “Good morning Vietnam”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
are allowed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Classes===&lt;br /&gt;
&lt;br /&gt;
A class is a “type” of variable specification. The difference between a class and a regular primitive integer, character, etc is that a class:-&lt;br /&gt;
&lt;br /&gt;
# consists of one or more primitive or non-primitive variables&lt;br /&gt;
# is a pre-defined structure&lt;br /&gt;
# defines methods which operate on the internal state of the object&lt;br /&gt;
&lt;br /&gt;
The Type of Class is “Class”, just like the Type of integer is “integer” in case of strongly typed languages. &lt;br /&gt;
&lt;br /&gt;
For example, in case of Java:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;“The types of the Java programming language are divided into two categories: primitive types and reference types. The primitive types are the boolean type and the numeric types. The numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double. The reference types are class types, interface types, and array types. There is also a special null type. An object is a dynamically created instance of a class type or a dynamically created array. The values of a reference type are references to objects. All objects, including arrays, support the methods of class Object . String literals are represented by String objects .” [2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, as mentioned before, in Java, there are two “Types”:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type:lower-roman&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Primitive Type&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Reference Type&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Classes, Interfaces, Arrays are all consolidations of Primitive types, so they just need to “point” to or reference the primitive ones, hence the name.&lt;br /&gt;
It is sometimes confusing and difficult to come up with a clear and robust distinction between Types and Classes. One might think &amp;quot;Class to be a Type of Type&amp;quot;. &lt;br /&gt;
It is however important to know that in strict Object Oriented Languages, Type is a union of Classes and Primitives. This rule, more or less consistent (with some deviations where primitives are treated as classes). &lt;br /&gt;
 &lt;br /&gt;
==Types and Classes in Languages==&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
Ruby claims to be a strong object oriented language. It is object oriented to the extent that every thing is an object. Primitive datatypes are objects, and we can make use of the object oriented techniques on even the primitives. As mentioned before, Ruby is a dynamic typed language, as the type is bound at compile time. Everything in Ruby has a class. Every class in Ruby is inherited from class Class. &lt;br /&gt;
&lt;br /&gt;
Type in Ruby is well defined as well. Using self inspection (reflection), we can find out whether a name is a Class, or a method. Let us see this in action:- &lt;br /&gt;
&lt;br /&gt;
The first thing that comes to a one’s mind is something like :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
&amp;quot;hello&amp;quot;.class #=&amp;gt; String&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
But have you thought of your class as an object? Well that seems odd, but that’s how ruby works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
class Foo;end  #=&amp;gt; nil&lt;br /&gt;
Foo.class #=&amp;gt; Class&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What does the above snippet of code mean exactly?&lt;br /&gt;
It means 2 things : Foo is a constant and that constant holds(refers to) an object of Class type.&lt;br /&gt;
&lt;br /&gt;
Let us prove that:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Foo = Class.new&lt;br /&gt;
(irb):8 warning: already initialized constant Foo&lt;br /&gt;
=&amp;gt; Foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
As you can see, we got a warning because we tried to initialize the constant Foo again.&lt;br /&gt;
&lt;br /&gt;
So ,when you define some class ‘Foo’ in ruby, all you are doing is:&lt;br /&gt;
1-instantiating an object of type Class.&lt;br /&gt;
2-initializing a constant Foo that refers to that created object .&lt;br /&gt;
&lt;br /&gt;
So, when we say “object” ,then we do mean any object; an object of Class type, or any object of any type.[3]&lt;br /&gt;
&lt;br /&gt;
===Java===&lt;br /&gt;
&lt;br /&gt;
As mentioned before, Java is a strongly typed language. The type of data needs to be declared before using. The types of &amp;quot;types&amp;quot; in Java are :&lt;br /&gt;
   * Primitive Types:-  boolean and numeric. The numeric types are the integral types byte, short, int, long, and char, and the         &lt;br /&gt;
     floating-point types float and double. &lt;br /&gt;
   * Reference Types:- class types, interface types and array types. [2] &lt;br /&gt;
&lt;br /&gt;
Java is an object-oriented language, but it does make a clear distinction between the primitive type and Classes. int, float, char etc. are primitives, and the other data types other than the primitives are references. It is an interesting distinction to note, because of the differences in method calling system in different languages. Java makes a distinction in &amp;quot;calling-by-value&amp;quot; when a primitive is passed as a parameter, and &amp;quot;calling-by-reference&amp;quot; when an object is passed. In fact, if a primitive is passed, a call by value is invoked, but when a Class object is passed, only a reference is passed to the object. &lt;br /&gt;
&lt;br /&gt;
For a more language specific treatment of types and classes, you can refer: http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_6_ap &lt;br /&gt;
&lt;br /&gt;
==Discussion of Issues==&lt;br /&gt;
Okay, so you're about to write a program and you need to represent data somehow.  Should you use a primitive type?  What about a class?  There are several features that are handed to you with each.&lt;br /&gt;
&lt;br /&gt;
=== Primitive Types ===&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Simplicity =====&lt;br /&gt;
In strongly typed languages, primitive types are ideal for data which doesn't necessarily need to be partitioned into several smaller components.  If you are looking to store and represent a simple throw-away integer for looping, for example, there's little reason why one would want to construct a class for this purpose.&lt;br /&gt;
&lt;br /&gt;
Primitive types are also often times coupled with native operations, handed to you by the language.  For example, in Java, variables of type int are automatically given operations such as addition, subtraction, multiplication, and so on.  These operations work as follows:&lt;br /&gt;
# Receive both inputs&lt;br /&gt;
# Cast if necessary (for example, from an int to a double)&lt;br /&gt;
# Perform calculation&lt;br /&gt;
# Return result&lt;br /&gt;
&lt;br /&gt;
It is important to note that the primitive types themselves are left ''unchanged'', and the result is returned from the operation, giving the programmer the ability to place the result elsewhere.&lt;br /&gt;
&lt;br /&gt;
===== Efficiency =====&lt;br /&gt;
In efficiency-critical applications, primitive types and their operations are oftentimes mapped directly to hardware-supported equivalents, thus operations can be performed very quickly.  This style of downgrading the logic to more so the hardware level has been replaced over the years for general applications, since improvements to hardware components have eradicated the once-imperative necessity to program efficiently.  Another point of view concerning efficiency could be from development time: if the program one is writing doesn't require complex design, it would be quicker to use the language's built-in types instead of taking the time to design a class to do the same feature.&lt;br /&gt;
&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Single-state storage =====&lt;br /&gt;
One large disadvantages to primitive types are that they are generally capable of only holding a single dimension state.  This limitation requires the programmer to use other variables in conjunction if they desire to hold more than one field of data.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Since primitive types do not allow you to encapsulate your data, if you ever desire to change the behavior of your program, you are forced to manually check each use of the variable for enforcement.&lt;br /&gt;
&lt;br /&gt;
For example, suppose you have a system designed in Java that maintains an integer value which represents the number of books you have in a library.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
int numBooks;&lt;br /&gt;
...&lt;br /&gt;
numBooks = 0;&lt;br /&gt;
...&lt;br /&gt;
numBooks++;&lt;br /&gt;
...&lt;br /&gt;
numBooks--;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A few days later, you realize that you should probably refactor your system to maintain a log of when this variable updates.  You immediately face a problem since, as it is, your code directly manipulates a single-state type integer.  Without resorting to a more object-oriented solution, you would have to update each location in the code of where a change takes place in order to establish this bookkeeping (pun intended).&lt;br /&gt;
&amp;lt;code id=&amp;quot;bookKeeping&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public static void integerValueChanged(){&lt;br /&gt;
  // records that the value has been changed&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public static void main(String[]args){&lt;br /&gt;
  int numBooks;&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks = 0;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks++;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks--;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To generalize this concept, it is oftentimes necessary to modify &amp;quot;what happens&amp;quot; when something is updated, and this cannot be easily accomplished by merely using primitive types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Class Types ===&lt;br /&gt;
Classes to the rescue!  Classes give programmers the ability to construct complex data types that are also capable of defining their own operations, all while keeping the details and specifics black-boxed outsize of where the class will be used in the code.&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Multi-dimensional Storage =====&lt;br /&gt;
Contrasting to primitive types, classes allow programmers to couple a varying number of fields.  Grouping fields of data into a single class, then instantiating such an object and manipulating it is much more convenient than keeping track of several individual variables.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Oftentimes it is necessary to refactor a system to execute code when a change happens.  In object-land, we are able to do this through the ability to control what happens in our methods.&lt;br /&gt;
&lt;br /&gt;
Taking our [[#bookKeeping| example from above]], we can give a quick example of how a class could be defined to handle the situation much more elegantly.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public class RecordedNumber{&lt;br /&gt;
  // The integer value, kept concealed in the class&lt;br /&gt;
  private int value;&lt;br /&gt;
&lt;br /&gt;
  public RecordedNumber(int value){&lt;br /&gt;
    this.value = value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public int getValue(){&lt;br /&gt;
    return value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public void setValue(int newValue){&lt;br /&gt;
    // code to do any necessary recording.&lt;br /&gt;
    ...&lt;br /&gt;
    this.value = newValue;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class MyExample{&lt;br /&gt;
  public static void main(String[]args){&lt;br /&gt;
    RecordedNumber numBooks = new RecordedNumber(0);&lt;br /&gt;
    ...&lt;br /&gt;
    numBooks.setValue(4); // the object handles all necessary bookkeeping&lt;br /&gt;
    ...&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Code-reuse =====&lt;br /&gt;
Another nice feature to class-types encapsulate the concept surrounding code re-usability, especially in topics such as inheritance.  Classes allow the programmer to enhance an already existing class-type to be more specific, which in turn can prevent excessive code duplication.&lt;br /&gt;
&lt;br /&gt;
===== Application Structure =====&lt;br /&gt;
Designing an application in a object-oriented / class-specific style can reduce the challenges of designing and building a difficult system into merely making objects successfully interact.  It is from this concept that languages such as [http://en.wikipedia.org/wiki/Unified_Modeling_Language Unified Modeling Language (UML)] have been created, allowing software engineers to build around the notion of classes and their relationships to one another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Speed Considerations =====&lt;br /&gt;
In computational-intensive applications, objects built from classes tend to be less efficient than primitive data types built around procedural context.  This is due in part because of the object's creation, since it isn't supported directly hardware level.  Consideration is placed more so on good-design and coding-practices when implementing functionality around classes.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== B =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== C =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[1] http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html&lt;br /&gt;
&lt;br /&gt;
[2] Java:- Types, Values and Variables&lt;br /&gt;
    http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html&lt;br /&gt;
[3] Ruby Reflection ,http://www.khelll.com/blog/ruby/ruby-reflection/&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39287</id>
		<title>CSC/ECE 517 Fall 2010/ch3 4b mt</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch3_4b_mt&amp;diff=39287"/>
		<updated>2010-10-21T04:10:02Z</updated>

		<summary type="html">&lt;p&gt;Grepper: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Types vs Classes'''&lt;br /&gt;
&amp;lt;blockquote style=&amp;quot;background-color: lightgrey; border: solid thin grey; margin: 20px;&amp;quot;&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.  This topic was covered three years ago (http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007), but all of the articles considered one language after the other, in a set of examples rather than a discussion of issues.  Make sure that you discuss the issues, using languages as examples rather than making language the primary means of organizing the chapter.&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Overall s.png|right|upright|Relationship between Type and Class]]&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
It is often that we talk about types, strongly typed, weakly typed, classes. To make it clear,  let us look into it clearly. Every programming language has a way to define a variable. A variable is a named address location which stores a particular value. &lt;br /&gt;
&lt;br /&gt;
[[Image:Connection s.png|right|Types can be thought of as the set of classes combined with primitive types given to a language.]]&lt;br /&gt;
&lt;br /&gt;
===Types===&lt;br /&gt;
&lt;br /&gt;
Time for an analogy? Imagine a variable to be a vacant house. It could have animals, humans, robots, or another smaller house, or whatever you can think of. There has to be a way, from a third party perspective, so as to be cognizant of the kind of things that reside in the house. Types and typing is a concept which realizes this concept. A typed language or a strongly typed language is one where the type of a variable has to be declared so as to avoid any wrong dealings of the value during run time. For example, Java is a strongly typed language. If I need to use two integers for addition, I would explicitly have to mention them as an integer:- &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  int integer1;&lt;br /&gt;
  int integer2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, we can’t then re-initialize it to any other type in its defined scope.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  integer1 = “Hello World”;  // cannot map an int to a String&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the case of non-typed languages, say Ruby, or Visual Basic, etc. We don’t need to specify a type. &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  def variable1;&lt;br /&gt;
  def variable2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, it could be initialized with anything,&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
as well as &lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
variable1 = “Good morning Vietnam”&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
are allowed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Classes===&lt;br /&gt;
&lt;br /&gt;
A class is a “type” of variable specification. The difference between a class and a regular primitive integer, character, etc is that a class:-&lt;br /&gt;
&lt;br /&gt;
# consists of one or more primitive or non-primitive variables&lt;br /&gt;
# is a pre-defined structure&lt;br /&gt;
# defines methods which operate on the internal state of the object&lt;br /&gt;
&lt;br /&gt;
The Type of Class is “Class”, just like the Type of integer is “integer” in case of strongly typed languages. &lt;br /&gt;
&lt;br /&gt;
For example, in case of Java:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;“The types of the Java programming language are divided into two categories: primitive types and reference types. The primitive types are the boolean type and the numeric types. The numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double. The reference types are class types, interface types, and array types. There is also a special null type. An object is a dynamically created instance of a class type or a dynamically created array. The values of a reference type are references to objects. All objects, including arrays, support the methods of class Object . String literals are represented by String objects .” [2]&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, as mentioned before, in Java, there are two “Types”:- &lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type:lower-roman&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Primitive Type&amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;Reference Type&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Classes, Interfaces, Arrays are all consolidations of Primitive types, so they just need to “point” to or reference the primitive ones, hence the name.&lt;br /&gt;
It is sometimes confusing and difficult to come up with a clear and robust distinction between Types and Classes. One might think &amp;quot;Class to be a Type of Type&amp;quot;. &lt;br /&gt;
It is however important to know that in strict Object Oriented Languages, Type is a union of Classes and Primitives. This rule, more or less consistent (with some deviations where primitives are treated as classes). &lt;br /&gt;
 &lt;br /&gt;
==Types and Classes in Languages==&lt;br /&gt;
===Ruby===&lt;br /&gt;
&lt;br /&gt;
Ruby claims to be a strong object oriented language. It is object oriented to the extent that every thing is an object. Primitive datatypes are objects, and we can make use of the object oriented techniques on even the primitives. As mentioned before, Ruby is a dynamic typed language, as the type is bound at compile time. Everything in Ruby has a class. Every class in Ruby is inherited from class Class. &lt;br /&gt;
&lt;br /&gt;
Type in Ruby is well defined as well. Using self inspection (reflection), we can find out whether a name is a Class, or a method. Let us see this in action:- &lt;br /&gt;
&lt;br /&gt;
The first thing that comes to a one’s mind is something like :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
&amp;quot;hello&amp;quot;.class #=&amp;gt; String&lt;br /&gt;
  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
But have you thought of your class as an object? Well that seems odd, but that’s how ruby works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
5.class #=&amp;gt; Fixnum&lt;br /&gt;
class Foo;end  #=&amp;gt; nil&lt;br /&gt;
Foo.class #=&amp;gt; Class&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What does the above snippet of code mean exactly?&lt;br /&gt;
It means 2 things : Foo is a constant and that constant holds(refers to) an object of Class type.&lt;br /&gt;
&lt;br /&gt;
Let us prove that:&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Foo = Class.new&lt;br /&gt;
(irb):8 warning: already initialized constant Foo&lt;br /&gt;
=&amp;gt; Foo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
As you can see, we got a warning because we tried to initialize the constant Foo again.&lt;br /&gt;
&lt;br /&gt;
So ,when you define some class ‘Foo’ in ruby, all you are doing is:&lt;br /&gt;
1-instantiating an object of type Class.&lt;br /&gt;
2-initializing a constant Foo that refers to that created object .&lt;br /&gt;
&lt;br /&gt;
So, when we say “object” ,then we do mean any object; an object of Class type, or any object of any type.[3]&lt;br /&gt;
&lt;br /&gt;
===Java===&lt;br /&gt;
&lt;br /&gt;
As mentioned before, Java is a strongly typed language. The type of data needs to be declared before using. The types of &amp;quot;types&amp;quot; in Java are :&lt;br /&gt;
   * Primitive Types:-  boolean and numeric. The numeric types are the integral types byte, short, int, long, and char, and the         &lt;br /&gt;
     floating-point types float and double. &lt;br /&gt;
   * Reference Types:- class types, interface types and array types. [2] &lt;br /&gt;
&lt;br /&gt;
Java is an object-oriented language, but it does make a clear distinction between the primitive type and Classes. int, float, char etc. are primitives, and the other data types other than the primitives are references. It is an interesting distinction to note, because of the differences in method calling system in different languages. Java makes a distinction in &amp;quot;calling-by-value&amp;quot; when a primitive is passed as a parameter, and &amp;quot;calling-by-reference&amp;quot; when an object is passed. In fact, if a primitive is passed, a call by value is invoked, but when a Class object is passed, only a reference is passed to the object. &lt;br /&gt;
&lt;br /&gt;
For a more language specific treatment of types and classes, you can refer: http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2007/wiki2_6_ap &lt;br /&gt;
&lt;br /&gt;
==Discussion of Issues==&lt;br /&gt;
Okay, so you're about to write a program and you need to represent data somehow.  Should you use a primitive type?  What about a class?  There are several features that are handed to you with each.&lt;br /&gt;
&lt;br /&gt;
=== Primitive Types ===&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Simplicity =====&lt;br /&gt;
In strongly typed languages, primitive types are ideal for data which doesn't necessarily need to be partitioned into several smaller components.  If you are looking to store and represent a simple throw-away integer for looping, for example, there's little reason why one would want to construct a class for this purpose.&lt;br /&gt;
&lt;br /&gt;
Primitive types are also often times coupled with native operations, handed to you by the language.  For example, in Java, variables of type int are automatically given operations such as addition, subtraction, multiplication, and so on.  These operations work as follows:&lt;br /&gt;
# Receive both inputs&lt;br /&gt;
# Cast if necessary (for example, from an int to a double)&lt;br /&gt;
# Perform calculation&lt;br /&gt;
# Return result&lt;br /&gt;
&lt;br /&gt;
It is important to note that the primitive types themselves are left ''unchanged'', and the result is returned from the operation, giving the programmer the ability to place the result elsewhere.&lt;br /&gt;
&lt;br /&gt;
===== Efficiency =====&lt;br /&gt;
In efficiency-critical applications, primitive types and their operations are oftentimes mapped directly to hardware-supported equivalents, thus operations can be performed very quickly.  This style of downgrading the logic to more so the hardware level has been replaced over the years for general applications, since improvements to hardware components have eradicated the once-imperative necessity to program efficiently.  Another point of view concerning efficiency could be from development time: if the program one is writing doesn't require complex design, it would be quicker to use the language's built-in types instead of taking the time to design a class to do the same feature.&lt;br /&gt;
&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Single-state storage =====&lt;br /&gt;
One large disadvantages to primitive types are that they are generally capable of only holding a single dimension state.  This limitation requires the programmer to use other variables in conjunction if they desire to hold more than one field of data.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Since primitive types do not allow you to encapsulate your data, if you ever desire to change the behavior of your program, you are forced to manually check each use of the variable for enforcement.&lt;br /&gt;
&lt;br /&gt;
For example, suppose you have a system designed in Java that maintains an integer value which represents the number of books you have in a library.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
int numBooks;&lt;br /&gt;
...&lt;br /&gt;
numBooks = 0;&lt;br /&gt;
...&lt;br /&gt;
numBooks++;&lt;br /&gt;
...&lt;br /&gt;
numBooks--;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A few days later, you realize that you should probably refactor your system to maintain a log of when this variable updates.  You immediately face a problem since, as it is, your code directly manipulates a single-state type integer.  Without resorting to a more object-oriented solution, you would have to update each location in the code of where a change takes place in order to establish this bookkeeping (pun intended).&lt;br /&gt;
&amp;lt;code id=&amp;quot;bookKeeping&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public static void integerValueChanged(){&lt;br /&gt;
  // records that the value has been changed&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public static void main(String[]args){&lt;br /&gt;
  int numBooks;&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks = 0;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks++;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
  numBooks--;&lt;br /&gt;
  integerValueChanged();&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To generalize this concept, it is oftentimes necessary to modify &amp;quot;what happens&amp;quot; when something is updated, and this cannot be easily accomplished by merely using primitive types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Class Types ===&lt;br /&gt;
Classes to the rescue!  Classes give programmers the ability to construct complex data types that are also capable of defining their own operations, all while keeping the details and specifics black-boxed outsize of where the class will be used in the code.&lt;br /&gt;
==== Advantages ====&lt;br /&gt;
===== Multi-dimensional Storage =====&lt;br /&gt;
Contrasting to primitive types, classes allow programmers to couple a varying number of fields.  Grouping fields of data into a single class, then instantiating such an object and manipulating it is much more convenient than keeping track of several individual variables.&lt;br /&gt;
&lt;br /&gt;
===== Refactoring =====&lt;br /&gt;
Oftentimes it is necessary to refactor a system to execute code when a change happens.  In object-land, we are able to do this through the ability to control what happens in our methods.&lt;br /&gt;
&lt;br /&gt;
Taking our [[#bookKeeping| example from above]], we can give a quick example of how a class could be defined to handle the situation much more elegantly.&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public class RecordedNumber{&lt;br /&gt;
  // The integer value, kept concealed in the class&lt;br /&gt;
  private int value;&lt;br /&gt;
&lt;br /&gt;
  public RecordedNumber(int value){&lt;br /&gt;
    this.value = value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public int getValue(){&lt;br /&gt;
    return value;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  public void setValue(int newValue){&lt;br /&gt;
    // code to do any necessary recording.&lt;br /&gt;
    ...&lt;br /&gt;
    this.value = newValue;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public class MyExample{&lt;br /&gt;
  public static void main(String[]args){&lt;br /&gt;
    RecordedNumber numBooks = new RecordedNumber(0);&lt;br /&gt;
    ...&lt;br /&gt;
    numBooks.setValue(4); // the object handles all necessary bookkeeping&lt;br /&gt;
    ...&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Code-reuse =====&lt;br /&gt;
Another nice feature to class-types encapsulate the concept surrounding code re-usability, especially in topics such as inheritance.  Classes allow the programmer to enhance an already existing class-type to be more specific, which in turn can prevent excessive code duplication.&lt;br /&gt;
&lt;br /&gt;
===== Application Structure =====&lt;br /&gt;
Designing an application in a object-oriented / class-specific style can reduce the challenges of designing and building a difficult system into merely making objects successfully interact.  It is from this concept that languages such as [http://en.wikipedia.org/wiki/Unified_Modeling_Language Unified Modeling Language (UML)] have been created, allowing software engineers to build around the notion of classes and their relationships to one another.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Disadvantages ====&lt;br /&gt;
===== Speed Considerations =====&lt;br /&gt;
In computational-intensive applications, objects built from classes tend to be less efficient than primitive data types built around procedural context.  This is due in part because of the object's creation, since it isn't supported directly hardware level.  Consideration is placed more so on good-design and coding-practices when implementing functionality around classes.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== B =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
===== C =====&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[1] http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html&lt;br /&gt;
&lt;br /&gt;
[2] Java:- Types, Values and Variables&lt;br /&gt;
    http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html&lt;br /&gt;
[3] Ruby Reflection ,http://www.khelll.com/blog/ruby/ruby-reflection/&lt;/div&gt;</summary>
		<author><name>Grepper</name></author>
	</entry>
</feed>