<?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=InteliSavant</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=InteliSavant"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/InteliSavant"/>
	<updated>2026-06-29T05:54:03Z</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_2009/wiki3_3_jn&amp;diff=26491</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 3 jn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_3_jn&amp;diff=26491"/>
		<updated>2009-11-09T19:58:13Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Common Closure Principle=&lt;br /&gt;
&lt;br /&gt;
==Definitions==&lt;br /&gt;
&lt;br /&gt;
*'''Common Closure Principle (CCP)''' - “The classes in a package should be closed against the same kinds of change; A change that affects a package affects all the classes in that package.” - R. Martin, 1996.  &lt;br /&gt;
&lt;br /&gt;
*'''Open Closed Principle (OCP)''' – &amp;quot;Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification&amp;quot; – Bertrand Meyer, 1988&lt;br /&gt;
&lt;br /&gt;
*'''Reuse-Release Equivalence Principle (REP)''' – “The granule of reuse is the granule of release. Only components that are released through a tracking system can be efficiently reused.” -R. Martin, 1996&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What is CCP?==&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle is defined as “The classes in a package should be closed against the same kinds of change; A change that affects a package affects all the classes in that package.”  [R. Martin, 1996].  The real concept here is to ensure that all the classes within a single package are cohesive and decoupled from other classes as much as possible.  If you remember this is a typical design principle for classes that has been extended to entire package granularity.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle is closely associated with the Open Closed Principle. [[http://www.objectmentor.com/resources/articles/granularity.pdf Granularity]]  The CCP is targeted towards more accurately defining a specific requirement for the closure portion of OCP.  The OCP states that classes should be closed for modification but open for extension.  The key idea here is that we should be able to add more functionality to our code without altering the existing functionality in any way.  This ensures backwards compatibility for older code systems but allows for future improvements if needed.  This is directly tied to expected function signatures and expected function output values for any users that have developed on top of a previous package release.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle augments the OCP principle by specifying specific closure practices for a specific package.  The principle requires that if code must be modified, possibly for a bug or some other critical reason, then all of the required changes to resolve the issue should be limited to a single package.  CCP requires that if any two classes are so closely coupled that they will likely need to be edited in unison in the future that they be part of the same class.  The need for this principle is exemplified in the next section.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Why do we need to use CCP?==&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle is targeted at maintainability rather than reusability, which many times is much more important.  [[http://mcs.mines.edu/Courses/csci306/CHAPTERS/Agile/AgileSection4.ppt Principles of Package Design]]  In many cases we would like the make packages as light weight as possible to allow code to be reused.  If users don't typically use all the code in the package then we have a trade off of wasting space if we make the package too big.  But if we make too many packages to ensure that they are lightweight we can run into the problem of inter-package coupling.  This can cause the need for many packages to be updated if new functionality or code fixes are required.  This is the key concept that the CCP is trying to prevent from occuring.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can clarify this concept further by a simple example.  Imagine you are a project manager for a large java software project and after the release of the software you have uncovered a critical bug.  This bug pertained to a specific usage case which was not covered in your testing strategy and covers a wide number of classes.  Now imagine that the work on your project has been divided up among smaller teams by the specific packages you have implemented.  Which would you rather have, a single team able to handle the entire code alteration ensuring that they can intracommunicate and that all the required changes are cohesive in the classes?   Or would you rather distribute the work and require a large amount of intercommunication between teams to ensure cohesion?  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The obvious answer from the example above is to allow a single team to handle the resolution of the problem.   This will simplify testing and integration of the next release by preventing separate teams from introducing separate bugs into the code.  We also need to remember that every package and class will require its own level of testing.  This should further clarify the need for the CCP as the amount of revalidation required is directly proportional to the number of packages involved.  Also this principle will help correlate the resolution of the bug to a single package change which can make it easier to package and distribute the patch to clients.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Conflicting Principles==&lt;br /&gt;
&lt;br /&gt;
The CCP principle can sometimes lead to confusion when also considering the Reuse-Release Equivalence Principle.  This principle tells use to combine code into packages based on user convenience and usage patterns.  Essentially if classes are typically used in unison then why not package them together and prevent the users from defining multiple imports?  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Many users find it hard to find a balance between obeying both REP and CCP.  The trade off here is user convenience and maintainability.  Program designers need to be careful to separate new and moderately unstable code from older and highly stable code in packages when considering how to package code.  Maintainability and User Convenience are both very important considerations and a good balance for both need to be discovered when packaging code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==XML Example==&lt;br /&gt;
&lt;br /&gt;
Consider that a newer standard of XML was released and you are responsible for implementing the java package which handles XML files.  The key features of the new package must support all the old XML standards but also the newly updated standard, so how do you go about accomplishing this goal?  Typically a newer standard of XML will require additional methods which are easy to accommodate by extending the current package.  The problem arises when an old function needs to be updated to support the new standard, since the Open Closed Principle states to not change previous code.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first option is to either create function calls by XML standard number.  This allows us to virtually extend the design without violating the OCP.  This requires the programmers to statically compile their code for a specific standard of XML and thus is not the best idea.   A more viable option is to create a totally separate package which handles the newer standard of XML.  This allows programmers to choose which version of the XML package they wish to support in their program.  This can complicate programmer's code if they wish to support multiple versions as they must now dynamically load a package at runtime depending on the XML standard the user wishes to use.  Multiple package versions can make others code easier to maintain since they can choose to use a stable version with known functionality or choose the newer and more versatile version.  Thus the programmers can easily make requirements on the required package version they want their program to use for stability reasons.  But this comes at a drawback that the program must now be released in multiple versions corresponding to the supported package version.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main problem with creating multiple packages is that it violates the Common Closure Principle.  Imagine that a very rare bug was found in some of the more stable portions of the XML code.  This stable code where the bug was located could be in multiple packages and even all the way back to the original release.  If you currently have launched 10 packages supporting different XML versions then you must first edit all 10 versions and then revalidate all the code.  This can be a daunting task and is the key objective that the CCP is trying to avoid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The best way to implement the newer version of XML is to alter the original by extending the support of each method.  This of course violates the OCP principle by not allowing the original version of the code to remain closed but provides for easier future maintenance of the code if a bug was discovered.  The advantage of doing this is that user’s code will not have to be recompiled to support the newer version of the code, as the method calls and package name will all remain exactly the same.  The limitation here is that the new version may be unstable and the programmers must be aware of this fact to prevent from using something that might be unstable compared to previous versions.  Thus the burden is on the consumers to ensure they have the proper version of the package that they wish to use.   If we look at most modern day programming releases this is the most common solution.  Programmers today will release beta and stable versions of code to allow users the option to choose when deciding what trade off they are willing accept for different availability of features.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
&lt;br /&gt;
[1] [http://en.wikipedia.org/wiki/Open/closed_principle The Open-Closed Principle]&lt;br /&gt;
&lt;br /&gt;
[2] [http://agileinaflash.blogspot.com/2009/07/principles-of-package-cohesion.html Principles of Package Cohesion]&lt;br /&gt;
&lt;br /&gt;
[3] [http://www2.cs.uh.edu/~svenkat/SoftwareDesign/slides/ObjectOrientedDesignPrinciples.pdf Object Oriented Design Principles]&lt;br /&gt;
&lt;br /&gt;
[4] [http://books.google.com/books?id=4pjbgVHzomsC&amp;amp;pg=PA26&amp;amp;lpg=PA26&amp;amp;dq=common+closure+principle&amp;amp;source=bl&amp;amp;ots=snjbB9n0Yf&amp;amp;sig=pHWv9VNcLH-uJGuiyoJjDbPmgnk&amp;amp;hl=en&amp;amp;ei=sif4Som8Dqrg8AaF_-DzCQ&amp;amp;sa=X&amp;amp;oi=book_result&amp;amp;ct=result&amp;amp;resnum=8&amp;amp;ved=0CBoQ6AEwBw#v=onepage&amp;amp;q=Open%20Closed&amp;amp;f=false Java Design: Objects, UML, and Process]&lt;br /&gt;
&lt;br /&gt;
[5] [http://www.objectmentor.com/resources/articles/granularity.pdf Granularity]&lt;br /&gt;
&lt;br /&gt;
[6] [http://ifacethoughts.net/2006/04/08/common-closure-principle/ Common Closure Principle (ifacethoughts.net)]&lt;br /&gt;
&lt;br /&gt;
[7] [http://missoula.vancouver.wsu.edu/cs320_Fall09/lectures/lecture16.ppt Object Orient Principles (Washington State University)]&lt;br /&gt;
&lt;br /&gt;
[8] [http://mcs.mines.edu/Courses/csci306/CHAPTERS/Agile/AgileSection4.ppt Principles of Package Design (Colorado School of Mines)]&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_3_jn&amp;diff=26490</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 3 jn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_3_jn&amp;diff=26490"/>
		<updated>2009-11-09T19:46:36Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Common Closure Principle=&lt;br /&gt;
&lt;br /&gt;
==Definitions==&lt;br /&gt;
&lt;br /&gt;
*'''CCP (Common Closure Principle)''' - “The classes in a package should be closed against the same kinds of change; A change that affects a package affects all the classes in that package.” - R. Martin, 1996.  &lt;br /&gt;
&lt;br /&gt;
*'''OCP (Open Closed Principle)''' – &amp;quot;software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification&amp;quot; – Bertrand Meyer, 1988&lt;br /&gt;
&lt;br /&gt;
*'''REP (Reuse-Release Equivalence)''' – “The granule of reuse is the granule of release. Only components that are released through a tracking system can be efficiently reused.” -R. Martin, 1996&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What is CCP?==&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle is defined as “The classes in a package should be closed against the same kinds of change; A change that affects a package affects all the classes in that package.”  [R. Martin, 1996].  The real concept here is to ensure that all the classes within a single package are cohesive and decoupled from other classes as much as possible.  If you remember this is a typical design principle for classes that has been extended to entire package granularity.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle is closely associated with the Open Closed Principle. [[http://www.objectmentor.com/resources/articles/granularity.pdf Granularity]]  The CCP is targeted towards more accurately defining a specific requirement for the closure portion of OCP.  The OCP states that classes should be closed for modification but open for extension.  The key idea here is that we should be able to add more functionality to our code without altering the existing functionality in any way.  This ensures backwards compatibility for older code systems but allows for future improvements if needed.  This is directly tied to expected function signatures and expected function output values for any users that have developed on top of a previous package release.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle augments the OCP principle by specifying specific closure practices for a specific package.  The principle requires that if code must be modified, possibly for a bug or some other critical reason, then all of the required changes to resolve the issue should be limited to a single package.  CCP requires that if any two classes are so closely coupled that they will likely need to be edited in unison in the future that they be part of the same class.  The need for this principle is exemplified in the next section.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Why do we need to use CCP?==&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle is targeted at maintainability rather than reusability, which many times is much more important.  [[http://mcs.mines.edu/Courses/csci306/CHAPTERS/Agile/AgileSection4.ppt Principles of Package Design]]  In many cases we would like the make packages as light weight as possible to allow code to be reused.  If users don't typically use all the code in the package then we have a trade off of wasting space if we make the package too big.  But if we make too many packages to ensure that they are lightweight we can run into the problem of inter-package coupling.  This can cause the need for many packages to be updated if new functionality or code fixes are required.  This is the key concept that the CCP is trying to prevent from occuring.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can clarify this concept further by a simple example.  Imagine you are a project manager for a large java software project and after the release of the software you have uncovered a critical bug.  This bug pertained to a specific usage case which was not covered in your testing strategy and covers a wide number of classes.  Now imagine that the work on your project has been divided up among smaller teams by the specific packages you have implemented.  Which would you rather have, a single team able to handle the entire code alteration ensuring that they can intracommunicate and that all the required changes are cohesive in the classes?   Or would you rather distribute the work and require a large amount of intercommunication between teams to ensure cohesion?  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The obvious answer from the example above is to allow a single team to handle the resolution of the problem.   This will simplify testing and integration of the next release by preventing separate teams from introducing separate bugs into the code.  We also need to remember that every package and class will require its own level of testing.  This should further clarify the need for the CCP as the amount of revalidation required is directly proportional to the number of packages involved.  Also this principle will help correlate the resolution of the bug to a single package change which can make it easier to package and distribute the patch to clients.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Conflicting Principles==&lt;br /&gt;
&lt;br /&gt;
The CCP principle can sometimes lead to confusion when also considering the Reuse-Release Equivalence Principle.  This principle tells use to combine code into packages based on user convenience and usage patterns.  Essentially if classes are typically used in unison then why not package them together and prevent the users from defining multiple imports?  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Many users find it hard to find a balance between obeying both REP and CCP.  The trade off here is user convenience and maintainability.  Program designers need to be careful to separate new and moderately unstable code from older and highly stable code in packages when considering how to package code.  Maintainability and User Convenience are both very important considerations and a good balance for both need to be discovered when packaging code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==XML Example==&lt;br /&gt;
&lt;br /&gt;
Consider that a newer standard of XML was released and you are responsible for implementing the java package which handles XML files.  The key features of the new package must support all the old XML standards but also the newly updated standard, so how do you go about accomplishing this goal?  Typically a newer standard of XML will require additional methods which are easy to accommodate by extending the current package.  The problem arises when an old function needs to be updated to support the new standard, since the Open Closed Principle states to not change previous code.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first option is to either create function calls by XML standard number.  This allows us to virtually extend the design without violating the OCP.  This requires the programmers to statically compile their code for a specific standard of XML and thus is not the best idea.   A more viable option is to create a totally separate package which handles the newer standard of XML.  This allows programmers to choose which version of the XML package they wish to support in their program.  This can complicate programmer's code if they wish to support multiple versions as they must now dynamically load a package at runtime depending on the XML standard the user wishes to use.  Multiple package versions can make others code easier to maintain since they can choose to use a stable version with known functionality or choose the newer and more versatile version.  Thus the programmers can easily make requirements on the required package version they want their program to use for stability reasons.  But this comes at a drawback that the program must now be released in multiple versions corresponding to the supported package version.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The main problem with creating multiple packages is that it violates the Common Closure Principle.  Imagine that a very rare bug was found in some of the more stable portions of the XML code.  This stable code where the bug was located could be in multiple packages and even all the way back to the original release.  If you currently have launched 10 packages supporting different XML versions then you must first edit all 10 versions and then revalidate all the code.  This can be a daunting task and is the key objective that the CCP is trying to avoid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The best way to implement the newer version of XML is to alter the original by extending the support of each method.  This of course violates the OCP principle by not allowing the original version of the code to remain closed but provides for easier future maintenance of the code if a bug was discovered.  The advantage of doing this is that user’s code will not have to be recompiled to support the newer version of the code, as the method calls and package name will all remain exactly the same.  The limitation here is that the new version may be unstable and the programmers must be aware of this fact to prevent from using something that might be unstable compared to previous versions.  Thus the burden is on the consumers to ensure they have the proper version of the package that they wish to use.   If we look at most modern day programming releases this is the most common solution.  Programmers today will release beta and stable versions of code to allow users the option to choose when deciding what trade off they are willing accept for different availability of features.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
&lt;br /&gt;
[1] [http://en.wikipedia.org/wiki/Open/closed_principle The Open-Closed Principle]&lt;br /&gt;
&lt;br /&gt;
[2] [http://agileinaflash.blogspot.com/2009/07/principles-of-package-cohesion.html Principles of Package Cohesion]&lt;br /&gt;
&lt;br /&gt;
[3] [http://www2.cs.uh.edu/~svenkat/SoftwareDesign/slides/ObjectOrientedDesignPrinciples.pdf Object Oriented Design Principles]&lt;br /&gt;
&lt;br /&gt;
[4] [http://books.google.com/books?id=4pjbgVHzomsC&amp;amp;pg=PA26&amp;amp;lpg=PA26&amp;amp;dq=common+closure+principle&amp;amp;source=bl&amp;amp;ots=snjbB9n0Yf&amp;amp;sig=pHWv9VNcLH-uJGuiyoJjDbPmgnk&amp;amp;hl=en&amp;amp;ei=sif4Som8Dqrg8AaF_-DzCQ&amp;amp;sa=X&amp;amp;oi=book_result&amp;amp;ct=result&amp;amp;resnum=8&amp;amp;ved=0CBoQ6AEwBw#v=onepage&amp;amp;q=Open%20Closed&amp;amp;f=false Java Design: Objects, UML, and Process]&lt;br /&gt;
&lt;br /&gt;
[5] [http://www.objectmentor.com/resources/articles/granularity.pdf Granularity]&lt;br /&gt;
&lt;br /&gt;
[6] [http://ifacethoughts.net/2006/04/08/common-closure-principle/ Common Closure Principle (ifacethoughts.net)]&lt;br /&gt;
&lt;br /&gt;
[7] [http://missoula.vancouver.wsu.edu/cs320_Fall09/lectures/lecture16.ppt Object Orient Principles (Washington State University)]&lt;br /&gt;
&lt;br /&gt;
[8] [http://mcs.mines.edu/Courses/csci306/CHAPTERS/Agile/AgileSection4.ppt Principles of Package Design (Colorado School of Mines)]&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_3_jn&amp;diff=26489</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 3 jn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_3_jn&amp;diff=26489"/>
		<updated>2009-11-09T19:45:39Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Common Closure Principle=&lt;br /&gt;
&lt;br /&gt;
==Definitions==&lt;br /&gt;
&lt;br /&gt;
*'''CCP (Common Closure Principle)''' - “The classes in a package should be closed against the same kinds of change; A change that affects a package affects all the classes in that package.” - R. Martin, 1996.  &lt;br /&gt;
&lt;br /&gt;
*'''OCP (Open Closed Principle)''' – &amp;quot;software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification&amp;quot; – Bertrand Meyer, 1988&lt;br /&gt;
&lt;br /&gt;
*'''REP (Reuse-Release Equivalence)''' – “The granule of reuse is the granule of release. Only components that are released through a tracking system can be efficiently reused.” -R. Martin, 1996&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What is CCP?==&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle is defined as “The classes in a package should be closed against the same kinds of change; A change that affects a package affects all the classes in that package.”  [R. Martin, 1996].  The real concept here is to ensure that all the classes within a single package are cohesive and decoupled from other classes as much as possible.  If you remember this is a typical design principle for classes that has been extended to entire package granularity.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle is closely associated with the Open Closed Principle. [[http://www.objectmentor.com/resources/articles/granularity.pdf Granularity]]  The CCP is targeted towards more accurately defining a specific requirement for the closure portion of OCP.  The OCP states that classes should be closed for modification but open for extension.  The key idea here is that we should be able to add more functionality to our code without altering the existing functionality in any way.  This ensures backwards compatibility for older code systems but allows for future improvements if needed.  This is directly tied to expected function signatures and expected function output values for any users that have developed on top of a previous package release.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle augments the OCP principle by specifying specific closure practices for a specific package.  The principle requires that if code must be modified, possibly for a bug or some other critical reason, then all of the required changes to resolve the issue should be limited to a single package.  CCP requires that if any two classes are so closely coupled that they will likely need to be edited in unison in the future that they be part of the same class.  The need for this principle is exemplified in the next section.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Why do we need to use CCP?==&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle is targeted at maintainability rather than reusability, which many times is much more important.  [[http://mcs.mines.edu/Courses/csci306/CHAPTERS/Agile/AgileSection4.ppt Principles of Package Design]]  In many cases we would like the make packages as light weight as possible to allow code to be reused.  If users don't typically use all the code in the package then we have a trade off of wasting space if we make the package too big.  But if we make too many packages to ensure that they are lightweight we can run into the problem of inter-package coupling.  This can cause the need for many packages to be updated if new functionality or code fixes are required.  This is the key concept that the CCP is trying to prevent from occuring.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can clarify this concept further by a simple example.  Imagine you are a project manager for a large java software project and after the release of the software you have uncovered a critical bug.  This bug pertained to a specific usage case which was not covered in your testing strategy and covers a wide number of classes.  Now imagine that the work on your project has been divided up among smaller teams by the specific packages you have implemented.  Which would you rather have, a single team able to handle the entire code alteration ensuring that they can intracommunicate and that all the required changes are cohesive in the classes?   Or would you rather distribute the work and require a large amount of intercommunication between teams to ensure cohesion?  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The obvious answer from the example above is to allow a single team to handle the resolution of the problem.   This will simplify testing and integration of the next release by preventing separate teams from introducing separate bugs into the code.  We also need to remember that every package and class will require its own level of testing.  This should further clarify the need for the CCP as the amount of revalidation required is directly proportional to the number of packages involved.  Also this principle will help correlate the resolution of the bug to a single package change which can make it easier to package and distribute the patch to clients.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Conflicting Principles==&lt;br /&gt;
&lt;br /&gt;
The CCP principle can sometimes lead to confusion when also considering the Reuse-Release Equivalence Principle.  This principle tells use to combine code into packages based on user convenience and usage patterns.  Essentially if classes are typically used in unison then why not package them together and prevent the users from defining multiple imports?  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Many users find it hard to find a balance between obeying both REP and CCP.  The trade off here is user convenience and maintainability.  Program designers need to be careful to separate new and moderately unstable code from older and highly stable code in packages when considering how to package code.  Maintainability and User Convenience are both very important considerations and a good balance for both need to be discovered when packaging code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==XML Example==&lt;br /&gt;
&lt;br /&gt;
Consider that a newer standard of XML was released and you are responsible for implementing the java package which handles XML files.  The key features of the new package must support all the old XML standards but also the newly updated standard, so how do you go about accomplishing this goal?  Typically a newer standard of XML will require additional methods which are easy to accommodate by extending the current package.  The problem arises when an old function needs to be updated to support the new standard, since the Open Closed Principle states to not change previous code.  &lt;br /&gt;
&lt;br /&gt;
The first option is to either create function calls by XML standard number.  This allows us to virtually extend the design without violating the OCP.  This requires the programmers to statically compile their code for a specific standard of XML and thus is not the best idea.   A more viable option is to create a totally separate package which handles the newer standard of XML.  This allows programmers to choose which version of the XML package they wish to support in their program.  This can complicate programmer's code if they wish to support multiple versions as they must now dynamically load a package at runtime depending on the XML standard the user wishes to use.  Multiple package versions can make others code easier to maintain since they can choose to use a stable version with known functionality or choose the newer and more versatile version.  Thus the programmers can easily make requirements on the required package version they want their program to use for stability reasons.  But this comes at a drawback that the program must now be released in multiple versions corresponding to the supported package version.  &lt;br /&gt;
&lt;br /&gt;
The main problem with creating multiple packages is that it violates the Common Closure Principle.  Imagine that a very rare bug was found in some of the more stable portions of the XML code.  This stable code where the bug was located could be in multiple packages and even all the way back to the original release.  If you currently have launched 10 packages supporting different XML versions then you must first edit all 10 versions and then revalidate all the code.  This can be a daunting task and is the key objective that the CCP is trying to avoid.&lt;br /&gt;
&lt;br /&gt;
The best way to implement the newer version of XML is to alter the original by extending the support of each method.  This of course violates the OCP principle by not allowing the original version of the code to remain closed but provides for easier future maintenance of the code if a bug was discovered.  The advantage of doing this is that user’s code will not have to be recompiled to support the newer version of the code, as the method calls and package name will all remain exactly the same.  The limitation here is that the new version may be unstable and the programmers must be aware of this fact to prevent from using something that might be unstable compared to previous versions.  Thus the burden is on the consumers to ensure they have the proper version of the package that they wish to use.   If we look at most modern day programming releases this is the most common solution.  Programmers today will release beta and stable versions of code to allow users the option to choose when deciding what trade off they are willing accept for different availability of features.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
&lt;br /&gt;
[1] [http://en.wikipedia.org/wiki/Open/closed_principle The Open-Closed Principle]&lt;br /&gt;
&lt;br /&gt;
[2] [http://agileinaflash.blogspot.com/2009/07/principles-of-package-cohesion.html Principles of Package Cohesion]&lt;br /&gt;
&lt;br /&gt;
[3] [http://www2.cs.uh.edu/~svenkat/SoftwareDesign/slides/ObjectOrientedDesignPrinciples.pdf Object Oriented Design Principles]&lt;br /&gt;
&lt;br /&gt;
[4] [http://books.google.com/books?id=4pjbgVHzomsC&amp;amp;pg=PA26&amp;amp;lpg=PA26&amp;amp;dq=common+closure+principle&amp;amp;source=bl&amp;amp;ots=snjbB9n0Yf&amp;amp;sig=pHWv9VNcLH-uJGuiyoJjDbPmgnk&amp;amp;hl=en&amp;amp;ei=sif4Som8Dqrg8AaF_-DzCQ&amp;amp;sa=X&amp;amp;oi=book_result&amp;amp;ct=result&amp;amp;resnum=8&amp;amp;ved=0CBoQ6AEwBw#v=onepage&amp;amp;q=Open%20Closed&amp;amp;f=false Java Design: Objects, UML, and Process]&lt;br /&gt;
&lt;br /&gt;
[5] [http://www.objectmentor.com/resources/articles/granularity.pdf Granularity]&lt;br /&gt;
&lt;br /&gt;
[6] [http://ifacethoughts.net/2006/04/08/common-closure-principle/ Common Closure Principle (ifacethoughts.net)]&lt;br /&gt;
&lt;br /&gt;
[7] [http://missoula.vancouver.wsu.edu/cs320_Fall09/lectures/lecture16.ppt Object Orient Principles (Washington State University)]&lt;br /&gt;
&lt;br /&gt;
[8] [http://mcs.mines.edu/Courses/csci306/CHAPTERS/Agile/AgileSection4.ppt Principles of Package Design (Colorado School of Mines)]&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_3_jn&amp;diff=26488</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 3 jn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_3_jn&amp;diff=26488"/>
		<updated>2009-11-09T18:26:39Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Common Closure Principle=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==TOC==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Definitions==&lt;br /&gt;
&lt;br /&gt;
*'''CCP (Common Closure Principle)''' - “The classes in a package should be closed against the same kinds of change; A change that affects a package affects all the classes in that package.” - R. Martin, 1996.  &lt;br /&gt;
&lt;br /&gt;
*'''OCP (Open Closed Principle)''' – &amp;quot;software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification&amp;quot; – Bertrand Meyer, 1988&lt;br /&gt;
&lt;br /&gt;
*'''REP (Reuse-Release Equivalence)''' – “The granule of reuse is the granule of release. Only components that are released through a tracking system can be efficiently reused.” -R. Martin, 1996&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What is CCP?==&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle is defined as “The classes in a package should be closed against the same kinds of change; A change that affects a package affects all the classes in that package.”  [R. Martin, 1996].  The real concept here is to ensure that all the classes within a single package are cohesive and decoupled from other classes as much as possible.  If you remember this is a typical design principle for classes that has been extended to entire package granularity.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle is closely associated with the Open Closed Principle. [[http://www.objectmentor.com/resources/articles/granularity.pdf Granularity]]  The CCP is targeted towards more accurately defining a specific requirement for the closure portion of OCP.  The OCP states that classes should be closed for modification but open for extension.  The key idea here is that we should be able to add more functionality to our code without altering the existing functionality in any way.  This ensures backwards compatibility for older code systems but allows for future improvements if needed.  This is directly tied to expected function signatures and expected function output values for any users that have developed on top of a previous package release.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle augments the OCP principle by specifying specific closure practices for a specific package.  The principle requires that if code must be modified, possibly for a bug or some other critical reason, then all of the required changes to resolve the issue should be limited to a single package.  CCP requires that if any two classes are so closely coupled that they will likely need to be edited in unison in the future that they be part of the same class.  The need for this principle is exemplified in the next section.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Why do we need to use CCP?==&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle is targeted at maintainability rather than reusability, which many times is much more important.  [[http://mcs.mines.edu/Courses/csci306/CHAPTERS/Agile/AgileSection4.ppt Principles of Package Design]]  In many cases we would like the make packages as light weight as possible to allow code to be reused.  If users don't typically use all the code in the package then we have a trade off of wasting space if we make the package too big.  But if we make too many packages to ensure that they are lightweight we can run into the problem of inter-package coupling.  This can cause the need for many packages to be updated if new functionality or code fixes are required.  This is the key concept that the CCP is trying to prevent from occuring.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can clarify this concept further by a simple example.  Imagine you are a project manager for a large java software project and after the release of the software you have uncovered a critical bug.  This bug pertained to a specific usage case which was not covered in your testing strategy and covers a wide number of classes.   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
!!Need Image that shows the two designs of the system.  IE One with multiple edits and the other with only one edit!!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now imagine that the work on your project has been divided up among smaller teams by the specific packages you have implemented.  Which would you rather have, a single team able to handle the entire code alteration ensuring that they can intracommunicate and that all the required changes are cohesive in the classes?   Or would you rather distribute the work and require a large amount of intercommunication between teams to ensure cohesion?  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The obvious answer from the example above is to allow a single team to handle the resolution of the problem.   This will simplify testing and integration of the next release by preventing separate teams from introducing separate bugs into the code.  We also need to remember that every package and class will require its own level of testing.  This should further clarify the need for the CCP as the amount of revalidation required is directly proportional to the number of packages involved.  Also this principle will help correlate the resolution of the bug to a single package change which can make it easier to package and distribute the patch to clients.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Conflicting Principles==&lt;br /&gt;
&lt;br /&gt;
The CCP principle can sometimes lead to confusion when also considering the Reuse-Release Equivalence Principle.  This principle tells use to combine code into packages based on user convenience and usage patterns.  Essentially if classes are typically used in unison then why not package them together and prevent the users from defining multiple imports?  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Many users find it hard to find a balance between obeying both REP and CCP.  The trade off here is user convenience and maintainability.  Program designers need to be careful to separate new and moderately unstable code from older and highly stable code in packages when considering how to package code.  Maintainability and User Convenience are both very important considerations and a good balance for both need to be discovered when packaging code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
&lt;br /&gt;
[1] [http://en.wikipedia.org/wiki/Open/closed_principle The Open-Closed Principle]&lt;br /&gt;
&lt;br /&gt;
[2] [http://agileinaflash.blogspot.com/2009/07/principles-of-package-cohesion.html Principles of Package Cohesion]&lt;br /&gt;
&lt;br /&gt;
[3] [http://www2.cs.uh.edu/~svenkat/SoftwareDesign/slides/ObjectOrientedDesignPrinciples.pdf Object Oriented Design Principles]&lt;br /&gt;
&lt;br /&gt;
[4] [http://books.google.com/books?id=4pjbgVHzomsC&amp;amp;pg=PA26&amp;amp;lpg=PA26&amp;amp;dq=common+closure+principle&amp;amp;source=bl&amp;amp;ots=snjbB9n0Yf&amp;amp;sig=pHWv9VNcLH-uJGuiyoJjDbPmgnk&amp;amp;hl=en&amp;amp;ei=sif4Som8Dqrg8AaF_-DzCQ&amp;amp;sa=X&amp;amp;oi=book_result&amp;amp;ct=result&amp;amp;resnum=8&amp;amp;ved=0CBoQ6AEwBw#v=onepage&amp;amp;q=Open%20Closed&amp;amp;f=false Java Design: Objects, UML, and Process]&lt;br /&gt;
&lt;br /&gt;
[5] [http://www.objectmentor.com/resources/articles/granularity.pdf Granularity]&lt;br /&gt;
&lt;br /&gt;
[6] [http://ifacethoughts.net/2006/04/08/common-closure-principle/ Common Closure Principle (ifacethoughts.net)]&lt;br /&gt;
&lt;br /&gt;
[7] [http://missoula.vancouver.wsu.edu/cs320_Fall09/lectures/lecture16.ppt Object Orient Principles (Washington State University)]&lt;br /&gt;
&lt;br /&gt;
[8] [http://mcs.mines.edu/Courses/csci306/CHAPTERS/Agile/AgileSection4.ppt Principles of Package Design (Colorado School of Mines)]&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_3_jn&amp;diff=26487</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 3 jn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_3_jn&amp;diff=26487"/>
		<updated>2009-11-09T18:03:54Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Common Closure Principle=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==TOC==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Definitions==&lt;br /&gt;
&lt;br /&gt;
*'''CCP (Common Closure Principle)''' - “The classes in a package should be closed against the same kinds of change; A change that affects a package affects all the classes in that package.” - R. Martin, 1996.  &lt;br /&gt;
&lt;br /&gt;
*'''OCP (Open Closed Principle)''' – &amp;quot;software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification&amp;quot; – Bertrand Meyer, 1988&lt;br /&gt;
&lt;br /&gt;
*'''REP (Reuse-Release Equivalence)''' – “The granule of reuse is the granule of release. Only components that are released through a tracking system can be efficiently reused.” -R. Martin, 1996&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What is CCP?==&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle is defined as “The classes in a package should be closed against the same kinds of change; A change that affects a package affects all the classes in that package.”  [R. Martin, 1996].  The real concept here is to ensure that all the classes within a single package are cohesive and decoupled from other classes as much as possible.  If you remember this is a typical design principle for classes that has been extended to entire package granularity.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle is closely associated with the Open Closed Principle. [[http://www.objectmentor.com/resources/articles/granularity.pdf Granularity]]  The CCP is targeted towards more accurately defining a specific requirement for the closure portion of OCP.  The OCP states that classes should be closed for modification but open for extension.  The key idea here is that we should be able to add more functionality to our code without altering the existing functionality in any way.  This ensures backwards compatibility for older code systems but allows for future improvements if needed.  This is directly tied to expected function signatures and expected function output values for any users that have developed on top of a previous package release.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle augments the OCP principle by specifying specific closure practices for a specific package.  The principle requires that if code must be modified, possibly for a bug or some other critical reason, then all of the required changes to resolve the issue should be limited to a single package.  CCP requires that if any two classes are so closely coupled that they will likely need to be edited in unison in the future that they be part of the same class.  The need for this principle is exemplified in the next section.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Why do we need to use CCP?==&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle is targeted at maintainability rather than reusability, which many times is much more important.  [[http://mcs.mines.edu/Courses/csci306/CHAPTERS/Agile/AgileSection4.ppt Principles of Package Design]]  In many cases we would like the make packages as light weight as possible to allow code to be reused.  If users don't typically use all the code in the package then we have a trade off of wasting space if we make the package too big.  But if we make too many packages to ensure that they are lightweight we can run into the problem of inter-package coupling.  This can cause the need for many packages to be updated if new functionality or code fixes are required.  This is the key concept that the CCP is trying to prevent from occuring.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We can clarify this concept further by a simple example.  Imagine you are a project manager for a large java software project and after the release of the software you have uncovered a critical bug.  This bug pertained to a specific usage case which was not covered in your testing strategy and covers a wide number of classes.   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
!!Need Image that shows the two designs of the system.  IE One with multiple edits and the other with only one edit!!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now imagine that the work on your project has been divided up among smaller teams by the specific packages you have implemented.  Which would you rather have, a single team able to handle the entire code alteration ensuring that they can intracommunicate and that all the required changes are cohesive in the classes?   Or would you rather distribute the work and require a large amount of intercommunication between teams to ensure cohesion?  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The obvious answer from the example above is to allow a single team to handle the resolution of the problem.   This will simplify testing and integration of the next release by preventing separate teams from introducing separate bugs into the code and preventing the need for each of the packages to be revalidated independently.  Also this will correlate the resolution of the bug to a single package change which can make it easier to package and distribute the patch to clients.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Conflicting Principles==&lt;br /&gt;
&lt;br /&gt;
The CCP principle can sometimes lead to confusion when also considering the Reuse-Release Equivalence Principle.  This principle tells use to combine code into packages based on user convenience and usage patterns.  Essentially if classes are typically used in unison then why not package them together and prevent the users from defining multiple imports?  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Many users find it hard to find a balance between obeying both REP and CCP.  The trade off here is user convenience and maintainability.  Program designers need to be careful to separate new and moderately unstable code from older and highly stable code in packages when considering how to package code.  Maintainability and User Convenience are both very important considerations and a good balance for both need to be discovered when packaging code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
&lt;br /&gt;
[1] [http://en.wikipedia.org/wiki/Open/closed_principle The Open-Closed Principle]&lt;br /&gt;
&lt;br /&gt;
[2] [http://agileinaflash.blogspot.com/2009/07/principles-of-package-cohesion.html Principles of Package Cohesion]&lt;br /&gt;
&lt;br /&gt;
[3] [http://www2.cs.uh.edu/~svenkat/SoftwareDesign/slides/ObjectOrientedDesignPrinciples.pdf Object Oriented Design Principles]&lt;br /&gt;
&lt;br /&gt;
[4] [http://books.google.com/books?id=4pjbgVHzomsC&amp;amp;pg=PA26&amp;amp;lpg=PA26&amp;amp;dq=common+closure+principle&amp;amp;source=bl&amp;amp;ots=snjbB9n0Yf&amp;amp;sig=pHWv9VNcLH-uJGuiyoJjDbPmgnk&amp;amp;hl=en&amp;amp;ei=sif4Som8Dqrg8AaF_-DzCQ&amp;amp;sa=X&amp;amp;oi=book_result&amp;amp;ct=result&amp;amp;resnum=8&amp;amp;ved=0CBoQ6AEwBw#v=onepage&amp;amp;q=Open%20Closed&amp;amp;f=false Java Design: Objects, UML, and Process]&lt;br /&gt;
&lt;br /&gt;
[5] [http://www.objectmentor.com/resources/articles/granularity.pdf Granularity]&lt;br /&gt;
&lt;br /&gt;
[6] [http://ifacethoughts.net/2006/04/08/common-closure-principle/ Common Closure Principle (ifacethoughts.net)]&lt;br /&gt;
&lt;br /&gt;
[7] [http://missoula.vancouver.wsu.edu/cs320_Fall09/lectures/lecture16.ppt Object Orient Principles (Washington State University)]&lt;br /&gt;
&lt;br /&gt;
[8] [http://mcs.mines.edu/Courses/csci306/CHAPTERS/Agile/AgileSection4.ppt Principles of Package Design (Colorado School of Mines)]&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_3_jn&amp;diff=26486</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 3 jn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_3_jn&amp;diff=26486"/>
		<updated>2009-11-09T17:56:25Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Common Closure Principle=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==TOC==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Definitions==&lt;br /&gt;
&lt;br /&gt;
*'''CCP (Common Closure Principle)''' - “The classes in a package should be closed against the same kinds of change; A change that affects a package affects all the classes in that package.” - R. Martin, 1996.  &lt;br /&gt;
&lt;br /&gt;
*'''OCP (Open Closed Principle)''' – &amp;quot;software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification&amp;quot; – Bertrand Meyer, 1988&lt;br /&gt;
&lt;br /&gt;
*'''REP (Reuse-Release Equivalence)''' – “The granule of reuse is the granule of release. Only components that are released through a tracking system can be efficiently reused.” -R. Martin, 1996&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What is CCP?==&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle is defined as “The classes in a package should be closed against the same kinds of change; A change that affects a package affects all the classes in that package.”  [R. Martin, 1996].  The real concept here is to ensure that all the classes within a single package are cohesive and decoupled from other classes as much as possible.  If you remember this is a typical design principle for classes that has been extended to entire package granularity.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle is closely associated with the Open Closed Principle. [[http://www.objectmentor.com/resources/articles/granularity.pdf Granularity]]  The CCP is targeted towards more accurately defining a specific requirement for the closure portion of OCP.  The OCP states that classes should be closed for modification but open for extension.  The key idea here is that we should be able to add more functionality to our code without altering the existing functionality in any way.  This ensures backwards compatibility for older code systems but allows for future improvements if needed.  This is directly tied to expected function signatures and expected function output values for any users that have developed on top of a previous package release.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle augments the OCP principle by specifying specific closure practices for a specific package.  The principle requires that if code must be modified, possibly for a bug or some other critical reason, then all of the required changes to resolve the issue should be limited to a single package.  CCP requires that if any two classes are so closely coupled that they will likely need to be edited in unison in the future that they be part of the same class.  The need for this principle is exemplified in the next section.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Why do we need to use CCP?==&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle is targeted at maintainability rather than reusability, which many times is much more important.  [[http://mcs.mines.edu/Courses/csci306/CHAPTERS/Agile/AgileSection4.ppt Principles of Package Design]]  We can clarify this concept by a simple example.  Imagine you are a project manager for a large java software project and after the release of the software you have uncovered a critical bug.  This bug pertained to a specific usage case which was not covered in your testing strategy and covers a wide number of classes.   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
!!Need Image that shows the two designs of the system.  IE One with multiple edits and the other with only one edit!!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now imagine that the work on your project has been divided up among smaller teams by the specific packages you have implemented.  Which would you rather have, a single team able to handle the entire code alteration ensuring that they can intracommunicate and that all the required changes are cohesive in the classes?   Or would you rather distribute the work and require a large amount of intercommunication between teams to ensure cohesion?  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The obvious answer from the example above is to allow a single team to handle the resolution of the problem.   This will simplify testing and integration of the next release by preventing separate teams from introducing separate bugs into the code and preventing the need for each of the packages to be revalidated independently.  Also this will correlate the resolution of the bug to a single package change which can make it easier to package and distribute the patch to clients.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Conflicting Principles==&lt;br /&gt;
&lt;br /&gt;
The CCP principle can sometimes lead to confusion when also considering the Reuse-Release Equivalence Principle.  This principle tells use to combine code into packages based on user convenience and usage patterns.  Essentially if classes are typically used in unison then why not package them together and prevent the users from defining multiple imports?  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Many users find it hard to find a balance between obeying both REP and CCP.  The trade off here is user convenience and maintainability.  Program designers need to be careful to separate new and moderately unstable code from older and highly stable code in packages when considering how to package code.  Maintainability and User Convenience are both very important considerations and a good balance for both need to be discovered when packaging code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
&lt;br /&gt;
[1] [http://en.wikipedia.org/wiki/Open/closed_principle The Open-Closed Principle]&lt;br /&gt;
&lt;br /&gt;
[2] [http://agileinaflash.blogspot.com/2009/07/principles-of-package-cohesion.html Principles of Package Cohesion]&lt;br /&gt;
&lt;br /&gt;
[3] [http://www2.cs.uh.edu/~svenkat/SoftwareDesign/slides/ObjectOrientedDesignPrinciples.pdf Object Oriented Design Principles]&lt;br /&gt;
&lt;br /&gt;
[4] [http://books.google.com/books?id=4pjbgVHzomsC&amp;amp;pg=PA26&amp;amp;lpg=PA26&amp;amp;dq=common+closure+principle&amp;amp;source=bl&amp;amp;ots=snjbB9n0Yf&amp;amp;sig=pHWv9VNcLH-uJGuiyoJjDbPmgnk&amp;amp;hl=en&amp;amp;ei=sif4Som8Dqrg8AaF_-DzCQ&amp;amp;sa=X&amp;amp;oi=book_result&amp;amp;ct=result&amp;amp;resnum=8&amp;amp;ved=0CBoQ6AEwBw#v=onepage&amp;amp;q=Open%20Closed&amp;amp;f=false Java Design: Objects, UML, and Process]&lt;br /&gt;
&lt;br /&gt;
[5] [http://www.objectmentor.com/resources/articles/granularity.pdf Granularity]&lt;br /&gt;
&lt;br /&gt;
[6] [http://ifacethoughts.net/2006/04/08/common-closure-principle/ Common Closure Principle (ifacethoughts.net)]&lt;br /&gt;
&lt;br /&gt;
[7] [http://missoula.vancouver.wsu.edu/cs320_Fall09/lectures/lecture16.ppt Object Orient Principles (Washington State University)]&lt;br /&gt;
&lt;br /&gt;
[8] [http://mcs.mines.edu/Courses/csci306/CHAPTERS/Agile/AgileSection4.ppt Principles of Package Design (Colorado School of Mines)]&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_3_jn&amp;diff=26485</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 3 jn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_3_jn&amp;diff=26485"/>
		<updated>2009-11-09T17:42:51Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Common Closure Principle=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==TOC==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Definitions==&lt;br /&gt;
&lt;br /&gt;
*'''CCP (Common Closure Principle)''' - “The classes in a package should be closed against the same kinds of change; A change that affects a package affects all the classes in that package.” - R. Martin, 1996.  &lt;br /&gt;
&lt;br /&gt;
*'''OCP (Open Closed Principle)''' – &amp;quot;software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification&amp;quot; – Bertrand Meyer, 1988&lt;br /&gt;
&lt;br /&gt;
*'''REP (Reuse-Release Equivalence)''' – “The granule of reuse is the granule of release. Only components that are released through a tracking system can be efficiently reused.” -R. Martin, 1996&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What is CCP?==&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle s defined as “The classes in a package should be closed against the same kinds of change; A change that affects a package affects all the classes in that package.”  [R. Martin, 1996].  The real concept here is to ensure that all the classes within a single package are cohesive and decoupled from other classes as much as possible.  If you remember this is a typical design principle for classes that for this principle has been extended to entire packages.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle is closely associated with the Open Closed Principle. The CCP is tightly connected with the closure portion of OCP.  The OCP states that classes should be closed for modification but open for extension. [[http://www.objectmentor.com/resources/articles/granularity.pdf Granularity]]  They key idea here is that we should be able to add more functionality to our code without altering the existing functionality in any way.  This ensures backwards compatibility for older code systems but allows for future improvements if needed.  This is directly tied to expected function signatures and expected function output values for any users that have developed on top of a previously used package.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle augments the OCP principle by specifying specific closure practices for a specific package.  The principle requires that if code must be modified, possibly for a bug or some other critical reason, then all of the required changes to resolve the issue should be limited to a single package.  CCP requires that if any two classes are so closely coupled that they will likely need to be edited in unison in the future that they be part of the same class.  The need for this principle is exemplified in the next section.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Why do we need to use CCP?==&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle is targeted at maintainability rather than reusability, which many times is much more important.  [[http://mcs.mines.edu/Courses/csci306/CHAPTERS/Agile/AgileSection4.ppt Principles of Package Design]]  We can clarify this concept by a simple example.  Imagine you are a project manager for a large java software project and after the release of the software you have uncovered a critical bug.  This bug pertained to a specific usage case which was not covered in your testing strategy and covers a wide number of classes.   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now imagine that the work on your project has been divided up among smaller teams by the specific packages you’ve implemented.  Which would you rather have, a single team able to handle the entire code alteration ensuring that they can intracommunicate and insure that all the required changes are cohesive in the classes?   Or would you rather distribute the work and require a large amount of intercommunication between teams to ensure cohesion?  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The obvious answer from the example above is to allow a single team to handle the resolution of the problem.   This will simplify testing and integration of the next release by preventing separate teams from introducing separate bugs into the code and preventing the need for each of the packages to be revalidated independently.  Also this will correlate the resolution of the bug to a single package change which can make it easier to distribute the patch to clients.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Conflicting Principles==&lt;br /&gt;
&lt;br /&gt;
The CCP principle can sometimes lead to confusion when also considering the Reuse-Release Equivalence Principle.  This principle tells use to combine code into packages based on user convenience and usage patterns.  Essentially if classes are typically used in unison then why not package them together?  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Many users find it hard to find a balance between obeying both REP and CCP.  The trade off here is user convenience and maintainability.  Program designers need to be careful to separate new and moderately unstable code from older and highly stable code in packages when considering how to package code for user convenience.  Maintainability and User Convenience are both very important and a good balance for both need to be discovered when packaging code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
&lt;br /&gt;
[1] [http://en.wikipedia.org/wiki/Open/closed_principle The Open-Closed Principle]&lt;br /&gt;
&lt;br /&gt;
[2] [http://agileinaflash.blogspot.com/2009/07/principles-of-package-cohesion.html Principles of Package Cohesion]&lt;br /&gt;
&lt;br /&gt;
[3] [http://www2.cs.uh.edu/~svenkat/SoftwareDesign/slides/ObjectOrientedDesignPrinciples.pdf Object Oriented Design Principles]&lt;br /&gt;
&lt;br /&gt;
[4] [http://books.google.com/books?id=4pjbgVHzomsC&amp;amp;pg=PA26&amp;amp;lpg=PA26&amp;amp;dq=common+closure+principle&amp;amp;source=bl&amp;amp;ots=snjbB9n0Yf&amp;amp;sig=pHWv9VNcLH-uJGuiyoJjDbPmgnk&amp;amp;hl=en&amp;amp;ei=sif4Som8Dqrg8AaF_-DzCQ&amp;amp;sa=X&amp;amp;oi=book_result&amp;amp;ct=result&amp;amp;resnum=8&amp;amp;ved=0CBoQ6AEwBw#v=onepage&amp;amp;q=Open%20Closed&amp;amp;f=false Java Design: Objects, UML, and Process]&lt;br /&gt;
&lt;br /&gt;
[5] [http://www.objectmentor.com/resources/articles/granularity.pdf Granularity]&lt;br /&gt;
&lt;br /&gt;
[6] [http://ifacethoughts.net/2006/04/08/common-closure-principle/ Common Closure Principle (ifacethoughts.net)]&lt;br /&gt;
&lt;br /&gt;
[7] [http://missoula.vancouver.wsu.edu/cs320_Fall09/lectures/lecture16.ppt Object Orient Principles (Washington State University)]&lt;br /&gt;
&lt;br /&gt;
[8] [http://mcs.mines.edu/Courses/csci306/CHAPTERS/Agile/AgileSection4.ppt Principles of Package Design (Colorado School of Mines)]&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_3_jn&amp;diff=26484</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 3 jn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_3_jn&amp;diff=26484"/>
		<updated>2009-11-09T17:34:22Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Common Closure Principle=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==TOC==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Definitions==&lt;br /&gt;
&lt;br /&gt;
*CCP (Common Closure Principle) - “The classes in a package should be closed against the same kinds of change; A change that affects a package affects all the classes in that package.” - R. Martin, 1996.  &lt;br /&gt;
&lt;br /&gt;
*OCP (Open Closed Principle) – &amp;quot;software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification&amp;quot; – Bertrand Meyer, 1988&lt;br /&gt;
&lt;br /&gt;
*REP (Reuse-Release Equivalence) – “The granule of reuse is the granule of release. Only components that are released through a tracking system can be efficiently reused.” -R. Martin, 1996&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What is CCP?==&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle s defined as “The classes in a package should be closed against the same kinds of change; A change that affects a package affects all the classes in that package.”  [R. Martin, 1996].  The real concept here is to ensure that all the classes within a single package are cohesive and decoupled from other classes as much as possible.  If you remember this is a typical design principle for classes that for this principle has been extended to entire packages.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle is closely associated with the Open Closed Principle. The CCP is tightly connected with the closure portion of OCP.  The OCP states that classes should be closed for modification but open for extension. [Granularity]  They key idea here is that we should be able to add more functionality to our code without altering the existing functionality in any way.  This ensures backwards compatibility for older code systems but allows for future improvements if needed.  This is directly tied to expected function signatures and expected function output values for any users that have developed on top of a previously used package.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle augments the OCP principle by specifying specific closure practices for a specific package.  The principle requires that if code must be modified, possibly for a bug or some other critical reason, then all of the required changes to resolve the issue should be limited to a single package.  CCP requires that if any two classes are so closely coupled that they will likely need to be edited in unison in the future that they be part of the same class.  The need for this principle is exemplified in the next section.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Why do we need to use CCP?==&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle is targeted at maintainability rather than reusability, which many times is much more important.  [Principles of Package Design]  We can clarify this concept by a simple example.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  Imagine you are a project manager for a large java software project and after the release of the software you have uncovered a critical bug.  This bug pertained to a specific usage case which was not covered in your testing strategy and covers a wide number of classes.   &lt;br /&gt;
&lt;br /&gt;
  Now imagine that the work on your project has been divided up among smaller teams by the specific packages you’ve implemented.  Which would you rather have, a single team able to handle the entire code alteration ensuring that they can intracommunicate and insure that all the required changes are cohesive in the classes?   Or would you rather distribute the work and require a large amount of intercommunication between teams to ensure cohesion?  &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The obvious answer from the example above is to allow a single team to handle the resolution of the problem.   This will simplify testing and integration of the next release by preventing separate teams from introducing separate bugs into the code and preventing the need for each of the packages to be revalidated independently.  Also this will correlate the resolution of the bug to a single package change which can make it easier to distribute the patch to clients.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Conflicting Principles==&lt;br /&gt;
&lt;br /&gt;
The CCP principle can sometimes lead to confusion when also considering the Reuse-Release Equivalence Principle.  This principle tells use to combine code into packages based on user convenience and usage patterns.  Essentially if classes are typically used in unison then why not package them together?  &lt;br /&gt;
&lt;br /&gt;
Many users find it hard to find a balance between obeying both REP and CCP.  The trade off here is user convenience and maintainability.  Program designers need to be careful to separate new and moderately unstable code from older and highly stable code in packages when considering how to package code for user convenience.  Maintainability and User Convenience are both very important and a good balance for both need to be discovered when packaging code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
&lt;br /&gt;
[1] [http://en.wikipedia.org/wiki/Open/closed_principle The Open-Closed Principle]&lt;br /&gt;
&lt;br /&gt;
[2] [http://agileinaflash.blogspot.com/2009/07/principles-of-package-cohesion.html Principles of Package Cohesion]&lt;br /&gt;
&lt;br /&gt;
[3] [http://www2.cs.uh.edu/~svenkat/SoftwareDesign/slides/ObjectOrientedDesignPrinciples.pdf Object Oriented Design Principles]&lt;br /&gt;
&lt;br /&gt;
[4] [http://books.google.com/books?id=4pjbgVHzomsC&amp;amp;pg=PA26&amp;amp;lpg=PA26&amp;amp;dq=common+closure+principle&amp;amp;source=bl&amp;amp;ots=snjbB9n0Yf&amp;amp;sig=pHWv9VNcLH-uJGuiyoJjDbPmgnk&amp;amp;hl=en&amp;amp;ei=sif4Som8Dqrg8AaF_-DzCQ&amp;amp;sa=X&amp;amp;oi=book_result&amp;amp;ct=result&amp;amp;resnum=8&amp;amp;ved=0CBoQ6AEwBw#v=onepage&amp;amp;q=Open%20Closed&amp;amp;f=false Java Design: Objects, UML, and Process]&lt;br /&gt;
&lt;br /&gt;
[5] [http://www.objectmentor.com/resources/articles/granularity.pdf Granularity]&lt;br /&gt;
&lt;br /&gt;
[6] [http://ifacethoughts.net/2006/04/08/common-closure-principle/ Common Closure Principle (ifacethoughts.net)]&lt;br /&gt;
&lt;br /&gt;
[7] [http://missoula.vancouver.wsu.edu/cs320_Fall09/lectures/lecture16.ppt Object Orient Principles (Washington State University)]&lt;br /&gt;
&lt;br /&gt;
[8] [http://mcs.mines.edu/Courses/csci306/CHAPTERS/Agile/AgileSection4.ppt Principles of Package Design (Colorado School of Mines)]&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_3_jn&amp;diff=26483</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 3 jn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_3_jn&amp;diff=26483"/>
		<updated>2009-11-09T17:32:28Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Common Closure Principle=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==TOC==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Definitions==&lt;br /&gt;
&lt;br /&gt;
*CCP (Common Closure Principle) - “The classes in a package should be closed against the same kinds of change; A change that affects a package affects all the classes in that package.” - R. Martin, 1996.  &lt;br /&gt;
&lt;br /&gt;
*OCP (Open Closed Principle) – &amp;quot;software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification&amp;quot; – Bertrand Meyer, 1988&lt;br /&gt;
&lt;br /&gt;
*REP (Reuse-Release Equivalence) – “The granule of reuse is the granule of release. Only components that are released through a tracking system can be efficiently reused.” -R. Martin, 1996&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What is CCP?==&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle s defined as “The classes in a package should be closed against the same kinds of change; A change that affects a package affects all the classes in that package.”  [R. Martin, 1996].  The real concept here is to ensure that all the classes within a single package are cohesive and decoupled from other classes as much as possible.  If you remember this is a typical design principle for classes that for this principle has been extended to entire packages.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle is closely associated with the Open Closed Principle. The CCP is tightly connected with the closure portion of OCP.  The OCP states that classes should be closed for modification but open for extension. [Granularity]  They key idea here is that we should be able to add more functionality to our code without altering the existing functionality in any way.  This ensures backwards compatibility for older code systems but allows for future improvements if needed.  This is directly tied to expected function signatures and expected function output values for any users that have developed on top of a previously used package.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle augments the OCP principle by specifying specific closure practices for a specific package.  The principle requires that if code must be modified, possibly for a bug or some other critical reason, then all of the required changes to resolve the issue should be limited to a single package.  CCP requires that if any two classes are so closely coupled that they will likely need to be edited in unison in the future that they be part of the same class.  The need for this principle is exemplified in the next section.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Why do we need to use CCP?==&lt;br /&gt;
&lt;br /&gt;
The Common Closure Principle is targeted at maintainability rather than reusability, which many times is much more important.  [Principles of Package Design]  We can clarify this concept by a simple example.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  Imagine you are a project manager for a large java software project and after the release of the software you have uncovered a critical bug.  This bug pertained to a specific usage case which was not covered in your testing strategy and covers a wide number of classes.   &lt;br /&gt;
&lt;br /&gt;
  Now imagine that the work on your project has been divided up among smaller teams by the specific packages you’ve implemented.  Which would you rather have, a single team able to handle the entire code alteration ensuring that they can intracommunicate and insure that all the required changes are cohesive in the classes?   Or would you rather distribute the work and require a large amount of intercommunication between teams to ensure cohesion?  &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The obvious answer from the example above is to allow a single team to handle the resolution of the problem.   This will simplify testing and integration of the next release by preventing separate teams from introducing separate bugs into the code and preventing the need for each of the packages to be revalidated independently.  Also this will correlate the resolution of the bug to a single package change which can make it easier to distribute the patch to clients.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Conflicting Principles==&lt;br /&gt;
&lt;br /&gt;
The CCP principle can sometimes lead to confusion when also considering the Reuse-Release Equivalence Principle.  This principle tells use to combine code into packages based on user convenience and usage patterns.  Essentially if classes are typically used in unison then why not package them together?  &lt;br /&gt;
&lt;br /&gt;
Many users find it hard to find a balance between obeying both REP and CCP.  The trade off here is user convenience and maintainability.  Program designers need to be careful to separate new and moderately unstable code from older and highly stable code in packages when considering how to package code for user convenience.  Maintainability and User Convenience are both very important and a good balance for both need to be discovered when packaging code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
&lt;br /&gt;
[1] [http://en.wikipedia.org/wiki/Open/closed_principle The Open-Closed Principle]&lt;br /&gt;
&lt;br /&gt;
http://agileinaflash.blogspot.com/2009/07/principles-of-package-cohesion.html - Principles of Package Cohesion&lt;br /&gt;
&lt;br /&gt;
http://www2.cs.uh.edu/~svenkat/SoftwareDesign/slides/ObjectOrientedDesignPrinciples.pdf - Object Oriented Design Principles&lt;br /&gt;
&lt;br /&gt;
http://books.google.com/books?id=4pjbgVHzomsC&amp;amp;pg=PA26&amp;amp;lpg=PA26&amp;amp;dq=common+closure+principle&amp;amp;source=bl&amp;amp;ots=snjbB9n0Yf&amp;amp;sig=pHWv9VNcLH-uJGuiyoJjDbPmgnk&amp;amp;hl=en&amp;amp;ei=sif4Som8Dqrg8AaF_-DzCQ&amp;amp;sa=X&amp;amp;oi=book_result&amp;amp;ct=result&amp;amp;resnum=8&amp;amp;ved=0CBoQ6AEwBw#v=onepage&amp;amp;q=Open%20Closed&amp;amp;f=false – Java Design: Objects, UML, and Process&lt;br /&gt;
http://www.objectmentor.com/resources/articles/granularity.pdf - Granularity&lt;br /&gt;
&lt;br /&gt;
http://ifacethoughts.net/2006/04/08/common-closure-principle/ - Common Closure Principle (ifacethoughts.net) &lt;br /&gt;
&lt;br /&gt;
http://missoula.vancouver.wsu.edu/cs320_Fall09/lectures/lecture16.ppt - Object Orient Principles (Washington State University)&lt;br /&gt;
&lt;br /&gt;
http://mcs.mines.edu/Courses/csci306/CHAPTERS/Agile/AgileSection4.ppt - Principles of Package Design (Colorado School of Mines)&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_3_jn&amp;diff=26481</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 3 jn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_3_jn&amp;diff=26481"/>
		<updated>2009-11-09T15:08:39Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Common Closure Principle=&lt;br /&gt;
&lt;br /&gt;
==TOC==&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=25810</id>
		<title>CSC/ECE 517 Fall 2009/wiki2 5 jn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=25810"/>
		<updated>2009-10-13T20:43:59Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Reflection APIs''' (Table of Contents)=&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
====What is Reflection?====&lt;br /&gt;
[http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection] in programming is a technique in which programs are able to dynamically view and alter their own structure and flow.  For example, in reflection one could determine method/variable/class names, add or delete method/variables, alter code to current methods, or simply alter values in variables.  Reflection is a subset of [http://en.wikipedia.org/wiki/Metaprogramming MetaProgramming] which relies heavily on the use of meta-information.  Meta-Information is used to keep track of the program structure such as names of available methods, variables and classes but also is what really makes reflection possible.  In theory there are nearly no bounds to reflection as it directly modifies the binary of the program.  The current limitations of this process are related to the APIs available for specific languages.  Majority of object-oriented languages have the functionality built in and some like C++ require external libraries to achieve even the basic functionality of Reflection.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===What languages are Supported?===&lt;br /&gt;
Due to the complexity required to support Reflection majority of the languages that support this feature tend to be object oriented.  Some examples of supported languages are [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/JavaScript JavaScript], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], and [http://en.wikipedia.org/wiki/ActionScript ActionScript].  In this page we will cover a select few of the languages above and what native API support is avaliable for each of the languages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Terminology=&lt;br /&gt;
&lt;br /&gt;
*'''[http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection]''' - the process by which a computer program can observe and modify its own structure and behavior.&lt;br /&gt;
&lt;br /&gt;
*'''[http://en.wikipedia.org/wiki/Meta_programming MetaProgramming]''' - the writing of computer programs that write or manipulate other programs (or themselves) as their data.&lt;br /&gt;
&lt;br /&gt;
*'''[http://www.geospatial.govt.nz/glossary/ MetaData]''' - &amp;quot;data about data&amp;quot;.  Describes how and when and by whom a particular set of data was collected, and how the data is formatted.&lt;br /&gt;
&lt;br /&gt;
*'''[http://en.wikipedia.org/wiki/Binding_(computer_science) Binding]''' - an object that encapsulates the execution context at some particular place in the code.&lt;br /&gt;
&lt;br /&gt;
*'''[http://en.wikipedia.org/wiki/Instance_(programming) Instance]''' - an object with functionality and information described by a class.&lt;br /&gt;
&lt;br /&gt;
*'''[http://en.wikipedia.org/wiki/Scope_(programming) Scope]''' - a location in a program where the value of the variable is available.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in C#=&lt;br /&gt;
&lt;br /&gt;
Reflection in C# is included in the [http://msdn.microsoft.com/en-us/netframework/default.aspx .NET framework] provided by [http://www.microsoft.com microsoft].  The methods and classes usable for reflection are accessed directly from the System.Reflection namespace and support any class type available under the .NET framework.  The basis of reflection in C# is powered by the Type class which is how metadata is accessed.  This Type object gives information about all available methods, variables, constructors, and more from a given class.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reflection in C# is not as dynamic as some other languages.  Particularly that it doesn't support the alteration of class variables, methods, and attributes.  As shown above the reflection implementation in C# is more for data collection and analysis for object types.  One of the best applications for Reflection in C# is the flexibility to dynamically load assembly code at runtime, ascertain information about the methods, variables and constructors, and then invoke code directly.  This type of usage makes examples especially hard to include in a short description.  For this reason the example has been simplified and is displayed below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
 public class Counter&lt;br /&gt;
 {&lt;br /&gt;
      // Private Variable&lt;br /&gt;
      private int ctr;&lt;br /&gt;
      // Constructor&lt;br /&gt;
      public Counter(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           ctr = temp;&lt;br /&gt;
      }&lt;br /&gt;
      // Increment&lt;br /&gt;
      public int Inc(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           return ctr+=temp;&lt;br /&gt;
      }&lt;br /&gt;
      // Decrement&lt;br /&gt;
      public int Dec(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           return ctr-=temp;&lt;br /&gt;
      }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Suppose we have the basic class as listed above.  There is only one constructor, one private instance variable, and two functions which increment or decrement the instance variable by a certain amount.  We could easily begin obtaining information about this class by performing the code below.&lt;br /&gt;
&lt;br /&gt;
 Counter myCtr = new Counter(1000);&lt;br /&gt;
 Type tempType = myCtr.GetType();&lt;br /&gt;
&lt;br /&gt;
From the instance of myCtr we were able to use the GetType method to instantiate and parse meta-information about the Counter class.  Keep in mind that this class could have been invoked at compile time and that we may have no previous information about it.  We could then dynamically determine what constructors and methods were available by performing the following actions.&lt;br /&gt;
&lt;br /&gt;
 ConstructorInfo [] c_info = tempType.GetConstructors();&lt;br /&gt;
 MethodInfo [] m_info = tempType.GetMethods();&lt;br /&gt;
&lt;br /&gt;
From these two lines of code we now have an array of information for both the available methods and the available constructors.  We can use the information in these two types to dynamically incorporate the class into the system at runtime.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====C# Conclusions=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The included [http://msdn.microsoft.com/en-us/library/ms173183(VS.80).aspx Reflection API] in the C# language creates a way for programmers to dynamically retrieve information from external assembly code.  They can then proceed to use that information to access the types available from the assembly.  While this is a difficult concept to grasp it does have its usages.  In the System.Reflection.Emit namespace there is a way to dynamically create types as well.  This form of reflection is typically used by script engines and compilers as they import and compile external types to be used in the current binaries.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in Java=&lt;br /&gt;
&lt;br /&gt;
Reflection in Java is much like the reflection available in C#.  Java's [http://java.sun.com/javase/7/docs/api/java/lang/reflect/package-summary.html Reflection API] is located in the java.lang.reflect package.  It makes it  possible for a programmer to dynamically parse information about classes, interfaces, methods, and fields at runtime.  With this information it is possible to dynamically incorporate these new classes into the running application.  Probably one of the best examples that this could be used for is the Netbeans compiler.  Netbeans is actually a java application which runs and compiles user's java applications.  Once the user chooses to run their code Netbeans then dynamically parses the classes and fields, then loads the class to be run.  Without reflection NetBean's functionality would not be possible. [http://tutorials.jenkov.com/java-reflection/index.html (Jenkov)]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Java actually has a few advantages over C# in that it can modify access to class fields and methods.  Once it has an instance of the class it can manually override the access and begin calling private and protected functions that users typically wouldn't be able to do.  This could be very useful for performing unit tests on a class since you now have access to all methods and fields.  An example of how both are performed is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example 1=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
     public class testClass {&lt;br /&gt;
        // Private Variable&lt;br /&gt;
        private String privateString = null;&lt;br /&gt;
        // Constructor&lt;br /&gt;
        public testClass(String temp) {&lt;br /&gt;
           privateString = temp;&lt;br /&gt;
        }&lt;br /&gt;
        // Private Method&lt;br /&gt;
        private String getString(){&lt;br /&gt;
          return privateString;&lt;br /&gt;
        }&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
Suppose we had the simple class shown above.  In this class we have both a private field and a private method which we wish to access to perform unit testing on.  Normally this could only be possible by creating public methods to call the private functions and getters and setters to change the fields.  With reflection we could perform the following instead.&lt;br /&gt;
&lt;br /&gt;
     // Create/Get an instance of the class.&lt;br /&gt;
     testClass m_Class = new testClass(&amp;quot;MyString&amp;quot;);&lt;br /&gt;
     // Get an instance of the field within the class&lt;br /&gt;
     Field m_Field = testClass.class.getDeclaredField(&amp;quot;privateString&amp;quot;);&lt;br /&gt;
     // Remove the access restricition on the variable&lt;br /&gt;
     m_Field.setAccessible(true);&lt;br /&gt;
     // Print the value of the field for a specific instance.&lt;br /&gt;
     System.out.println((String) m_Field.get(m_Class));&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The process of accomplishing this seems a bit daunting especially when you compare it to Ruby's implementation which is described later.  But the result is direct access to instance variables at run-time no matter what the restriction policy.  If we needed to access the private method we could accomplish that as shown below.&lt;br /&gt;
&lt;br /&gt;
     // Create/Get an instance of the class.&lt;br /&gt;
     testClass m_Class = new testClass(&amp;quot;MyString&amp;quot;);&lt;br /&gt;
     // Get an instance of the method within the class&lt;br /&gt;
     Method m_Method = testClass.class.getDeclaredMethod(&amp;quot;getString&amp;quot;, null);&lt;br /&gt;
     // Remove the access restricition on the method&lt;br /&gt;
     m_Method.setAccessible(true);&lt;br /&gt;
     // Print the result of method for a specific instance.&lt;br /&gt;
     System.out.println((String) m_Method.invoke(m_Class, null));&lt;br /&gt;
&lt;br /&gt;
The result is the same as from the previous section of code.  We simply accessed the private getter rather than calling the instance variable directly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example 2=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
In the C# example we were not able to present any code for dynamically loading classes into the running program due to the complexity and length.  Java has made this process relatively simple and only requires a few lines of code.  Below is how we could dynamically load our previous class example from an outside source.&lt;br /&gt;
&lt;br /&gt;
public class test2Class {&lt;br /&gt;
  // Main Method of invokiing class&lt;br /&gt;
  public static void main(String[] args){&lt;br /&gt;
    // Instance of a classloader as part of this class&lt;br /&gt;
    ClassLoader m_Loader = test2Class.class.getClassLoader();&lt;br /&gt;
    // Try/Catch Block&lt;br /&gt;
    try {&lt;br /&gt;
        Class m_Class = m_Loader.loadClass(&amp;quot;com.myClassPackage.testClass&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Successfully loaded class: &amp;quot; + m_Class.getName());&lt;br /&gt;
    } &lt;br /&gt;
    catch (ClassNotFoundException e) {&lt;br /&gt;
        System.err.println(e)    &lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The result from above is access to &amp;quot;testClass&amp;quot;. The test2Class loaded our example class from before.  From here we could now instantiate the class and call its functions (or search for what functions it has to offer).  This gives real insight to the flexibility of Java's Reflection API and how it could be practically used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Java Conclusions====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Java's [http://java.sun.com/javase/7/docs/api/java/lang/reflect/package-summary.html Reflection API] supplies a great deal of flexibility.  It allows the user almost complete access to classes as well as the ability to dynamically load new classes and utilize their functions.  While some of the method calls aren't trivial, majority of the coding is very useful once you understand the uses.  Java also has the added advantage to access private functions and variables of a class instance which can allow for easier unit testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in Ruby=&lt;br /&gt;
&lt;br /&gt;
The nature of Ruby as an object-oriented language gives great support for Reflection.  The big advantage to ruby is it gives us complete flexibility and control with reflection.  Most usages of reflection is only to obtain information and create new types dynamically but not modify current ones.  With Ruby's reflection API we have the ability to add or remove almost anything, whether that is a method, a class, or even the class variables.  Please note that this flexibility can also lead to a program's downfall as with any reflection API.  Too much alteration of the source code can cause many unknown bugs.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The current support for reflection in ruby is built into the language and is accessible through certain functions within the standard Ruby API.  The methods most commonly used for reflection in Ruby along with some basic examples of their usage are shown below.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Kernel.html#M005922 eval] method is defined in the Kernel Module of Ruby and is used to evaluate literals encompassed in strings.  This may not seem useful but the eval method also works in the scope of bindings.  Bindings represent the scope of execution at a particular place in the code.  This allows programmers to view any variables in any scope for any instance.  An example of eval's usage is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
          def getBinding&lt;br /&gt;
               return binding()&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar is and evaluate it without an accessor method&lt;br /&gt;
     eval(&amp;quot;@myvar&amp;quot;, test1.getBinding)   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
In this example we can see that by acquiring the binding at some scope in the program we can use it to get inside the context of any object instance and determine the value of any instance variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Instance Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Object.html#M000334 instance_eval] method is defined in the Object class and works within the instance of any class.  This method performs much of the same operations as the eval method but works in the scope of an object without requiring the binding statement as above.  In fact we can accomplish the same example as above with the code shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar is and evaluate it without an accessor method&lt;br /&gt;
     test1.instance_eval { @myvar }   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
Again this code performs exactly the same thing as the prior example above.  The result is 17 which is the evaluation of the string literal as a command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Class Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.src/M001650.html class_eval] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object whether that is assigning or accessing variables, declaring instance methods, or even re-defining inherited methods.  The method takes actions either via string literal or a block of code.  This method is one of the strongest and most versatile methods in the Ruby Reflection API.  It can access any private methods of any objects and its parents, thus giving you full control over the code.&lt;br /&gt;
&lt;br /&gt;
=====Example 1=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar by creating an accessor method for this instance.&lt;br /&gt;
     test1.class_eval{ def getVar; @myvar; end }&lt;br /&gt;
     eval(test1.getVar)   #=&amp;gt;  17&lt;br /&gt;
     #Or by simply accessing the local variable as below.&lt;br /&gt;
     eval(test1.class_eval{@myvar})    #=&amp;gt; 17&lt;br /&gt;
&lt;br /&gt;
This example shows the versatility of the class_eval method to work on any class instance.  It performs many of the operations that the previous methods have performed but with the added advantage of assigning instance methods.&lt;br /&gt;
&lt;br /&gt;
=====Example 2=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
       private:&lt;br /&gt;
          def increment&lt;br /&gt;
               @myvar += 1&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     #We can directly use class_eval to call private methods within a class as well.&lt;br /&gt;
     test1.class_eval{ increment() }   #=&amp;gt; 18&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval has even more flexibility to call private functions of a class from outside of the class scope. &lt;br /&gt;
&lt;br /&gt;
=====Example 3=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     # We can directly use class_eval to add variables to the instance of the class&lt;br /&gt;
     test1.class_eval{ instance_variable_set :@myvar2 , 25 }   &lt;br /&gt;
     test1.class_eval{ @myvar2 } #=&amp;gt; 25&lt;br /&gt;
     # Or We can remove variables from an instance of the class&lt;br /&gt;
     test1.class_eval{ remove_instance_variable :@myvar2 }&lt;br /&gt;
     test1.class_eval{ @myvar2 } #=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval is capable of defining and removing instance variables from the instance of a class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Define Method Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.html#M001654 define_method] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object to declare methods directly.  This method can be accomplished by using the class_eval method but is also a bit more flexible in it's notation.  An example of the use of this function is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;This is my String!&amp;quot;)&lt;br /&gt;
     #We can use define_method to create a instance method for this class with multiple parameters.&lt;br /&gt;
     test1.class_eval{ define_method(:getSubString){|start, end| @secret[start,end]} }&lt;br /&gt;
     test1.getSubString(5,9)   #=&amp;gt; &amp;quot;is my&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This example shows how to use define_method to create an instance method with multiple parameters by the common block notation.  Please not that we did have to use class_eval still to access the define_method.  This was due to the fact that define_method is a private method within the Module class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Ruby Conclusions====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The ruby language provides great support for reflection due to the nature of its design.  By using the class_eval method by itself one could completely encompass majority of the required reflection programming.  The other functions do provide some other basic support not granted to the class_eval function, specifically the eval function in combination with bindings.  The use of bindings allow the program to save the context of scope at some particular moment in the program and access it later.  With these functions ruby makes reflection simple.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusions=&lt;br /&gt;
&lt;br /&gt;
All of the Reflection APIs had one thing in common.  The ability to analyze classes and determine information about them from the available metadata.  C#'s API allows the usage of dynamically loaded classes but does not seem as trivial to use as the other APIs.  Java has taken it a step further and allows instance variables to be monitored during execution as well as the ability to call classes' private functions as needed.  Java has proven to be a very flexible reflection API.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The most flexible Reflection API by far is Ruby's.  The nature of Ruby's language allows it to dynamically create and destroy classes as well as variables and methods within the class.  No other language that we've seen will allow you to add or remove functionality of a class as needed during execution.  This allows Ruby programmers to invent new and interesting uses for this flexibility when designing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
[1] [http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection Wikipedia]&lt;br /&gt;
&lt;br /&gt;
[2] [http://www.codersource.net/published/view/291/reflection_in.aspx Reflection in C# - CoderSource.net]&lt;br /&gt;
&lt;br /&gt;
[3] [http://msdn.microsoft.com/en-us/library/f7ykdhsy.aspx MSDN Visual C# - Reflection Programmers Guide]&lt;br /&gt;
&lt;br /&gt;
[4] [http://www.khelll.com/blog/ruby/ruby-reflection/ Ruby Reflection]&lt;br /&gt;
&lt;br /&gt;
[5] [http://practicalruby.blogspot.com/2007/02/ruby-metaprogramming-introduction.html A Ruby Metaprogramming Introduction]&lt;br /&gt;
&lt;br /&gt;
[6] [http://books.google.com/books?id=jcUbTcr5XWwC&amp;amp;lpg=PA266&amp;amp;ots=fHFlsa2wgC&amp;amp;dq=Ruby%20Reflection%20API&amp;amp;pg=PA265#v=onepage&amp;amp;q=Ruby%20Reflection%20API&amp;amp;f=false Ruby Programming Language - Reflection and Metaprogramming]&lt;br /&gt;
&lt;br /&gt;
[7] [http://tutorials.jenkov.com/java-reflection/index.html Java Reflection Tutorial]&lt;br /&gt;
&lt;br /&gt;
[8] [http://java.sun.com/docs/books/tutorial/reflect/ Java Reflection API]&lt;br /&gt;
&lt;br /&gt;
[9] [http://java.sun.com/j2se/1.4.2/docs/api/java/lang/reflect/package-summary.html Java Reflection API Listing]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Related Topics=&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Meta_programming Wikipedia - MetaProgramming]&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Binding_(computer_science) Wikipedia - Binding]&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Interpreted_language Wikipedia - Interpreted Languages]&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=25808</id>
		<title>CSC/ECE 517 Fall 2009/wiki2 5 jn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=25808"/>
		<updated>2009-10-13T20:43:22Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Reflection APIs''' (Table of Contents)=&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
====What is Reflection?====&lt;br /&gt;
[http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection] in programming is a technique in which programs are able to dynamically view and alter their own structure and flow.  For example, in reflection one could determine method/variable/class names, add or delete method/variables, alter code to current methods, or simply alter values in variables.  Reflection is a subset of [http://en.wikipedia.org/wiki/Metaprogramming MetaProgramming] which relies heavily on the use of meta-information.  Meta-Information is used to keep track of the program structure such as names of available methods, variables and classes but also is what really makes reflection possible.  In theory there are nearly no bounds to reflection as it directly modifies the binary of the program.  The current limitations of this process are related to the APIs available for specific languages.  Majority of object-oriented languages have the functionality built in and some like C++ require external libraries to achieve even the basic functionality of Reflection.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===What languages are Supported?===&lt;br /&gt;
Due to the complexity required to support Reflection majority of the languages that support this feature tend to be object oriented.  Some examples of supported languages are [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/JavaScript JavaScript], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], and [http://en.wikipedia.org/wiki/ActionScript ActionScript].  In this page we will cover a select few of the languages above and what native API support is avaliable for each of the languages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Terminology=&lt;br /&gt;
&lt;br /&gt;
*'''[http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection]''' - the process by which a computer program can observe and modify its own structure and behavior.&lt;br /&gt;
&lt;br /&gt;
*'''[http://en.wikipedia.org/wiki/Meta_programming MetaProgramming]''' - the writing of computer programs that write or manipulate other programs (or themselves) as their data.&lt;br /&gt;
&lt;br /&gt;
*'''[http://www.geospatial.govt.nz/glossary/ MetaData]''' - &amp;quot;data about data&amp;quot;.  Describes how and when and by whom a particular set of data was collected, and how the data is formatted.&lt;br /&gt;
&lt;br /&gt;
*'''[http://en.wikipedia.org/wiki/Binding_(computer_science) Binding]''' - an object that encapsulates the execution context at some particular place in the code.&lt;br /&gt;
&lt;br /&gt;
*'''[http://en.wikipedia.org/wiki/Instance_(programming) Instance]''' - an object with functionality and information described by a class.&lt;br /&gt;
&lt;br /&gt;
*'''[http://en.wikipedia.org/wiki/Scope_(programming) Scope]''' - a location in a program where the value of the variable is available.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in C#=&lt;br /&gt;
&lt;br /&gt;
Reflection in C# is included in the [http://msdn.microsoft.com/en-us/netframework/default.aspx .NET framework] provided by [http://www.microsoft.com microsoft].  The methods and classes usable for reflection are accessed directly from the System.Reflection namespace and support any class type available under the .NET framework.  The basis of reflection in C# is powered by the Type class which is how metadata is accessed.  This Type object gives information about all available methods, variables, constructors, and more from a given class.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reflection in C# is not as dynamic as some other languages.  Particularly that it doesn't support the alteration of class variables, methods, and attributes.  As shown above the reflection implementation in C# is more for data collection and analysis for object types.  One of the best applications for Reflection in C# is the flexibility to dynamically load assembly code at runtime, ascertain information about the methods, variables and constructors, and then invoke code directly.  This type of usage makes examples especially hard to include in a short description.  For this reason the example has been simplified and is displayed below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
 public class Counter&lt;br /&gt;
 {&lt;br /&gt;
      // Private Variable&lt;br /&gt;
      private int ctr;&lt;br /&gt;
      // Constructor&lt;br /&gt;
      public Counter(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           ctr = temp;&lt;br /&gt;
      }&lt;br /&gt;
      // Increment&lt;br /&gt;
      public int Inc(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           return ctr+=temp;&lt;br /&gt;
      }&lt;br /&gt;
      // Decrement&lt;br /&gt;
      public int Dec(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           return ctr-=temp;&lt;br /&gt;
      }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Suppose we have the basic class as listed above.  There is only one constructor, one private instance variable, and two functions which increment or decrement the instance variable by a certain amount.  We could easily begin obtaining information about this class by performing the code below.&lt;br /&gt;
&lt;br /&gt;
 Counter myCtr = new Counter(1000);&lt;br /&gt;
 Type tempType = myCtr.GetType();&lt;br /&gt;
&lt;br /&gt;
From the instance of myCtr we were able to use the GetType method to instantiate and parse meta-information about the Counter class.  Keep in mind that this class could have been invoked at compile time and that we may have no previous information about it.  We could then dynamically determine what constructors and methods were available by performing the following actions.&lt;br /&gt;
&lt;br /&gt;
 ConstructorInfo [] c_info = tempType.GetConstructors();&lt;br /&gt;
 MethodInfo [] m_info = tempType.GetMethods();&lt;br /&gt;
&lt;br /&gt;
From these two lines of code we now have an array of information for both the available methods and the available constructors.  We can use the information in these two types to dynamically incorporate the class into the system at runtime.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====C# Conclusions=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The included [http://msdn.microsoft.com/en-us/library/ms173183(VS.80).aspx Reflection API] in the C# language creates a way for programmers to dynamically retrieve information from external assembly code.  They can then proceed to use that information to access the types available from the assembly.  While this is a difficult concept to grasp it does have its usages.  In the System.Reflection.Emit namespace there is a way to dynamically create types as well.  This form of reflection is typically used by script engines and compilers as they import and compile external types to be used in the current binaries.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in Java=&lt;br /&gt;
&lt;br /&gt;
Reflection in Java is much like the reflection available in C#.  Java's [http://java.sun.com/javase/7/docs/api/java/lang/reflect/package-summary.html Reflection API] is located in the java.lang.reflect package.  It makes it  possible for a programmer to dynamically parse information about classes, interfaces, methods, and fields at runtime.  With this information it is possible to dynamically incorporate these new classes into the running application.  Probably one of the best examples that this could be used for is the Netbeans compiler.  Netbeans is actually a java application which runs and compiles user's java applications.  Once the user chooses to run their code Netbeans then dynamically parses the classes and fields, then loads the class to be run.  Without reflection NetBean's functionality would not be possible. [http://tutorials.jenkov.com/java-reflection/index.html (Jenkov)]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Java actually has a few advantages over C# in that it can modify access to class fields and methods.  Once it has an instance of the class it can manually override the access and begin calling private and protected functions that users typically wouldn't be able to do.  This could be very useful for performing unit tests on a class since you now have access to all methods and fields.  An example of how both are performed is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example 1=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
     public class testClass {&lt;br /&gt;
        // Private Variable&lt;br /&gt;
        private String privateString = null;&lt;br /&gt;
        // Constructor&lt;br /&gt;
        public testClass(String temp) {&lt;br /&gt;
           privateString = temp;&lt;br /&gt;
        }&lt;br /&gt;
        // Private Method&lt;br /&gt;
        private String getString(){&lt;br /&gt;
          return privateString;&lt;br /&gt;
        }&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
Suppose we had the simple class shown above.  In this class we have both a private field and a private method which we wish to access to perform unit testing on.  Normally this could only be possible by creating public methods to call the private functions and getters and setters to change the fields.  With reflection we could perform the following instead.&lt;br /&gt;
&lt;br /&gt;
     // Create/Get an instance of the class.&lt;br /&gt;
     testClass m_Class = new testClass(&amp;quot;MyString&amp;quot;);&lt;br /&gt;
     // Get an instance of the field within the class&lt;br /&gt;
     Field m_Field = testClass.class.getDeclaredField(&amp;quot;privateString&amp;quot;);&lt;br /&gt;
     // Remove the access restricition on the variable&lt;br /&gt;
     m_Field.setAccessible(true);&lt;br /&gt;
     // Print the value of the field for a specific instance.&lt;br /&gt;
     System.out.println((String) m_Field.get(m_Class));&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The process of accomplishing this seems a bit daunting especially when you compare it to Ruby's implementation which is described later.  But the result is direct access to instance variables at run-time no matter what the restriction policy.  If we needed to access the private method we could accomplish that as shown below.&lt;br /&gt;
&lt;br /&gt;
     // Create/Get an instance of the class.&lt;br /&gt;
     testClass m_Class = new testClass(&amp;quot;MyString&amp;quot;);&lt;br /&gt;
     // Get an instance of the method within the class&lt;br /&gt;
     Method m_Method = testClass.class.getDeclaredMethod(&amp;quot;getString&amp;quot;, null);&lt;br /&gt;
     // Remove the access restricition on the method&lt;br /&gt;
     m_Method.setAccessible(true);&lt;br /&gt;
     // Print the result of method for a specific instance.&lt;br /&gt;
     System.out.println((String) m_Method.invoke(m_Class, null));&lt;br /&gt;
&lt;br /&gt;
The result is the same as from the previous section of code.  We simply accessed the private getter rather than calling the instance variable directly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example 2=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
In the C# example we were not able to present any code for dynamically loading classes into the running program due to the complexity and length.  Java has made this process relatively simple and only requires a few lines of code.  Below is how we could dynamically load our previous class example from an outside source.&lt;br /&gt;
&lt;br /&gt;
public class test2Class {&lt;br /&gt;
  // Main Method of invokiing class&lt;br /&gt;
  public static void main(String[] args){&lt;br /&gt;
    // Instance of a classloader as part of this class&lt;br /&gt;
    ClassLoader m_Loader = test2Class.class.getClassLoader();&lt;br /&gt;
    // Try/Catch Block&lt;br /&gt;
    try {&lt;br /&gt;
        Class m_Class = m_Loader.loadClass(&amp;quot;com.myClassPackage.testClass&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Successfully loaded class: &amp;quot; + m_Class.getName());&lt;br /&gt;
    } &lt;br /&gt;
    catch (ClassNotFoundException e) {&lt;br /&gt;
        System.err.println(e)    &lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The result from above is access to &amp;quot;testClass&amp;quot;. The test2Class loaded our example class from before.  From here we could now instantiate the class and call its functions (or search for what functions it has to offer).  This gives real insight to the flexibility of Java's Reflection API and how it could be practically used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Java Conclusions====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Java's [http://java.sun.com/javase/7/docs/api/java/lang/reflect/package-summary.html Reflection API] supplies a great deal of flexibility.  It allows the user almost complete access to classes as well as the ability to dynamically load new classes and utilize their functions.  While some of the method calls aren't trivial, majority of the coding is very useful once you understand the uses.  Java also has the added advantage to access private functions and variables of a class instance which can allow for easier unit testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in Ruby=&lt;br /&gt;
&lt;br /&gt;
The nature of Ruby as an object-oriented language gives great support for Reflection.  The big advantage to ruby is it gives us complete flexibility and control with reflection.  Most usages of reflection is only to obtain information and create new types dynamically but not modify current ones.  With Ruby's reflection API we have the ability to add or remove almost anything, whether that is a method, a class, or even the class variables.  Please note that this flexibility can also lead to a program's downfall as with any reflection API.  Too much alteration of the source code can cause many unknown bugs.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The current support for reflection in ruby is built into the language and is accessible through certain functions within the standard Ruby API.  The methods most commonly used for reflection in Ruby along with some basic examples of their usage are shown below.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Kernel.html#M005922 eval] method is defined in the Kernel Module of Ruby and is used to evaluate literals encompassed in strings.  This may not seem useful but the eval method also works in the scope of bindings.  Bindings represent the scope of execution at a particular place in the code.  This allows programmers to view any variables in any scope for any instance.  An example of eval's usage is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
          def getBinding&lt;br /&gt;
               return binding()&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar is and evaluate it without an accessor method&lt;br /&gt;
     eval(&amp;quot;@myvar&amp;quot;, test1.getBinding)   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
In this example we can see that by acquiring the binding at some scope in the program we can use it to get inside the context of any object instance and determine the value of any instance variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Instance Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Object.html#M000334 instance_eval] method is defined in the Object class and works within the instance of any class.  This method performs much of the same operations as the eval method but works in the scope of an object without requiring the binding statement as above.  In fact we can accomplish the same example as above with the code shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar is and evaluate it without an accessor method&lt;br /&gt;
     test1.instance_eval { @myvar }   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
Again this code performs exactly the same thing as the prior example above.  The result is 17 which is the evaluation of the string literal as a command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Class Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.src/M001650.html class_eval] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object whether that is assigning or accessing variables, declaring instance methods, or even re-defining inherited methods.  The method takes actions either via string literal or a block of code.  This method is one of the strongest and most versatile methods in the Ruby Reflection API.  It can access any private methods of any objects and its parents, thus giving you full control over the code.&lt;br /&gt;
&lt;br /&gt;
=====Example 1=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar by creating an accessor method for this instance.&lt;br /&gt;
     test1.class_eval{ def getVar; @myvar; end }&lt;br /&gt;
     eval(test1.getVar)   #=&amp;gt;  17&lt;br /&gt;
     #Or by simply accessing the local variable as below.&lt;br /&gt;
     eval(test1.class_eval{@myvar})    #=&amp;gt; 17&lt;br /&gt;
&lt;br /&gt;
This example shows the versatility of the class_eval method to work on any class instance.  It performs many of the operations that the previous methods have performed but with the added advantage of assigning instance methods.&lt;br /&gt;
&lt;br /&gt;
=====Example 2=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
       private:&lt;br /&gt;
          def increment&lt;br /&gt;
               @myvar += 1&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     #We can directly use class_eval to call private methods within a class as well.&lt;br /&gt;
     test1.class_eval{ increment() }   #=&amp;gt; 18&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval has even more flexibility to call private functions of a class from outside of the class scope. &lt;br /&gt;
&lt;br /&gt;
=====Example 3=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     # We can directly use class_eval to add variables to the instance of the class&lt;br /&gt;
     test1.class_eval{ instance_variable_set :@myvar2 , 25 }   &lt;br /&gt;
     test1.class_eval{ @myvar2 } #=&amp;gt; 25&lt;br /&gt;
     # Or We can remove variables from an instance of the class&lt;br /&gt;
     test1.class_eval{ remove_instance_variable :@myvar2 }&lt;br /&gt;
     test1.class_eval{ @myvar2 } #=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval is capable of defining and removing instance variables from the instance of a class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Define Method Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.html#M001654 define_method] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object to declare methods directly.  This method can be accomplished by using the class_eval method but is also a bit more flexible in it's notation.  An example of the use of this function is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;This is my String!&amp;quot;)&lt;br /&gt;
     #We can use define_method to create a instance method for this class with multiple parameters.&lt;br /&gt;
     test1.class_eval{ define_method(:getSubString){|start, end| @secret[start,end]} }&lt;br /&gt;
     test1.getSubString(5,9)   #=&amp;gt; &amp;quot;is my&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This example shows how to use define_method to create an instance method with multiple parameters by the common block notation.  Please not that we did have to use class_eval still to access the define_method.  This was due to the fact that define_method is a private method within the Module class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Ruby Conclusions====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The ruby language provides great support for reflection due to the nature of its design.  By using the class_eval method by itself one could completely encompass majority of the required reflection programming.  The other functions do provide some other basic support not granted to the class_eval function, specifically the eval function in combination with bindings.  The use of bindings allow the program to save the context of scope at some particular moment in the program and access it later.  With these functions ruby makes reflection simple.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusions=&lt;br /&gt;
&lt;br /&gt;
All of the Reflection APIs had one thing in common.  The ability to analyze classes and determine information about them from the available metadata.  C#'s API allows the usage of dynamically loaded classes but does not seem as trivial to use as the other APIs.  Java has taken it a step further and allows instance variables to be monitored during execution as well as the ability to call classes' private functions as needed.  Java has proven to be a very flexible reflection API.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The most flexible Reflection API by far is Ruby's.  The nature of Ruby's language allows it to dynamically create and destroy classes as well as variables and methods within the class.  No other language that we've seen will allow you to add or remove functionality of a class as needed during execution.  This allows Ruby programmers to invent new and interesting uses for this flexibility when designing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
[1] [http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection Wikipedia]&lt;br /&gt;
&lt;br /&gt;
[2] [http://www.codersource.net/published/view/291/reflection_in.aspx Reflection in C# - CoderSource.net]&lt;br /&gt;
&lt;br /&gt;
[3] [http://msdn.microsoft.com/en-us/library/f7ykdhsy.aspx MSDN Visual C# - Reflection Programmers Guide]&lt;br /&gt;
&lt;br /&gt;
[4] [http://www.khelll.com/blog/ruby/ruby-reflection/ Ruby Reflection]&lt;br /&gt;
&lt;br /&gt;
[5] [http://practicalruby.blogspot.com/2007/02/ruby-metaprogramming-introduction.html A Ruby Metaprogramming Introduction]&lt;br /&gt;
&lt;br /&gt;
[6] [http://books.google.com/books?id=jcUbTcr5XWwC&amp;amp;lpg=PA266&amp;amp;ots=fHFlsa2wgC&amp;amp;dq=Ruby%20Reflection%20API&amp;amp;pg=PA265#v=onepage&amp;amp;q=Ruby%20Reflection%20API&amp;amp;f=false Ruby Programming Language - Reflection and Metaprogramming]&lt;br /&gt;
&lt;br /&gt;
[7] [http://tutorials.jenkov.com/java-reflection/index.html Java Reflection Tutorial]&lt;br /&gt;
&lt;br /&gt;
[8] [http://java.sun.com/docs/books/tutorial/reflect/ Java Reflection API]&lt;br /&gt;
&lt;br /&gt;
[9] [http://java.sun.com/j2se/1.4.2/docs/api/java/lang/reflect/package-summary.html Java Reflection API Listing]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Further Reading=&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Meta_programming Wikipedia - MetaProgramming]&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Binding_(computer_science) Wikipedia - Binding]&lt;br /&gt;
&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Interpreted_language Wikipedia - Interpreted Languages]&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=25805</id>
		<title>CSC/ECE 517 Fall 2009/wiki2 5 jn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=25805"/>
		<updated>2009-10-13T20:27:32Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Reflection APIs''' (Table of Contents)=&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
====What is Reflection?====&lt;br /&gt;
[http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection] in programming is a technique in which programs are able to dynamically view and alter their own structure and flow.  For example, in reflection one could determine method/variable/class names, add or delete method/variables, alter code to current methods, or simply alter values in variables.  Reflection is a subset of [http://en.wikipedia.org/wiki/Metaprogramming MetaProgramming] which relies heavily on the use of meta-information.  Meta-Information is used to keep track of the program structure such as names of available methods, variables and classes but also is what really makes reflection possible.  In theory there are nearly no bounds to reflection as it directly modifies the binary of the program.  The current limitations of this process are related to the APIs available for specific languages.  Majority of object-oriented languages have the functionality built in and some like C++ require external libraries to achieve even the basic functionality of Reflection.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===What languages are Supported?===&lt;br /&gt;
Due to the complexity required to support Reflection majority of the languages that support this feature tend to be object oriented.  Some examples of supported languages are [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/JavaScript JavaScript], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], and [http://en.wikipedia.org/wiki/ActionScript ActionScript].  In this page we will cover a select few of the languages above and what native API support is avaliable for each of the languages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Terminology=&lt;br /&gt;
&lt;br /&gt;
*'''[http://www.google.com/url?q=http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection]''' - the process by which a computer program can observe and modify its own structure and behavior.&lt;br /&gt;
&lt;br /&gt;
*'''[http://www.google.com/url?q=http://en.wikipedia.org/wiki/Meta_programming MetaProgramming]''' - the writing of computer programs that write or manipulate other programs (or themselves) as their data.&lt;br /&gt;
&lt;br /&gt;
*'''[http://www.google.com/url?q=http://www.geospatial.govt.nz/glossary/ MetaData]''' - &amp;quot;data about data&amp;quot;.  Describes how and when and by whom a particular set of data was collected, and how the data is formatted.&lt;br /&gt;
&lt;br /&gt;
*'''[http://www.google.com/url?q=http://en.wikipedia.org/wiki/Binding_(computer_science) Binding]''' - an object that encapsulates the execution context at some particular place in the code.&lt;br /&gt;
&lt;br /&gt;
*'''[http://www.google.com/url?q=http://en.wikipedia.org/wiki/Instance_(programming) Instance]''' - an object with functionality and information described by a class.&lt;br /&gt;
&lt;br /&gt;
*'''[http://www.google.com/url?q=http://en.wikipedia.org/wiki/Scope_(programming) Scope]''' - a location in a program where the value of the variable is available.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in C#=&lt;br /&gt;
&lt;br /&gt;
Reflection in C# is included in the .NET framework provided by microsoft.  The methods and classes usable for reflection are accessed directly from the System.Reflection namespace and support any class type available under the .NET framework.  The basis of reflection in C# is powered by the Type class which is how metadata is accessed.  This Type object gives information about all available methods, variables, constructors, and more from a given class.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reflection in C# is not as dynamic as some other languages.  Particularly that it doesn't support the alteration of class variables, methods, and attributes.  As shown above the reflection implementation in C# is more for data collection and analysis for object types.  One of the best applications for Reflection in C# is the flexibility to dynamically load assembly code at runtime, ascertain information about the methods, variables and constructors, and then invoke code directly.  This type of usage makes examples especially hard to include in a short description.  For this reason the example has been simplified and is displayed below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
 public class Counter&lt;br /&gt;
 {&lt;br /&gt;
      // Private Variable&lt;br /&gt;
      private int ctr;&lt;br /&gt;
      // Constructor&lt;br /&gt;
      public Counter(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           ctr = temp;&lt;br /&gt;
      }&lt;br /&gt;
      // Increment&lt;br /&gt;
      public int Inc(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           return ctr+=temp;&lt;br /&gt;
      }&lt;br /&gt;
      // Decrement&lt;br /&gt;
      public int Dec(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           return ctr-=temp;&lt;br /&gt;
      }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Suppose we have the basic class as listed above.  There is only one constructor, one private instance variable, and two functions which increment or decrement the instance variable by a certain amount.  We could easily begin obtaining information about this class by performing the code below.&lt;br /&gt;
&lt;br /&gt;
 Counter myCtr = new Counter(1000);&lt;br /&gt;
 Type tempType = myCtr.GetType();&lt;br /&gt;
&lt;br /&gt;
From the instance of myCtr we were able to use the GetType method to instantiate and parse meta-information about the Counter class.  Keep in mind that this class could have been invoked at compile time and that we may have no previous information about it.  We could then dynamically determine what constructors and methods were available by performing the following actions.&lt;br /&gt;
&lt;br /&gt;
 ConstructorInfo [] c_info = tempType.GetConstructors();&lt;br /&gt;
 MethodInfo [] m_info = tempType.GetMethods();&lt;br /&gt;
&lt;br /&gt;
From these two lines of code we now have an array of information for both the available methods and the available constructors.  We can use the information in these two types to dynamically incorporate the class into the system at runtime.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====C# Conclusions=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The included [http://msdn.microsoft.com/en-us/library/ms173183(VS.80).aspx Reflection API] in the C# language creates a way for programmers to dynamically retrieve information from external assembly code.  They can then proceed to use that information to access the types available from the assembly.  While this is a difficult concept to grasp it does have its usages.  In the System.Reflection.Emit namespace there is a way to dynamically create types as well.  This form of reflection is typically used by script engines and compilers as they import and compile external types to be used in the current binaries.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in Java=&lt;br /&gt;
&lt;br /&gt;
Reflection in Java is much like the reflection available in C#.  Java's Reflection API is located in the java.lang.reflect package.  It makes it  possible for a programmer to dynamically parse information about classes, interfaces, methods, and fields at runtime.  With this information it is possible to dynamically incorporate these new classes into the running application.  Probably one of the best examples that this could be used for is the Netbeans compiler.  Netbeans is actually a java application which runs and compiles user's java applications.  Once the user chooses to run their code Netbeans then dynamically parses the classes and fields, then loads the class to be run.  Without reflection NetBean's functionality would not be possible. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Java actually has a few advantages over C# in that it can modify access to class fields and methods.  Once it has an instance of the class it can manually override the access and begin calling private and protected functions that users typically wouldn't be able to do.  This could be very useful for performing unit tests on a class since you now have access to all methods and fields.  An example of how both are performed is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example 1=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
     public class testClass {&lt;br /&gt;
        // Private Variable&lt;br /&gt;
        private String privateString = null;&lt;br /&gt;
        // Constructor&lt;br /&gt;
        public testClass(String temp) {&lt;br /&gt;
           privateString = temp;&lt;br /&gt;
        }&lt;br /&gt;
        // Private Method&lt;br /&gt;
        private String getString(){&lt;br /&gt;
          return privateString;&lt;br /&gt;
        }&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
Suppose we had the simple class shown above.  In this class we have both a private field and a private method which we wish to access to perform unit testing on.  Normally this could only be possible by creating public methods to call the private functions and getters and setters to change the fields.  With reflection we could perform the following instead.&lt;br /&gt;
&lt;br /&gt;
     // Create/Get an instance of the class.&lt;br /&gt;
     testClass m_Class = new testClass(&amp;quot;MyString&amp;quot;);&lt;br /&gt;
     // Get an instance of the field within the class&lt;br /&gt;
     Field m_Field = testClass.class.getDeclaredField(&amp;quot;privateString&amp;quot;);&lt;br /&gt;
     // Remove the access restricition on the variable&lt;br /&gt;
     m_Field.setAccessible(true);&lt;br /&gt;
     // Print the value of the field for a specific instance.&lt;br /&gt;
     System.out.println((String) m_Field.get(m_Class));&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The process of accomplishing this seems a bit daunting especially when you compare it to Ruby's implementation which is described later.  But the result is direct access to instance variables at run-time no matter what the restriction policy.  If we needed to access the private method we could accomplish that as shown below.&lt;br /&gt;
&lt;br /&gt;
     // Create/Get an instance of the class.&lt;br /&gt;
     testClass m_Class = new testClass(&amp;quot;MyString&amp;quot;);&lt;br /&gt;
     // Get an instance of the method within the class&lt;br /&gt;
     Method m_Method = testClass.class.getDeclaredMethod(&amp;quot;getString&amp;quot;, null);&lt;br /&gt;
     // Remove the access restricition on the method&lt;br /&gt;
     m_Method.setAccessible(true);&lt;br /&gt;
     // Print the result of method for a specific instance.&lt;br /&gt;
     System.out.println((String) m_Method.invoke(m_Class, null));&lt;br /&gt;
&lt;br /&gt;
The result is the same as from the previous section of code.  We simply accessed the private getter rather than calling the instance variable directly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example 2=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
In the C# example we were not able to present any code for dynamically loading classes into the running program due to the complexity and length.  Java has made this process relatively simple and only requires a few lines of code.  Below is how we could dynamically load our previous class example from an outside source.&lt;br /&gt;
&lt;br /&gt;
public class test2Class {&lt;br /&gt;
  // Main Method of invokiing class&lt;br /&gt;
  public static void main(String[] args){&lt;br /&gt;
    // Instance of a classloader as part of this class&lt;br /&gt;
    ClassLoader m_Loader = test2Class.class.getClassLoader();&lt;br /&gt;
    // Try/Catch Block&lt;br /&gt;
    try {&lt;br /&gt;
        Class m_Class = m_Loader.loadClass(&amp;quot;com.myClassPackage.testClass&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Successfully loaded class: &amp;quot; + m_Class.getName());&lt;br /&gt;
    } &lt;br /&gt;
    catch (ClassNotFoundException e) {&lt;br /&gt;
        System.err.println(e)    &lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The result from above is access to &amp;quot;testClass&amp;quot;. The test2Class loaded our example class from before.  From here we could now instantiate the class and call its functions (or search for what functions it has to offer).  This gives real insight to the flexibility of Java's Reflection API and how it could be practically used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Java Conclusions====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Java's [http://java.sun.com/javase/7/docs/api/java/lang/reflect/package-summary.html Reflection API] supplies a great deal of flexibility.  It allows the user almost complete access to classes as well as the ability to dynamically load new classes and utilize their functions.  While some of the method calls aren't trivial, majority of the coding is very useful once you understand the uses.  Java also has the added advantage to access private functions and variables of a class instance which can allow for easier unit testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in Ruby=&lt;br /&gt;
&lt;br /&gt;
The nature of Ruby as an object-oriented language gives great support for Reflection.  The big advantage to ruby is it gives us complete flexibility and control with reflection.  Most usages of reflection is only to obtain information and create new types dynamically but not modify current ones.  With Ruby's reflection API we have the ability to add or remove almost anything, whether that is a method, a class, or even the class variables.  Please note that this flexibility can also lead to a program's downfall as with any reflection API.  Too much alteration of the source code can cause many unknown bugs.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The current support for reflection in ruby is built into the language and is accessible through certain functions within the standard Ruby API.  The methods most commonly used for reflection in Ruby along with some basic examples of their usage are shown below.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Kernel.html#M005922 eval] method is defined in the Kernel Module of Ruby and is used to evaluate literals encompassed in strings.  This may not seem useful but the eval method also works in the scope of bindings.  Bindings represent the scope of execution at a particular place in the code.  This allows programmers to view any variables in any scope for any instance.  An example of eval's usage is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
          def getBinding&lt;br /&gt;
               return binding()&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar is and evaluate it without an accessor method&lt;br /&gt;
     eval(&amp;quot;@myvar&amp;quot;, test1.getBinding)   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
In this example we can see that by acquiring the binding at some scope in the program we can use it to get inside the context of any object instance and determine the value of any instance variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Instance Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Object.html#M000334 instance_eval] method is defined in the Object class and works within the instance of any class.  This method performs much of the same operations as the eval method but works in the scope of an object without requiring the binding statement as above.  In fact we can accomplish the same example as above with the code shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar is and evaluate it without an accessor method&lt;br /&gt;
     test1.instance_eval { @myvar }   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
Again this code performs exactly the same thing as the prior example above.  The result is 17 which is the evaluation of the string literal as a command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Class Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.src/M001650.html class_eval] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object whether that is assigning or accessing variables, declaring instance methods, or even re-defining inherited methods.  The method takes actions either via string literal or a block of code.  This method is one of the strongest and most versatile methods in the Ruby Reflection API.  It can access any private methods of any objects and its parents, thus giving you full control over the code.&lt;br /&gt;
&lt;br /&gt;
=====Example 1=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar by creating an accessor method for this instance.&lt;br /&gt;
     test1.class_eval{ def getVar; @myvar; end }&lt;br /&gt;
     eval(test1.getVar)   #=&amp;gt;  17&lt;br /&gt;
     #Or by simply accessing the local variable as below.&lt;br /&gt;
     eval(test1.class_eval{@myvar})    #=&amp;gt; 17&lt;br /&gt;
&lt;br /&gt;
This example shows the versatility of the class_eval method to work on any class instance.  It performs many of the operations that the previous methods have performed but with the added advantage of assigning instance methods.&lt;br /&gt;
&lt;br /&gt;
=====Example 2=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
       private:&lt;br /&gt;
          def increment&lt;br /&gt;
               @myvar += 1&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     #We can directly use class_eval to call private methods within a class as well.&lt;br /&gt;
     test1.class_eval{ increment() }   #=&amp;gt; 18&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval has even more flexibility to call private functions of a class from outside of the class scope. &lt;br /&gt;
&lt;br /&gt;
=====Example 3=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     # We can directly use class_eval to add variables to the instance of the class&lt;br /&gt;
     test1.class_eval{ instance_variable_set :@myvar2 , 25 }   &lt;br /&gt;
     test1.class_eval{ @myvar2 } #=&amp;gt; 25&lt;br /&gt;
     # Or We can remove variables from an instance of the class&lt;br /&gt;
     test1.class_eval{ remove_instance_variable :@myvar2 }&lt;br /&gt;
     test1.class_eval{ @myvar2 } #=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval is capable of defining and removing instance variables from the instance of a class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Define Method Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.html#M001654 define_method] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object to declare methods directly.  This method can be accomplished by using the class_eval method but is also a bit more flexible in it's notation.  An example of the use of this function is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;This is my String!&amp;quot;)&lt;br /&gt;
     #We can use define_method to create a instance method for this class with multiple parameters.&lt;br /&gt;
     test1.class_eval{ define_method(:getSubString){|start, end| @secret[start,end]} }&lt;br /&gt;
     test1.getSubString(5,9)   #=&amp;gt; &amp;quot;is my&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This example shows how to use define_method to create an instance method with multiple parameters by the common block notation.  Please not that we did have to use class_eval still to access the define_method.  This was due to the fact that define_method is a private method within the Module class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Ruby Conclusions====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The ruby language provides great support for reflection due to the nature of its design.  By using the class_eval method by itself one could completely encompass majority of the required reflection programming.  The other functions do provide some other basic support not granted to the class_eval function, specifically the eval function in combination with bindings.  The use of bindings allow the program to save the context of scope at some particular moment in the program and access it later.  With these functions ruby makes reflection simple.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusions=&lt;br /&gt;
&lt;br /&gt;
All of the Reflection APIs had one thing in common.  The ability to analyze classes and determine information about them from the available metadata.  C#'s API allows the usage of dynamically loaded classes but does not seem as trivial to use as the other APIs.  Java has taken it a step further and allows instance variables to be monitored during execution as well as the ability to call classes' private functions as needed.  Java has proven to be a very flexible reflection API.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The most flexible Reflection API by far is Ruby's.  The nature of Ruby's language allows it to dynamically create and destroy classes as well as variables and methods within the class.  No other language that we've seen will allow you to add or remove functionality of a class as needed during execution.  This allows Ruby programmers to invent new and interesting uses for this flexibility when designing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
[1] [http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection Wikipedia]&lt;br /&gt;
&lt;br /&gt;
[2] [http://www.codersource.net/published/view/291/reflection_in.aspx Reflection in C# - CoderSource.net]&lt;br /&gt;
&lt;br /&gt;
[3] [http://msdn.microsoft.com/en-us/library/f7ykdhsy.aspx MSDN Visual C# - Reflection Programmers Guide]&lt;br /&gt;
&lt;br /&gt;
[4] [http://www.khelll.com/blog/ruby/ruby-reflection/ Ruby Reflection]&lt;br /&gt;
&lt;br /&gt;
[5] [http://practicalruby.blogspot.com/2007/02/ruby-metaprogramming-introduction.html A Ruby Metaprogramming Introduction]&lt;br /&gt;
&lt;br /&gt;
[6] [http://books.google.com/books?id=jcUbTcr5XWwC&amp;amp;lpg=PA266&amp;amp;ots=fHFlsa2wgC&amp;amp;dq=Ruby%20Reflection%20API&amp;amp;pg=PA265#v=onepage&amp;amp;q=Ruby%20Reflection%20API&amp;amp;f=false Ruby Programming Language - Reflection and Metaprogramming]&lt;br /&gt;
&lt;br /&gt;
[7] [http://tutorials.jenkov.com/java-reflection/index.html Java Reflection Tutorial]&lt;br /&gt;
&lt;br /&gt;
[8] [http://java.sun.com/docs/books/tutorial/reflect/ Java Reflection API]&lt;br /&gt;
&lt;br /&gt;
[9] [http://java.sun.com/j2se/1.4.2/docs/api/java/lang/reflect/package-summary.html Java Reflection API Listing]&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=25803</id>
		<title>CSC/ECE 517 Fall 2009/wiki2 5 jn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=25803"/>
		<updated>2009-10-13T20:16:20Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Reflection APIs (TOC)=&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
====What is Reflection?====&lt;br /&gt;
[http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection] in programming is a technique in which programs are able to dynamically view and alter their own structure and flow.  For example, in reflection one could determine method/variable/class names, add or delete method/variables, alter code to current methods, or simply alter values in variables.  Reflection is a subset of [http://en.wikipedia.org/wiki/Metaprogramming MetaProgramming] which relies heavily on the use of meta-information.  Meta-Information is used to keep track of the program structure such as names of available methods, variables and classes but also is what really makes reflection possible.  In theory there are nearly no bounds to reflection as it directly modifies the binary of the program.  The current limitations of this process are related to the APIs available for specific languages.  Majority of object-oriented languages have the functionality built in and some like C++ require external libraries to achieve even the basic functionality of Reflection.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===What languages are Supported?===&lt;br /&gt;
Due to the complexity required to support Reflection majority of the languages that support this feature tend to be object oriented.  Some examples of supported languages are [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/JavaScript JavaScript], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], and [http://en.wikipedia.org/wiki/ActionScript ActionScript].  In this page we will cover a select few of the languages above and what native API support is avaliable for each of the languages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Terminology=&lt;br /&gt;
&lt;br /&gt;
*'''[http://www.google.com/url?q=http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection]''' - the process by which a computer program can observe and modify its own structure and behavior.&lt;br /&gt;
&lt;br /&gt;
*'''[http://www.google.com/url?q=http://en.wikipedia.org/wiki/Meta_programming MetaProgramming]''' - the writing of computer programs that write or manipulate other programs (or themselves) as their data.&lt;br /&gt;
&lt;br /&gt;
*'''[http://www.google.com/url?q=http://www.geospatial.govt.nz/glossary/ MetaData]''' - &amp;quot;data about data&amp;quot;.  Describes how and when and by whom a particular set of data was collected, and how the data is formatted.&lt;br /&gt;
&lt;br /&gt;
*'''[http://www.google.com/url?q=http://en.wikipedia.org/wiki/Binding_(computer_science) Binding]''' - an object that encapsulates the execution context at some particular place in the code.&lt;br /&gt;
&lt;br /&gt;
*'''[http://www.google.com/url?q=http://en.wikipedia.org/wiki/Instance_(programming) Instance]''' - an object with functionality and information described by a class.&lt;br /&gt;
&lt;br /&gt;
*'''[http://www.google.com/url?q=http://en.wikipedia.org/wiki/Scope_(programming) Scope]''' - a location in a program where the value of the variable is available.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in C#=&lt;br /&gt;
&lt;br /&gt;
Reflection in C# is included in the .NET framework provided by microsoft.  The methods and classes usable for reflection are accessed directly from the System.Reflection namespace and support any class type available under the .NET framework.  The basis of reflection in C# is powered by the Type class which is how metadata is accessed.  This Type object gives information about all available methods, variables, constructors, and more from a given class.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reflection in C# is not as dynamic as some other languages.  Particularly that it doesn't support the alteration of class variables, methods, and attributes.  As shown above the reflection implementation in C# is more for data collection and analysis for object types.  One of the best applications for Reflection in C# is the flexibility to dynamically load assembly code at runtime, ascertain information about the methods, variables and constructors, and then invoke code directly.  This type of usage makes examples especially hard to include in a short description.  For this reason the example has been simplified and is displayed below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
 public class Counter&lt;br /&gt;
 {&lt;br /&gt;
      // Private Variable&lt;br /&gt;
      private int ctr;&lt;br /&gt;
      // Constructor&lt;br /&gt;
      public Counter(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           ctr = temp;&lt;br /&gt;
      }&lt;br /&gt;
      // Increment&lt;br /&gt;
      public int Inc(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           return ctr+=temp;&lt;br /&gt;
      }&lt;br /&gt;
      // Decrement&lt;br /&gt;
      public int Dec(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           return ctr-=temp;&lt;br /&gt;
      }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Suppose we have the basic class as listed above.  There is only one constructor, one private instance variable, and two functions which increment or decrement the instance variable by a certain amount.  We could easily begin obtaining information about this class by performing the code below.&lt;br /&gt;
&lt;br /&gt;
 Counter myCtr = new Counter(1000);&lt;br /&gt;
 Type tempType = myCtr.GetType();&lt;br /&gt;
&lt;br /&gt;
From the instance of myCtr we were able to use the GetType method to instantiate and parse meta-information about the Counter class.  Keep in mind that this class could have been invoked at compile time and that we may have no previous information about it.  We could then dynamically determine what constructors and methods were available by performing the following actions.&lt;br /&gt;
&lt;br /&gt;
 ConstructorInfo [] c_info = tempType.GetConstructors();&lt;br /&gt;
 MethodInfo [] m_info = tempType.GetMethods();&lt;br /&gt;
&lt;br /&gt;
From these two lines of code we now have an array of information for both the available methods and the available constructors.  We can use the information in these two types to dynamically incorporate the class into the system at runtime.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====C# Conclusions=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The included [http://msdn.microsoft.com/en-us/library/ms173183(VS.80).aspx Reflection API] in the C# language creates a way for programmers to dynamically retrieve information from external assembly code.  They can then proceed to use that information to access the types available from the assembly.  While this is a difficult concept to grasp it does have its usages.  In the System.Reflection.Emit namespace there is a way to dynamically create types as well.  This form of reflection is typically used by script engines and compilers as they import and compile external types to be used in the current binaries.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in Java=&lt;br /&gt;
&lt;br /&gt;
Reflection in Java is much like the reflection available in C#.  Java's Reflection API is located in the java.lang.reflect package.  It makes it  possible for a programmer to dynamically parse information about classes, interfaces, methods, and fields at runtime.  With this information it is possible to dynamically incorporate these new classes into the running application.  Probably one of the best examples that this could be used for is the Netbeans compiler.  Netbeans is actually a java application which runs and compiles user's java applications.  Once the user chooses to run their code Netbeans then dynamically parses the classes and fields, then loads the class to be run.  Without reflection NetBean's functionality would not be possible. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Java actually has a few advantages over C# in that it can modify access to class fields and methods.  Once it has an instance of the class it can manually override the access and begin calling private and protected functions that users typically wouldn't be able to do.  This could be very useful for performing unit tests on a class since you now have access to all methods and fields.  An example of how both are performed is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example 1=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
     public class testClass {&lt;br /&gt;
        // Private Variable&lt;br /&gt;
        private String privateString = null;&lt;br /&gt;
        // Constructor&lt;br /&gt;
        public testClass(String temp) {&lt;br /&gt;
           privateString = temp;&lt;br /&gt;
        }&lt;br /&gt;
        // Private Method&lt;br /&gt;
        private String getString(){&lt;br /&gt;
          return privateString;&lt;br /&gt;
        }&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
Suppose we had the simple class shown above.  In this class we have both a private field and a private method which we wish to access to perform unit testing on.  Normally this could only be possible by creating public methods to call the private functions and getters and setters to change the fields.  With reflection we could perform the following instead.&lt;br /&gt;
&lt;br /&gt;
     // Create/Get an instance of the class.&lt;br /&gt;
     testClass m_Class = new testClass(&amp;quot;MyString&amp;quot;);&lt;br /&gt;
     // Get an instance of the field within the class&lt;br /&gt;
     Field m_Field = testClass.class.getDeclaredField(&amp;quot;privateString&amp;quot;);&lt;br /&gt;
     // Remove the access restricition on the variable&lt;br /&gt;
     m_Field.setAccessible(true);&lt;br /&gt;
     // Print the value of the field for a specific instance.&lt;br /&gt;
     System.out.println((String) m_Field.get(m_Class));&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The process of accomplishing this seems a bit daunting especially when you compare it to Ruby's implementation which is described later.  But the result is direct access to instance variables at run-time no matter what the restriction policy.  If we needed to access the private method we could accomplish that as shown below.&lt;br /&gt;
&lt;br /&gt;
     // Create/Get an instance of the class.&lt;br /&gt;
     testClass m_Class = new testClass(&amp;quot;MyString&amp;quot;);&lt;br /&gt;
     // Get an instance of the method within the class&lt;br /&gt;
     Method m_Method = testClass.class.getDeclaredMethod(&amp;quot;getString&amp;quot;, null);&lt;br /&gt;
     // Remove the access restricition on the method&lt;br /&gt;
     m_Method.setAccessible(true);&lt;br /&gt;
     // Print the result of method for a specific instance.&lt;br /&gt;
     System.out.println((String) m_Method.invoke(m_Class, null));&lt;br /&gt;
&lt;br /&gt;
The result is the same as from the previous section of code.  We simply accessed the private getter rather than calling the instance variable directly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example 2=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
In the C# example we were not able to present any code for dynamically loading classes into the running program due to the complexity and length.  Java has made this process relatively simple and only requires a few lines of code.  Below is how we could dynamically load our previous class example from an outside source.&lt;br /&gt;
&lt;br /&gt;
public class test2Class {&lt;br /&gt;
  // Main Method of invokiing class&lt;br /&gt;
  public static void main(String[] args){&lt;br /&gt;
    // Instance of a classloader as part of this class&lt;br /&gt;
    ClassLoader m_Loader = test2Class.class.getClassLoader();&lt;br /&gt;
    // Try/Catch Block&lt;br /&gt;
    try {&lt;br /&gt;
        Class m_Class = m_Loader.loadClass(&amp;quot;com.myClassPackage.testClass&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Successfully loaded class: &amp;quot; + m_Class.getName());&lt;br /&gt;
    } &lt;br /&gt;
    catch (ClassNotFoundException e) {&lt;br /&gt;
        System.err.println(e)    &lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The result from above is access to &amp;quot;testClass&amp;quot;. The test2Class loaded our example class from before.  From here we could now instantiate the class and call its functions (or search for what functions it has to offer).  This gives real insight to the flexibility of Java's Reflection API and how it could be practically used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Java Conclusions====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Java's [http://java.sun.com/javase/7/docs/api/java/lang/reflect/package-summary.html Reflection API] supplies a great deal of flexibility.  It allows the user almost complete access to classes as well as the ability to dynamically load new classes and utilize their functions.  While some of the method calls aren't trivial, majority of the coding is very useful once you understand the uses.  Java also has the added advantage to access private functions and variables of a class instance which can allow for easier unit testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in Ruby=&lt;br /&gt;
&lt;br /&gt;
The nature of Ruby as an object-oriented language gives great support for Reflection.  The big advantage to ruby is it gives us complete flexibility and control with reflection.  Most usages of reflection is only to obtain information and create new types dynamically but not modify current ones.  With Ruby's reflection api we have the ability to add or remove almost anything, whether that's a method, a class, or even class variables.  Please note that this flexibility can also lead to a programs downfall as with any reflection API.  Too much alteration of the source code can cause many unknown bugs.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The current support for reflection in ruby is built into the language and is accessible through certain functions within the standard Ruby API.  The methods most commonly used for reflection in Ruby along with some basic examples of their usage are shown below.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Kernel.html#M005922 eval] method is defined in the Kernel Module of Ruby and is used to evaluate literals encompassed in strings.  This may not seem useful but the eval method also work in the scope of bindings which represent the scope of execution at a particular place in the code.  This allows programmers to view any variables in any scope for any instance.  An example of eval's usage is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
          def getBinding&lt;br /&gt;
               return binding()&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar is and evaluate it without an accessor method&lt;br /&gt;
     eval(&amp;quot;@myvar&amp;quot;, test1.getBinding)   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
I this example we can see that by acquiring the binding at some scope in the program we can use it to get inside the context of any object instance and determine the value of any instance variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Instance Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Object.html#M000334 instance_eval] method is defined in the Object class and works within the instance of any class.  This method performs much of the same operations as the eval method but works in the scope of an object without requiring the binding statement as above.  In fact we can accomplish the same example as above with the code shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar is and evaluate it without an accessor method&lt;br /&gt;
     test1.instance_eval { @myvar }   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
Again this code performs exactly the same thing as the prior example above.  The result is 17 which is the evaluation of the string literal as a command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Class Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.src/M001650.html class_eval] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object whether that is assigning or accessing variables, declaring instance methods, or even re-defining inherited methods.  The method takes actions either via string literal or a block of code.  This method is one of the strongest and most versatile methods in the Ruby Reflection API since it can access any private methods of any objects and its parents, this giving you full control over control.&lt;br /&gt;
&lt;br /&gt;
=====Example 1=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar by creating an accessor method for this instance.&lt;br /&gt;
     test1.class_eval{ def getVar; @myvar; end }&lt;br /&gt;
     eval(test1.getVar)   #=&amp;gt;  17&lt;br /&gt;
     #Or by simply accessing the local variable as below.&lt;br /&gt;
     eval(test1.class_eval{@myvar})    #=&amp;gt; 17&lt;br /&gt;
&lt;br /&gt;
This example shows the versatility of the class_eval method to work on any class instance.  It performs many of the operations that the previous methods have performed but with the added advantage of assigning instance methods.&lt;br /&gt;
&lt;br /&gt;
=====Example 2=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
       private:&lt;br /&gt;
          def increment&lt;br /&gt;
               @myvar += 1&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     #We can directly use class_eval to call private methods within a class as well.&lt;br /&gt;
     test1.class_eval{ increment() }   #=&amp;gt; 18&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval has even more flexibility to call private functions of a class from outside of the class scope. &lt;br /&gt;
&lt;br /&gt;
=====Example 3=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     # We can directly use class_eval to add variables to the instance of the class&lt;br /&gt;
     test1.class_eval{ instance_variable_set :@myvar2 , 25 }   &lt;br /&gt;
     test1.class_eval{ @myvar2 } #=&amp;gt; 25&lt;br /&gt;
     # Or We can remove variables from an instance of the class&lt;br /&gt;
     test1.class_eval{ remove_instance_variable :@myvar2 }&lt;br /&gt;
     test1.class_eval{ @myvar2 } #=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval is capable of defining and removing instance variables from the instance of a class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Define Method Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.html#M001654 define_method] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object to declare methods directly.  This method can be accomplished by using the class_eval method but is also a bit more flexible in it's notation.  An example of the use of this function is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;This is my String!&amp;quot;)&lt;br /&gt;
     #We can use define_method to create a instance method for this class with multiple parameters.&lt;br /&gt;
     test1.class_eval{ define_method(:getSubString){|start, end| @secret[start,end]} }&lt;br /&gt;
     test1.getSubString(5,9)   #=&amp;gt; &amp;quot;is my&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This example shows how to use define_method to create an instance method with multiple parameters by the common block notation.  Please not that we did have to use class_eval still to access the define_method.  This was due to the fact that define_method is a private method within the Module class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Ruby Conclusions====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The ruby language provides great support for reflection due to the nature of its design.  By using the class_eval method by itself one could completely encompass majority of the required reflection programming.  The other functions do provide some other basic support not granted to the class_eval function, specifically the eval function in combination with bindings.  The use of bindings allow the program to save the context of scope at some particular moment in the program and access it later.  With these functions ruby makes reflection simple.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusions=&lt;br /&gt;
&lt;br /&gt;
All of the Reflection API's had one thing in common.  The ability to analyze classes and determine information about them from the available metadata.  C#'s API allows the usage of dynamically loaded classes but does not seem as trivial to use as the other APIs.  Java has take it a step further and allows instance variables to be monitored during execution as well as the ability to call classes' private functions as needed.  Java has proven to be a very flexible reflection API.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The most flexible Reflection API by far is Ruby's.  The nature of Ruby's language allows it to dynamically create and destroy classes as well as variables and methods within the class.  No other language that we've seen will allow you to add or remove functionality of a class as needed during execution.  This allows Ruby programmers to invent new and interesting uses for this flexibility when designing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
[1] [http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection Wikipedia]&lt;br /&gt;
&lt;br /&gt;
[2] [http://www.codersource.net/published/view/291/reflection_in.aspx Reflection in C# - CoderSource.net]&lt;br /&gt;
&lt;br /&gt;
[3] [http://msdn.microsoft.com/en-us/library/f7ykdhsy.aspx MSDN Visual C# - Reflection Programmers Guide]&lt;br /&gt;
&lt;br /&gt;
[4] [http://www.khelll.com/blog/ruby/ruby-reflection/ Ruby Reflection]&lt;br /&gt;
&lt;br /&gt;
[5] [http://practicalruby.blogspot.com/2007/02/ruby-metaprogramming-introduction.html A Ruby Metaprogramming Introduction]&lt;br /&gt;
&lt;br /&gt;
[6] [http://books.google.com/books?id=jcUbTcr5XWwC&amp;amp;lpg=PA266&amp;amp;ots=fHFlsa2wgC&amp;amp;dq=Ruby%20Reflection%20API&amp;amp;pg=PA265#v=onepage&amp;amp;q=Ruby%20Reflection%20API&amp;amp;f=false Ruby Programming Language - Reflection and Metaprogramming]&lt;br /&gt;
&lt;br /&gt;
[7] [http://tutorials.jenkov.com/java-reflection/index.html Java Reflection Tutorial]&lt;br /&gt;
&lt;br /&gt;
[8] [http://java.sun.com/docs/books/tutorial/reflect/ Java Reflection API]&lt;br /&gt;
&lt;br /&gt;
[9] [http://java.sun.com/j2se/1.4.2/docs/api/java/lang/reflect/package-summary.html Java Reflection API Listing]&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=25793</id>
		<title>CSC/ECE 517 Fall 2009/wiki2 5 jn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=25793"/>
		<updated>2009-10-13T19:58:58Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Reflection APIs (TOC)=&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
====What is Reflection?====&lt;br /&gt;
[http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection] in programming is a technique in which programs are able to dynamically view and alter their own structure and flow.  For example, in reflection one could determine method/variable/class names, add or delete method/variables, alter code to current methods, or simply alter values in variables.  Reflection is a subset of [http://en.wikipedia.org/wiki/Metaprogramming MetaProgramming] which relies heavily on the use of meta-information.  Meta-Information is used to keep track of the program structure such as names of available methods, variables and classes but also is what really makes reflection possible.  In theory there are nearly no bounds to reflection as it directly modifies the binary of the program.  The current limitations of this process are related to the APIs available for specific languages.  Majority of object-oriented languages have the functionality built in and some like C++ require external libraries to achieve even the basic functionality of Reflection.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===What languages are Supported?===&lt;br /&gt;
Due to the complexity required to support this majority of the languages that support this feature tend to be object oriented.  Some examples of supported languages are [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/JavaScript JavaScript], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], and [http://en.wikipedia.org/wiki/ActionScript ActionScript].  In this page we will cover a select few of the languages above and what native API support is avaliable for each of the languages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Terminology=&lt;br /&gt;
&lt;br /&gt;
*'''[http://www.google.com/url?q=http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection]''' - the process by which a computer program can observe and modify its own structure and behavior.&lt;br /&gt;
&lt;br /&gt;
*'''[http://www.google.com/url?q=http://en.wikipedia.org/wiki/Meta_programming MetaProgramming]''' - the writing of computer programs that write or manipulate other programs (or themselves) as their data.&lt;br /&gt;
&lt;br /&gt;
*'''[http://www.google.com/url?q=http://www.geospatial.govt.nz/glossary/ MetaData]''' - &amp;quot;data about data&amp;quot;.  Describes how and when and by whom a particular set of data was collected, and how the data is formatted.&lt;br /&gt;
&lt;br /&gt;
*'''[http://www.google.com/url?q=http://en.wikipedia.org/wiki/Binding_(computer_science) Binding]''' - an object that encapsulates the execution context at some particular place in the code.&lt;br /&gt;
&lt;br /&gt;
*'''[http://www.google.com/url?q=http://en.wikipedia.org/wiki/Instance_(programming) Instance]''' - an object with functionality and information described by a class.&lt;br /&gt;
&lt;br /&gt;
*'''[http://www.google.com/url?q=http://en.wikipedia.org/wiki/Scope_(programming) Scope]''' - a location in a program where the value of the variable is available.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in C#=&lt;br /&gt;
&lt;br /&gt;
Reflection in C# is included in the .NET framework provided by microsoft.  The methods and classes usable for reflection are access directly from the System.Reflection namespace and support any class type available under the .NET framework.  The basis of reflection in C# is powered by the Type class which is the way metadata is accessed.  This type object gives information about all available methods, variables, constructors, and more from a given class.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reflection in C# is not as dynamic as some other languages in the fact that it doesn't support the alteration of class variables, methods, and attributes.  As shown above the reflection implementation in C# is more for data collection and analysis for object types.  One of the best applications for Reflection in C# is the flexibility to dynamically load assembly code at runtime, ascertain information about the methods, variables and constructors, and then invoke code directly.  This type of usage makes examples especially hard to include in a short description as this.  For this reason the example has been simplified and is displayed below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
 public class Counter&lt;br /&gt;
 {&lt;br /&gt;
      // Private Variable&lt;br /&gt;
      private int ctr;&lt;br /&gt;
      // Constructor&lt;br /&gt;
      public Counter(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           ctr = temp;&lt;br /&gt;
      }&lt;br /&gt;
      // Increment&lt;br /&gt;
      public int Inc(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           return ctr+=temp;&lt;br /&gt;
      }&lt;br /&gt;
      // Decrement&lt;br /&gt;
      public int Dec(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           return ctr-=temp;&lt;br /&gt;
      }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Suppose we have the basic class as listed above.  There is only one constructor, one private instance variable, and two functions which increment or decrement the instance variable by a certain amount.  We could easily begin obtaining information about this class by performing the code below.&lt;br /&gt;
&lt;br /&gt;
 Counter myCtr = new Counter(1000);&lt;br /&gt;
 Type tempType = myCtr.GetType();&lt;br /&gt;
&lt;br /&gt;
From the instance of myCtr we were able to use the GetType method to instantiate and parse meta-information about the Counter class.  Keep in mind that this class could have been invoked at compile time and that we may have no previous information about it.  We could then dynamically determine what constructors and methods were available by performing the following actions.&lt;br /&gt;
&lt;br /&gt;
 ConstructorInfo [] c_info = tempType.GetConstructors();&lt;br /&gt;
 MethodInfo [] m_info = tempType.GetMethods();&lt;br /&gt;
&lt;br /&gt;
From these two lines of code we now have an array of information for both the available methods and the available constructors.  We can use the information in these two types to dynamically incorporate the class into the system at runtime.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====C# Conclusions=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The included reflection API in the C# language creates a way for programmers to dynamically retrieve information from external assembly code.  They can then proceed to use that information to access the types available from the assembly.  While this is a difficult concept to grasp it does have its usages.  In the System.Reflection.Emit namespace there is a way to dynamically create types.  This form of reflection is typically used by script engines and compilers as they import external types to be used in the current binaries.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in Java=&lt;br /&gt;
&lt;br /&gt;
Reflection in Java is much like the reflection available in C#.  Java's Reflection API is located in the java.lang.reflect package and makes it possible for a programmer to dynamically parse information about classes, interfaces, methods, and fields at runtime.  With this information it is possibly to dynamically incorporate these new classes into the running application.  Probably one of the best examples that this could be used for is the Netbeans compiler.  Netbeans is actually a java application which runs and compiles user's java applications.  Once the user chooses to run it Netbeans then dynamically parses the classes and fields, then loads the class to be run.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Java actually has a few advantages over C# in that it can modify access to class fields and methods.  Once it has an instance of the class it can manually override the access and begin calling private and protected functions that users typically wouldn't be able to do.  This could be very useful for performing unit tests on a class since you now have access to all methods and fields.  An example of how both are performed is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example 1=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
     public class testClass {&lt;br /&gt;
        // Private Variable&lt;br /&gt;
        private String privateString = null;&lt;br /&gt;
        // Constructor&lt;br /&gt;
        public testClass(String temp) {&lt;br /&gt;
           privateString = temp;&lt;br /&gt;
        }&lt;br /&gt;
        // Private Method&lt;br /&gt;
        private String getString(){&lt;br /&gt;
          return privateString;&lt;br /&gt;
        }&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
Suppose we had the simple class shown above.  In this class we have both a private field and a private method which we wish to access to perform unit testing on.  Normally this could only be possible by creating public methods to call the private functions and getters and setters to change the fields.  With reflection we could perform the following.&lt;br /&gt;
&lt;br /&gt;
     // Create/Get an instance of the class.&lt;br /&gt;
     testClass m_Class = new testClass(&amp;quot;MyString&amp;quot;);&lt;br /&gt;
     // Get an instance of the field within the class&lt;br /&gt;
     Field m_Field = testClass.class.getDeclaredField(&amp;quot;privateString&amp;quot;);&lt;br /&gt;
     // Remove the access restricition on the variable&lt;br /&gt;
     m_Field.setAccessible(true);&lt;br /&gt;
     // Print the value of the field for a specific instance.&lt;br /&gt;
     System.out.println((String) m_Field.get(m_Class));&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The process of accomplishing this seems a bit daunting especially when you compare it to Ruby's implementation which is described later.  But the result is direct access to instance variables at run-time no matter what the restriction policy.  If we needed to access the private method we could accomplish that as shown below.&lt;br /&gt;
&lt;br /&gt;
     // Create/Get an instance of the class.&lt;br /&gt;
     testClass m_Class = new testClass(&amp;quot;MyString&amp;quot;);&lt;br /&gt;
     // Get an instance of the method within the class&lt;br /&gt;
     Method m_Method = testClass.class.getDeclaredMethod(&amp;quot;getString&amp;quot;, null);&lt;br /&gt;
     // Remove the access restricition on the method&lt;br /&gt;
     m_Method.setAccessible(true);&lt;br /&gt;
     // Print the result of method for a specific instance.&lt;br /&gt;
     System.out.println((String) m_Method.invoke(m_Class, null));&lt;br /&gt;
&lt;br /&gt;
The result is the same as from the previous section of code.  We simply accessed the private getter rather than calling the instance variable directly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example 2=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
In the C# example we were not able to present any code for dynamically loading classes into the running program due to the complexity and length.  Java has made this process relatively simple and only requires a few lines of code.  Below is how we could dynamically load our previous class example from an outside source.&lt;br /&gt;
&lt;br /&gt;
public class test2Class {&lt;br /&gt;
  // Main Method of invokiing class&lt;br /&gt;
  public static void main(String[] args){&lt;br /&gt;
    // Instance of a classloader as part of this class&lt;br /&gt;
    ClassLoader m_Loader = test2Class.class.getClassLoader();&lt;br /&gt;
    // Try/Catch Block&lt;br /&gt;
    try {&lt;br /&gt;
        Class m_Class = m_Loader.loadClass(&amp;quot;com.myClassPackage.testClass&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Successfully loaded class: &amp;quot; + m_Class.getName());&lt;br /&gt;
    } &lt;br /&gt;
    catch (ClassNotFoundException e) {&lt;br /&gt;
        System.err.println(e)    &lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The result from above is &amp;quot;testClass&amp;quot; as it loaded our example class from before.  From here we could now instantiate the class and call its functions (or search for what functions it has to offer).  This gives real insight to the flexibility of Java's Reflection API and how it could be practically used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Java Conclusions====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Java's Reflection API supplies a great deal of flexibility.  It allows the user almost complete access to classes as well as the ability to dynamically load new classes and utilize their functions.  While some of the method calls aren't trivial majority of the coding is understandable and very useful once you understand what is going on.  Java also has the added advantage to access private functions and variables of a class instance which can allow easier unit testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in Ruby=&lt;br /&gt;
&lt;br /&gt;
The nature of Ruby as an object-oriented language gives great support for Reflection.  The big advantage to ruby is it gives us complete flexibility and control with reflection.  Most usages of reflection is only to obtain information and create new types dynamically but not modify current ones.  With Ruby's reflection api we have the ability to add or remove almost anything, whether that's a method, a class, or even class variables.  Please note that this flexibility can also lead to a programs downfall as with any reflection API.  Too much alteration of the source code can cause many unknown bugs.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The current support for reflection in ruby is built into the language and is accessible through certain functions within the standard Ruby API.  The methods most commonly used for reflection in Ruby along with some basic examples of their usage are shown below.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Kernel.html#M005922 eval] method is defined in the Kernel Module of Ruby and is used to evaluate literals encompassed in strings.  This may not seem useful but the eval method also work in the scope of bindings which represent the scope of execution at a particular place in the code.  This allows programmers to view any variables in any scope for any instance.  An example of eval's usage is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
          def getBinding&lt;br /&gt;
               return binding()&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar is and evaluate it without an accessor method&lt;br /&gt;
     eval(&amp;quot;@myvar&amp;quot;, test1.getBinding)   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
I this example we can see that by acquiring the binding at some scope in the program we can use it to get inside the context of any object instance and determine the value of any instance variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Instance Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Object.html#M000334 instance_eval] method is defined in the Object class and works within the instance of any class.  This method performs much of the same operations as the eval method but works in the scope of an object without requiring the binding statement as above.  In fact we can accomplish the same example as above with the code shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar is and evaluate it without an accessor method&lt;br /&gt;
     test1.instance_eval { @myvar }   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
Again this code performs exactly the same thing as the prior example above.  The result is 17 which is the evaluation of the string literal as a command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Class Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.src/M001650.html class_eval] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object whether that is assigning or accessing variables, declaring instance methods, or even re-defining inherited methods.  The method takes actions either via string literal or a block of code.  This method is one of the strongest and most versatile methods in the Ruby Reflection API since it can access any private methods of any objects and its parents, this giving you full control over control.&lt;br /&gt;
&lt;br /&gt;
=====Example 1=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar by creating an accessor method for this instance.&lt;br /&gt;
     test1.class_eval{ def getVar; @myvar; end }&lt;br /&gt;
     eval(test1.getVar)   #=&amp;gt;  17&lt;br /&gt;
     #Or by simply accessing the local variable as below.&lt;br /&gt;
     eval(test1.class_eval{@myvar})    #=&amp;gt; 17&lt;br /&gt;
&lt;br /&gt;
This example shows the versatility of the class_eval method to work on any class instance.  It performs many of the operations that the previous methods have performed but with the added advantage of assigning instance methods.&lt;br /&gt;
&lt;br /&gt;
=====Example 2=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
       private:&lt;br /&gt;
          def increment&lt;br /&gt;
               @myvar += 1&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     #We can directly use class_eval to call private methods within a class as well.&lt;br /&gt;
     test1.class_eval{ increment() }   #=&amp;gt; 18&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval has even more flexibility to call private functions of a class from outside of the class scope. &lt;br /&gt;
&lt;br /&gt;
=====Example 3=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     # We can directly use class_eval to add variables to the instance of the class&lt;br /&gt;
     test1.class_eval{ instance_variable_set :@myvar2 , 25 }   &lt;br /&gt;
     test1.class_eval{ @myvar2 } #=&amp;gt; 25&lt;br /&gt;
     # Or We can remove variables from an instance of the class&lt;br /&gt;
     test1.class_eval{ remove_instance_variable :@myvar2 }&lt;br /&gt;
     test1.class_eval{ @myvar2 } #=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval is capable of defining and removing instance variables from the instance of a class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Define Method Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.html#M001654 define_method] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object to declare methods directly.  This method can be accomplished by using the class_eval method but is also a bit more flexible in it's notation.  An example of the use of this function is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;This is my String!&amp;quot;)&lt;br /&gt;
     #We can use define_method to create a instance method for this class with multiple parameters.&lt;br /&gt;
     test1.class_eval{ define_method(:getSubString){|start, end| @secret[start,end]} }&lt;br /&gt;
     test1.getSubString(5,9)   #=&amp;gt; &amp;quot;is my&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This example shows how to use define_method to create an instance method with multiple parameters by the common block notation.  Please not that we did have to use class_eval still to access the define_method.  This was due to the fact that define_method is a private method within the Module class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Ruby Conclusions====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The ruby language provides great support for reflection due to the nature of its design.  By using the class_eval method by itself one could completely encompass majority of the required reflection programming.  The other functions do provide some other basic support not granted to the class_eval function, specifically the eval function in combination with bindings.  The use of bindings allow the program to save the context of scope at some particular moment in the program and access it later.  With these functions ruby makes reflection simple.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusions=&lt;br /&gt;
&lt;br /&gt;
All of the Reflection API's had one thing in common.  The ability to analyze classes and determine information about them from the available metadata.  C#'s API allows the usage of dynamically loaded classes but does not seem as trivial to use as the other APIs.  Java has take it a step further and allows instance variables to be monitored during execution as well as the ability to call classes' private functions as needed.  Java has proven to be a very flexible reflection API.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The most flexible Reflection API by far is Ruby's.  The nature of Ruby's language allows it to dynamically create and destroy classes as well as variables and methods within the class.  No other language that we've seen will allow you to add or remove functionality of a class as needed during execution.  This allows Ruby programmers to invent new and interesting uses for this flexibility when designing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
[1] [http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection Wikipedia]&lt;br /&gt;
&lt;br /&gt;
[2] [http://www.codersource.net/published/view/291/reflection_in.aspx Reflection in C# - CoderSource.net]&lt;br /&gt;
&lt;br /&gt;
[3] [http://msdn.microsoft.com/en-us/library/f7ykdhsy.aspx MSDN Visual C# - Reflection Programmers Guide]&lt;br /&gt;
&lt;br /&gt;
[4] [http://www.khelll.com/blog/ruby/ruby-reflection/ Ruby Reflection]&lt;br /&gt;
&lt;br /&gt;
[5] [http://practicalruby.blogspot.com/2007/02/ruby-metaprogramming-introduction.html A Ruby Metaprogramming Introduction]&lt;br /&gt;
&lt;br /&gt;
[6] [http://books.google.com/books?id=jcUbTcr5XWwC&amp;amp;lpg=PA266&amp;amp;ots=fHFlsa2wgC&amp;amp;dq=Ruby%20Reflection%20API&amp;amp;pg=PA265#v=onepage&amp;amp;q=Ruby%20Reflection%20API&amp;amp;f=false Ruby Programming Language - Reflection and Metaprogramming]&lt;br /&gt;
&lt;br /&gt;
[7] [http://tutorials.jenkov.com/java-reflection/index.html Java Reflection Tutorial]&lt;br /&gt;
&lt;br /&gt;
[8] [http://java.sun.com/docs/books/tutorial/reflect/ Java Reflection API]&lt;br /&gt;
&lt;br /&gt;
[9] [http://java.sun.com/j2se/1.4.2/docs/api/java/lang/reflect/package-summary.html Java Reflection API Listing]&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=24659</id>
		<title>CSC/ECE 517 Fall 2009/wiki2 5 jn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=24659"/>
		<updated>2009-10-09T22:40:04Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Reflection APIs (TOC)=&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
====What is Reflection?====&lt;br /&gt;
[http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection] in programming is a technique in which programs are able to dynamically view and alter their own structure and flow.  For example, in reflection one could determine method/variable/class names, add or delete method/variables, alter code to current methods, or simply alter values in variables.  Reflection is a subset of [http://en.wikipedia.org/wiki/Metaprogramming MetaProgramming] which relies heavily on the use of meta-information.  Meta-Information is used to keep track of the program structure such as names of available methods, variables and classes but also is what really makes reflection possible.  In theory there are nearly no bounds to reflection as it directly modifies the binary of the program.  The current limitations of this process are related to the APIs available for specific languages.  Majority of object-oriented languages have the functionality built in and some like C++ require external libraries to achieve even the basic functionality of Reflection.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===What languages are Supported?===&lt;br /&gt;
Due to the complexity required to support this majority of the languages that support this feature tend to be object oriented.  Some examples of supported languages are [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/JavaScript JavaScript], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], and [http://en.wikipedia.org/wiki/ActionScript ActionScript].  In this page we will cover a select few of the languages above and what native API support is avaliable for each of the languages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Terminology=&lt;br /&gt;
&lt;br /&gt;
*'''Reflection''' - the process by which a computer program can observe and modify its own structure and behavior.&lt;br /&gt;
&lt;br /&gt;
*'''MetaProgramming''' - the writing of computer programs that write or manipulate other programs (or themselves) as their data.&lt;br /&gt;
&lt;br /&gt;
*'''MetaData''' - &amp;quot;data about data&amp;quot;.  Describes how and when and by whom a particular set of data was collected, and how the data is formatted.&lt;br /&gt;
&lt;br /&gt;
*'''Binding''' - an object that encapsulates the execution context at some particular place in the code.&lt;br /&gt;
&lt;br /&gt;
*'''Instance''' - an object with functionality and information described by a class.&lt;br /&gt;
&lt;br /&gt;
*'''Scope''' - a location in a program where the value of the variable is available.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in C#=&lt;br /&gt;
&lt;br /&gt;
Reflection in C# is included in the .NET framework provided by microsoft.  The methods and classes usable for reflection are access directly from the System.Reflection namespace and support any class type available under the .NET framework.  The basis of reflection in C# is powered by the Type class which is the way metadata is accessed.  This type object gives information about all available methods, variables, constructors, and more from a given class.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reflection in C# is not as dynamic as some other languages in the fact that it doesn't support the alteration of class variables, methods, and attributes.  As shown above the reflection implementation in C# is more for data collection and analysis for object types.  One of the best applications for Reflection in C# is the flexibility to dynamically load assembly code at runtime, ascertain information about the methods, variables and constructors, and then invoke code directly.  This type of usage makes examples especially hard to include in a short description as this.  For this reason the example has been simplified and is displayed below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
 public class Counter&lt;br /&gt;
 {&lt;br /&gt;
      // Private Variable&lt;br /&gt;
      private int ctr;&lt;br /&gt;
      // Constructor&lt;br /&gt;
      public Counter(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           ctr = temp;&lt;br /&gt;
      }&lt;br /&gt;
      // Increment&lt;br /&gt;
      public int Inc(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           return ctr+=temp;&lt;br /&gt;
      }&lt;br /&gt;
      // Decrement&lt;br /&gt;
      public int Dec(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           return ctr-=temp;&lt;br /&gt;
      }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Suppose we have the basic class as listed above.  There is only one constructor, one private instance variable, and two functions which increment or decrement the instance variable by a certain amount.  We could easily begin obtaining information about this class by performing the code below.&lt;br /&gt;
&lt;br /&gt;
 Counter myCtr = new Counter(1000);&lt;br /&gt;
 Type tempType = myCtr.GetType();&lt;br /&gt;
&lt;br /&gt;
From the instance of myCtr we were able to use the GetType method to instantiate and parse meta-information about the Counter class.  Keep in mind that this class could have been invoked at compile time and that we may have no previous information about it.  We could then dynamically determine what constructors and methods were available by performing the following actions.&lt;br /&gt;
&lt;br /&gt;
 ConstructorInfo [] c_info = tempType.GetConstructors();&lt;br /&gt;
 MethodInfo [] m_info = tempType.GetMethods();&lt;br /&gt;
&lt;br /&gt;
From these two lines of code we now have an array of information for both the available methods and the available constructors.  We can use the information in these two types to dynamically incorporate the class into the system at runtime.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====C# Conclusions=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The included reflection API in the C# language creates a way for programmers to dynamically retrieve information from external assembly code.  They can then proceed to use that information to access the types available from the assembly.  While this is a difficult concept to grasp it does have its usages.  In the System.Reflection.Emit namespace there is a way to dynamically create types.  This form of reflection is typically used by script engines and compilers as they import external types to be used in the current binaries.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in Java=&lt;br /&gt;
&lt;br /&gt;
Reflection in Java is much like the reflection available in C#.  Java's Reflection API is located in the java.lang.reflect package and makes it possible for a programmer to dynamically parse information about classes, interfaces, methods, and fields at runtime.  With this information it is possibly to dynamically incorporate these new classes into the running application.  Probably one of the best examples that this could be used for is the Netbeans compiler.  Netbeans is actually a java application which runs and compiles user's java applications.  Once the user chooses to run it Netbeans then dynamically parses the classes and fields, then loads the class to be run.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Java actually has a few advantages over C# in that it can modify access to class fields and methods.  Once it has an instance of the class it can manually override the access and begin calling private and protected functions that users typically wouldn't be able to do.  This could be very useful for performing unit tests on a class since you now have access to all methods and fields.  An example of how both are performed is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example 1=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
     public class testClass {&lt;br /&gt;
        // Private Variable&lt;br /&gt;
        private String privateString = null;&lt;br /&gt;
        // Constructor&lt;br /&gt;
        public testClass(String temp) {&lt;br /&gt;
           privateString = temp;&lt;br /&gt;
        }&lt;br /&gt;
        // Private Method&lt;br /&gt;
        private String getString(){&lt;br /&gt;
          return privateString;&lt;br /&gt;
        }&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
Suppose we had the simple class shown above.  In this class we have both a private field and a private method which we wish to access to perform unit testing on.  Normally this could only be possible by creating public methods to call the private functions and getters and setters to change the fields.  With reflection we could perform the following.&lt;br /&gt;
&lt;br /&gt;
     // Create/Get an instance of the class.&lt;br /&gt;
     testClass m_Class = new testClass(&amp;quot;MyString&amp;quot;);&lt;br /&gt;
     // Get an instance of the field within the class&lt;br /&gt;
     Field m_Field = testClass.class.getDeclaredField(&amp;quot;privateString&amp;quot;);&lt;br /&gt;
     // Remove the access restricition on the variable&lt;br /&gt;
     m_Field.setAccessible(true);&lt;br /&gt;
     // Print the value of the field for a specific instance.&lt;br /&gt;
     System.out.println((String) m_Field.get(m_Class));&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The process of accomplishing this seems a bit daunting especially when you compare it to Ruby's implementation which is described later.  But the result is direct access to instance variables at run-time no matter what the restriction policy.  If we needed to access the private method we could accomplish that as shown below.&lt;br /&gt;
&lt;br /&gt;
     // Create/Get an instance of the class.&lt;br /&gt;
     testClass m_Class = new testClass(&amp;quot;MyString&amp;quot;);&lt;br /&gt;
     // Get an instance of the method within the class&lt;br /&gt;
     Method m_Method = testClass.class.getDeclaredMethod(&amp;quot;getString&amp;quot;, null);&lt;br /&gt;
     // Remove the access restricition on the method&lt;br /&gt;
     m_Method.setAccessible(true);&lt;br /&gt;
     // Print the result of method for a specific instance.&lt;br /&gt;
     System.out.println((String) m_Method.invoke(m_Class, null));&lt;br /&gt;
&lt;br /&gt;
The result is the same as from the previous section of code.  We simply accessed the private getter rather than calling the instance variable directly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example 2=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
In the C# example we were not able to present any code for dynamically loading classes into the running program due to the complexity and length.  Java has made this process relatively simple and only requires a few lines of code.  Below is how we could dynamically load our previous class example from an outside source.&lt;br /&gt;
&lt;br /&gt;
public class test2Class {&lt;br /&gt;
  // Main Method of invokiing class&lt;br /&gt;
  public static void main(String[] args){&lt;br /&gt;
    // Instance of a classloader as part of this class&lt;br /&gt;
    ClassLoader m_Loader = test2Class.class.getClassLoader();&lt;br /&gt;
    // Try/Catch Block&lt;br /&gt;
    try {&lt;br /&gt;
        Class m_Class = m_Loader.loadClass(&amp;quot;com.myClassPackage.testClass&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Successfully loaded class: &amp;quot; + m_Class.getName());&lt;br /&gt;
    } &lt;br /&gt;
    catch (ClassNotFoundException e) {&lt;br /&gt;
        System.err.println(e)    &lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The result from above is &amp;quot;testClass&amp;quot; as it loaded our example class from before.  From here we could now instantiate the class and call its functions (or search for what functions it has to offer).  This gives real insight to the flexibility of Java's Reflection API and how it could be practically used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Java Conclusions====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Java's Reflection API supplies a great deal of flexibility.  It allows the user almost complete access to classes as well as the ability to dynamically load new classes and utilize their functions.  While some of the method calls aren't trivial majority of the coding is understandable and very useful once you understand what is going on.  Java also has the added advantage to access private functions and variables of a class instance which can allow easier unit testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in Ruby=&lt;br /&gt;
&lt;br /&gt;
The nature of Ruby as an object-oriented language gives great support for Reflection.  The big advantage to ruby is it gives us complete flexibility and control with reflection.  Most usages of reflection is only to obtain information and create new types dynamically but not modify current ones.  With Ruby's reflection api we have the ability to add or remove almost anything, whether that's a method, a class, or even class variables.  Please note that this flexibility can also lead to a programs downfall as with any reflection API.  Too much alteration of the source code can cause many unknown bugs.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The current support for reflection in ruby is built into the language and is accessible through certain functions within the standard Ruby API.  The methods most commonly used for reflection in Ruby along with some basic examples of their usage are shown below.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Kernel.html#M005922 eval] method is defined in the Kernel Module of Ruby and is used to evaluate literals encompassed in strings.  This may not seem useful but the eval method also work in the scope of bindings which represent the scope of execution at a particular place in the code.  This allows programmers to view any variables in any scope for any instance.  An example of eval's usage is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
          def getBinding&lt;br /&gt;
               return binding()&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar is and evaluate it without an accessor method&lt;br /&gt;
     eval(&amp;quot;@myvar&amp;quot;, test1.getBinding)   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
I this example we can see that by acquiring the binding at some scope in the program we can use it to get inside the context of any object instance and determine the value of any instance variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Instance Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Object.html#M000334 instance_eval] method is defined in the Object class and works within the instance of any class.  This method performs much of the same operations as the eval method but works in the scope of an object without requiring the binding statement as above.  In fact we can accomplish the same example as above with the code shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar is and evaluate it without an accessor method&lt;br /&gt;
     test1.instance_eval { @myvar }   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
Again this code performs exactly the same thing as the prior example above.  The result is 17 which is the evaluation of the string literal as a command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Class Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.src/M001650.html class_eval] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object whether that is assigning or accessing variables, declaring instance methods, or even re-defining inherited methods.  The method takes actions either via string literal or a block of code.  This method is one of the strongest and most versatile methods in the Ruby Reflection API since it can access any private methods of any objects and its parents, this giving you full control over control.&lt;br /&gt;
&lt;br /&gt;
=====Example 1=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar by creating an accessor method for this instance.&lt;br /&gt;
     test1.class_eval{ def getVar; @myvar; end }&lt;br /&gt;
     eval(test1.getVar)   #=&amp;gt;  17&lt;br /&gt;
     #Or by simply accessing the local variable as below.&lt;br /&gt;
     eval(test1.class_eval{@myvar})    #=&amp;gt; 17&lt;br /&gt;
&lt;br /&gt;
This example shows the versatility of the class_eval method to work on any class instance.  It performs many of the operations that the previous methods have performed but with the added advantage of assigning instance methods.&lt;br /&gt;
&lt;br /&gt;
=====Example 2=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
       private:&lt;br /&gt;
          def increment&lt;br /&gt;
               @myvar += 1&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     #We can directly use class_eval to call private methods within a class as well.&lt;br /&gt;
     test1.class_eval{ increment() }   #=&amp;gt; 18&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval has even more flexibility to call private functions of a class from outside of the class scope. &lt;br /&gt;
&lt;br /&gt;
=====Example 3=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     # We can directly use class_eval to add variables to the instance of the class&lt;br /&gt;
     test1.class_eval{ instance_variable_set :@myvar2 , 25 }   &lt;br /&gt;
     test1.class_eval{ @myvar2 } #=&amp;gt; 25&lt;br /&gt;
     # Or We can remove variables from an instance of the class&lt;br /&gt;
     test1.class_eval{ remove_instance_variable :@myvar2 }&lt;br /&gt;
     test1.class_eval{ @myvar2 } #=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval is capable of defining and removing instance variables from the instance of a class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Define Method Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.html#M001654 define_method] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object to declare methods directly.  This method can be accomplished by using the class_eval method but is also a bit more flexible in it's notation.  An example of the use of this function is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;This is my String!&amp;quot;)&lt;br /&gt;
     #We can use define_method to create a instance method for this class with multiple parameters.&lt;br /&gt;
     test1.class_eval{ define_method(:getSubString){|start, end| @secret[start,end]} }&lt;br /&gt;
     test1.getSubString(5,9)   #=&amp;gt; &amp;quot;is my&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This example shows how to use define_method to create an instance method with multiple parameters by the common block notation.  Please not that we did have to use class_eval still to access the define_method.  This was due to the fact that define_method is a private method within the Module class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Ruby Conclusions====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The ruby language provides great support for reflection due to the nature of its design.  By using the class_eval method by itself one could completely encompass majority of the required reflection programming.  The other functions do provide some other basic support not granted to the class_eval function, specifically the eval function in combination with bindings.  The use of bindings allow the program to save the context of scope at some particular moment in the program and access it later.  With these functions ruby makes reflection simple.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusions=&lt;br /&gt;
&lt;br /&gt;
All of the Reflection API's had one thing in common.  The ability to analyze classes and determine information about them from the available metadata.  C#'s API allows the usage of dynamically loaded classes but does not seem as trivial to use as the other APIs.  Java has take it a step further and allows instance variables to be monitored during execution as well as the ability to call classes' private functions as needed.  Java has proven to be a very flexible reflection API.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The most flexible Reflection API by far is Ruby's.  The nature of Ruby's language allows it to dynamically create and destroy classes as well as variables and methods within the class.  No other language that we've seen will allow you to add or remove functionality of a class as needed during execution.  This allows Ruby programmers to invent new and interesting uses for this flexibility when designing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
[1] [http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection Wikipedia]&lt;br /&gt;
&lt;br /&gt;
[2] [http://www.codersource.net/published/view/291/reflection_in.aspx Reflection in C# - CoderSource.net]&lt;br /&gt;
&lt;br /&gt;
[3] [http://msdn.microsoft.com/en-us/library/f7ykdhsy.aspx MSDN Visual C# - Reflection Programmers Guide]&lt;br /&gt;
&lt;br /&gt;
[4] [http://www.khelll.com/blog/ruby/ruby-reflection/ Ruby Reflection]&lt;br /&gt;
&lt;br /&gt;
[5] [http://practicalruby.blogspot.com/2007/02/ruby-metaprogramming-introduction.html A Ruby Metaprogramming Introduction]&lt;br /&gt;
&lt;br /&gt;
[6] [http://books.google.com/books?id=jcUbTcr5XWwC&amp;amp;lpg=PA266&amp;amp;ots=fHFlsa2wgC&amp;amp;dq=Ruby%20Reflection%20API&amp;amp;pg=PA265#v=onepage&amp;amp;q=Ruby%20Reflection%20API&amp;amp;f=false Ruby Programming Language - Reflection and Metaprogramming]&lt;br /&gt;
&lt;br /&gt;
[7] [http://tutorials.jenkov.com/java-reflection/index.html Java Reflection Tutorial]&lt;br /&gt;
&lt;br /&gt;
[8] [http://java.sun.com/docs/books/tutorial/reflect/ Java Reflection API]&lt;br /&gt;
&lt;br /&gt;
[9] [http://java.sun.com/j2se/1.4.2/docs/api/java/lang/reflect/package-summary.html Java Reflection API Listing]&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=24656</id>
		<title>CSC/ECE 517 Fall 2009/wiki2 5 jn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=24656"/>
		<updated>2009-10-09T22:39:25Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Reflection APIs (TOC)=&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
====What is Reflection?====&lt;br /&gt;
[http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection] in programming is a technique in which programs are able to dynamically view and alter their own structure and flow.  For example, in reflection one could determine method/variable/class names, add or delete method/variables, alter code to current methods, or simply alter values in variables.  Reflection is a subset of [http://en.wikipedia.org/wiki/Metaprogramming MetaProgramming] which relies heavily on the use of meta-information.  Meta-Information is used to keep track of the program structure such as names of available methods, variables and classes but also is what really makes reflection possible.  In theory there are nearly no bounds to reflection as it directly modifies the binary of the program.  The current limitations of this process are related to the APIs available for specific languages.  Majority of object-oriented languages have the functionality built in and some like C++ require external libraries to achieve even the basic functionality of Reflection.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===What languages are Supported?===&lt;br /&gt;
Due to the complexity required to support this majority of the languages that support this feature tend to be object oriented.  Some examples of supported languages are [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/JavaScript JavaScript], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], and [http://en.wikipedia.org/wiki/ActionScript ActionScript].  In this page we will cover a select few of the languages above and what native API support is avaliable for each of the languages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Terminology=&lt;br /&gt;
&lt;br /&gt;
*'''Reflection''' - the process by which a computer program can observe and modify its own structure and behavior.&lt;br /&gt;
*'''MetaProgramming''' - the writing of computer programs that write or manipulate other programs (or themselves) as their data.&lt;br /&gt;
*'''MetaData''' - &amp;quot;data about data&amp;quot;.  Describes how and when and by whom a particular set of data was collected, and how the data is formatted.&lt;br /&gt;
*'''Binding''' - an object that encapsulates the execution context at some particular place in the code.&lt;br /&gt;
*'''Instance''' - an object with functionality and information described by a class.&lt;br /&gt;
*'''Scope''' - a location in a program where the value of the variable is available.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in C#=&lt;br /&gt;
&lt;br /&gt;
Reflection in C# is included in the .NET framework provided by microsoft.  The methods and classes usable for reflection are access directly from the System.Reflection namespace and support any class type available under the .NET framework.  The basis of reflection in C# is powered by the Type class which is the way metadata is accessed.  This type object gives information about all available methods, variables, constructors, and more from a given class.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reflection in C# is not as dynamic as some other languages in the fact that it doesn't support the alteration of class variables, methods, and attributes.  As shown above the reflection implementation in C# is more for data collection and analysis for object types.  One of the best applications for Reflection in C# is the flexibility to dynamically load assembly code at runtime, ascertain information about the methods, variables and constructors, and then invoke code directly.  This type of usage makes examples especially hard to include in a short description as this.  For this reason the example has been simplified and is displayed below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
 public class Counter&lt;br /&gt;
 {&lt;br /&gt;
      // Private Variable&lt;br /&gt;
      private int ctr;&lt;br /&gt;
      // Constructor&lt;br /&gt;
      public Counter(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           ctr = temp;&lt;br /&gt;
      }&lt;br /&gt;
      // Increment&lt;br /&gt;
      public int Inc(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           return ctr+=temp;&lt;br /&gt;
      }&lt;br /&gt;
      // Decrement&lt;br /&gt;
      public int Dec(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           return ctr-=temp;&lt;br /&gt;
      }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Suppose we have the basic class as listed above.  There is only one constructor, one private instance variable, and two functions which increment or decrement the instance variable by a certain amount.  We could easily begin obtaining information about this class by performing the code below.&lt;br /&gt;
&lt;br /&gt;
 Counter myCtr = new Counter(1000);&lt;br /&gt;
 Type tempType = myCtr.GetType();&lt;br /&gt;
&lt;br /&gt;
From the instance of myCtr we were able to use the GetType method to instantiate and parse meta-information about the Counter class.  Keep in mind that this class could have been invoked at compile time and that we may have no previous information about it.  We could then dynamically determine what constructors and methods were available by performing the following actions.&lt;br /&gt;
&lt;br /&gt;
 ConstructorInfo [] c_info = tempType.GetConstructors();&lt;br /&gt;
 MethodInfo [] m_info = tempType.GetMethods();&lt;br /&gt;
&lt;br /&gt;
From these two lines of code we now have an array of information for both the available methods and the available constructors.  We can use the information in these two types to dynamically incorporate the class into the system at runtime.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====C# Conclusions=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The included reflection API in the C# language creates a way for programmers to dynamically retrieve information from external assembly code.  They can then proceed to use that information to access the types available from the assembly.  While this is a difficult concept to grasp it does have its usages.  In the System.Reflection.Emit namespace there is a way to dynamically create types.  This form of reflection is typically used by script engines and compilers as they import external types to be used in the current binaries.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in Java=&lt;br /&gt;
&lt;br /&gt;
Reflection in Java is much like the reflection available in C#.  Java's Reflection API is located in the java.lang.reflect package and makes it possible for a programmer to dynamically parse information about classes, interfaces, methods, and fields at runtime.  With this information it is possibly to dynamically incorporate these new classes into the running application.  Probably one of the best examples that this could be used for is the Netbeans compiler.  Netbeans is actually a java application which runs and compiles user's java applications.  Once the user chooses to run it Netbeans then dynamically parses the classes and fields, then loads the class to be run.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Java actually has a few advantages over C# in that it can modify access to class fields and methods.  Once it has an instance of the class it can manually override the access and begin calling private and protected functions that users typically wouldn't be able to do.  This could be very useful for performing unit tests on a class since you now have access to all methods and fields.  An example of how both are performed is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example 1=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
     public class testClass {&lt;br /&gt;
        // Private Variable&lt;br /&gt;
        private String privateString = null;&lt;br /&gt;
        // Constructor&lt;br /&gt;
        public testClass(String temp) {&lt;br /&gt;
           privateString = temp;&lt;br /&gt;
        }&lt;br /&gt;
        // Private Method&lt;br /&gt;
        private String getString(){&lt;br /&gt;
          return privateString;&lt;br /&gt;
        }&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
Suppose we had the simple class shown above.  In this class we have both a private field and a private method which we wish to access to perform unit testing on.  Normally this could only be possible by creating public methods to call the private functions and getters and setters to change the fields.  With reflection we could perform the following.&lt;br /&gt;
&lt;br /&gt;
     // Create/Get an instance of the class.&lt;br /&gt;
     testClass m_Class = new testClass(&amp;quot;MyString&amp;quot;);&lt;br /&gt;
     // Get an instance of the field within the class&lt;br /&gt;
     Field m_Field = testClass.class.getDeclaredField(&amp;quot;privateString&amp;quot;);&lt;br /&gt;
     // Remove the access restricition on the variable&lt;br /&gt;
     m_Field.setAccessible(true);&lt;br /&gt;
     // Print the value of the field for a specific instance.&lt;br /&gt;
     System.out.println((String) m_Field.get(m_Class));&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The process of accomplishing this seems a bit daunting especially when you compare it to Ruby's implementation which is described later.  But the result is direct access to instance variables at run-time no matter what the restriction policy.  If we needed to access the private method we could accomplish that as shown below.&lt;br /&gt;
&lt;br /&gt;
     // Create/Get an instance of the class.&lt;br /&gt;
     testClass m_Class = new testClass(&amp;quot;MyString&amp;quot;);&lt;br /&gt;
     // Get an instance of the method within the class&lt;br /&gt;
     Method m_Method = testClass.class.getDeclaredMethod(&amp;quot;getString&amp;quot;, null);&lt;br /&gt;
     // Remove the access restricition on the method&lt;br /&gt;
     m_Method.setAccessible(true);&lt;br /&gt;
     // Print the result of method for a specific instance.&lt;br /&gt;
     System.out.println((String) m_Method.invoke(m_Class, null));&lt;br /&gt;
&lt;br /&gt;
The result is the same as from the previous section of code.  We simply accessed the private getter rather than calling the instance variable directly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example 2=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
In the C# example we were not able to present any code for dynamically loading classes into the running program due to the complexity and length.  Java has made this process relatively simple and only requires a few lines of code.  Below is how we could dynamically load our previous class example from an outside source.&lt;br /&gt;
&lt;br /&gt;
public class test2Class {&lt;br /&gt;
  // Main Method of invokiing class&lt;br /&gt;
  public static void main(String[] args){&lt;br /&gt;
    // Instance of a classloader as part of this class&lt;br /&gt;
    ClassLoader m_Loader = test2Class.class.getClassLoader();&lt;br /&gt;
    // Try/Catch Block&lt;br /&gt;
    try {&lt;br /&gt;
        Class m_Class = m_Loader.loadClass(&amp;quot;com.myClassPackage.testClass&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Successfully loaded class: &amp;quot; + m_Class.getName());&lt;br /&gt;
    } &lt;br /&gt;
    catch (ClassNotFoundException e) {&lt;br /&gt;
        System.err.println(e)    &lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The result from above is &amp;quot;testClass&amp;quot; as it loaded our example class from before.  From here we could now instantiate the class and call its functions (or search for what functions it has to offer).  This gives real insight to the flexibility of Java's Reflection API and how it could be practically used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Java Conclusions====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Java's Reflection API supplies a great deal of flexibility.  It allows the user almost complete access to classes as well as the ability to dynamically load new classes and utilize their functions.  While some of the method calls aren't trivial majority of the coding is understandable and very useful once you understand what is going on.  Java also has the added advantage to access private functions and variables of a class instance which can allow easier unit testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in Ruby=&lt;br /&gt;
&lt;br /&gt;
The nature of Ruby as an object-oriented language gives great support for Reflection.  The big advantage to ruby is it gives us complete flexibility and control with reflection.  Most usages of reflection is only to obtain information and create new types dynamically but not modify current ones.  With Ruby's reflection api we have the ability to add or remove almost anything, whether that's a method, a class, or even class variables.  Please note that this flexibility can also lead to a programs downfall as with any reflection API.  Too much alteration of the source code can cause many unknown bugs.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The current support for reflection in ruby is built into the language and is accessible through certain functions within the standard Ruby API.  The methods most commonly used for reflection in Ruby along with some basic examples of their usage are shown below.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Kernel.html#M005922 eval] method is defined in the Kernel Module of Ruby and is used to evaluate literals encompassed in strings.  This may not seem useful but the eval method also work in the scope of bindings which represent the scope of execution at a particular place in the code.  This allows programmers to view any variables in any scope for any instance.  An example of eval's usage is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
          def getBinding&lt;br /&gt;
               return binding()&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar is and evaluate it without an accessor method&lt;br /&gt;
     eval(&amp;quot;@myvar&amp;quot;, test1.getBinding)   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
I this example we can see that by acquiring the binding at some scope in the program we can use it to get inside the context of any object instance and determine the value of any instance variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Instance Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Object.html#M000334 instance_eval] method is defined in the Object class and works within the instance of any class.  This method performs much of the same operations as the eval method but works in the scope of an object without requiring the binding statement as above.  In fact we can accomplish the same example as above with the code shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar is and evaluate it without an accessor method&lt;br /&gt;
     test1.instance_eval { @myvar }   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
Again this code performs exactly the same thing as the prior example above.  The result is 17 which is the evaluation of the string literal as a command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Class Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.src/M001650.html class_eval] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object whether that is assigning or accessing variables, declaring instance methods, or even re-defining inherited methods.  The method takes actions either via string literal or a block of code.  This method is one of the strongest and most versatile methods in the Ruby Reflection API since it can access any private methods of any objects and its parents, this giving you full control over control.&lt;br /&gt;
&lt;br /&gt;
=====Example 1=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar by creating an accessor method for this instance.&lt;br /&gt;
     test1.class_eval{ def getVar; @myvar; end }&lt;br /&gt;
     eval(test1.getVar)   #=&amp;gt;  17&lt;br /&gt;
     #Or by simply accessing the local variable as below.&lt;br /&gt;
     eval(test1.class_eval{@myvar})    #=&amp;gt; 17&lt;br /&gt;
&lt;br /&gt;
This example shows the versatility of the class_eval method to work on any class instance.  It performs many of the operations that the previous methods have performed but with the added advantage of assigning instance methods.&lt;br /&gt;
&lt;br /&gt;
=====Example 2=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
       private:&lt;br /&gt;
          def increment&lt;br /&gt;
               @myvar += 1&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     #We can directly use class_eval to call private methods within a class as well.&lt;br /&gt;
     test1.class_eval{ increment() }   #=&amp;gt; 18&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval has even more flexibility to call private functions of a class from outside of the class scope. &lt;br /&gt;
&lt;br /&gt;
=====Example 3=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     # We can directly use class_eval to add variables to the instance of the class&lt;br /&gt;
     test1.class_eval{ instance_variable_set :@myvar2 , 25 }   &lt;br /&gt;
     test1.class_eval{ @myvar2 } #=&amp;gt; 25&lt;br /&gt;
     # Or We can remove variables from an instance of the class&lt;br /&gt;
     test1.class_eval{ remove_instance_variable :@myvar2 }&lt;br /&gt;
     test1.class_eval{ @myvar2 } #=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval is capable of defining and removing instance variables from the instance of a class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Define Method Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.html#M001654 define_method] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object to declare methods directly.  This method can be accomplished by using the class_eval method but is also a bit more flexible in it's notation.  An example of the use of this function is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;This is my String!&amp;quot;)&lt;br /&gt;
     #We can use define_method to create a instance method for this class with multiple parameters.&lt;br /&gt;
     test1.class_eval{ define_method(:getSubString){|start, end| @secret[start,end]} }&lt;br /&gt;
     test1.getSubString(5,9)   #=&amp;gt; &amp;quot;is my&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This example shows how to use define_method to create an instance method with multiple parameters by the common block notation.  Please not that we did have to use class_eval still to access the define_method.  This was due to the fact that define_method is a private method within the Module class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Ruby Conclusions====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The ruby language provides great support for reflection due to the nature of its design.  By using the class_eval method by itself one could completely encompass majority of the required reflection programming.  The other functions do provide some other basic support not granted to the class_eval function, specifically the eval function in combination with bindings.  The use of bindings allow the program to save the context of scope at some particular moment in the program and access it later.  With these functions ruby makes reflection simple.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusions=&lt;br /&gt;
&lt;br /&gt;
All of the Reflection API's had one thing in common.  The ability to analyze classes and determine information about them from the available metadata.  C#'s API allows the usage of dynamically loaded classes but does not seem as trivial to use as the other APIs.  Java has take it a step further and allows instance variables to be monitored during execution as well as the ability to call classes' private functions as needed.  Java has proven to be a very flexible reflection API.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The most flexible Reflection API by far is Ruby's.  The nature of Ruby's language allows it to dynamically create and destroy classes as well as variables and methods within the class.  No other language that we've seen will allow you to add or remove functionality of a class as needed during execution.  This allows Ruby programmers to invent new and interesting uses for this flexibility when designing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
[1] [http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection Wikipedia]&lt;br /&gt;
&lt;br /&gt;
[2] [http://www.codersource.net/published/view/291/reflection_in.aspx Reflection in C# - CoderSource.net]&lt;br /&gt;
&lt;br /&gt;
[3] [http://msdn.microsoft.com/en-us/library/f7ykdhsy.aspx MSDN Visual C# - Reflection Programmers Guide]&lt;br /&gt;
&lt;br /&gt;
[4] [http://www.khelll.com/blog/ruby/ruby-reflection/ Ruby Reflection]&lt;br /&gt;
&lt;br /&gt;
[5] [http://practicalruby.blogspot.com/2007/02/ruby-metaprogramming-introduction.html A Ruby Metaprogramming Introduction]&lt;br /&gt;
&lt;br /&gt;
[6] [http://books.google.com/books?id=jcUbTcr5XWwC&amp;amp;lpg=PA266&amp;amp;ots=fHFlsa2wgC&amp;amp;dq=Ruby%20Reflection%20API&amp;amp;pg=PA265#v=onepage&amp;amp;q=Ruby%20Reflection%20API&amp;amp;f=false Ruby Programming Language - Reflection and Metaprogramming]&lt;br /&gt;
&lt;br /&gt;
[7] [http://tutorials.jenkov.com/java-reflection/index.html Java Reflection Tutorial]&lt;br /&gt;
&lt;br /&gt;
[8] [http://java.sun.com/docs/books/tutorial/reflect/ Java Reflection API]&lt;br /&gt;
&lt;br /&gt;
[9] [http://java.sun.com/j2se/1.4.2/docs/api/java/lang/reflect/package-summary.html Java Reflection API Listing]&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=24653</id>
		<title>CSC/ECE 517 Fall 2009/wiki2 5 jn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=24653"/>
		<updated>2009-10-09T22:38:44Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Reflection APIs (TOC)=&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
====What is Reflection?====&lt;br /&gt;
[http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection] in programming is a technique in which programs are able to dynamically view and alter their own structure and flow.  For example, in reflection one could determine method/variable/class names, add or delete method/variables, alter code to current methods, or simply alter values in variables.  Reflection is a subset of [http://en.wikipedia.org/wiki/Metaprogramming MetaProgramming] which relies heavily on the use of meta-information.  Meta-Information is used to keep track of the program structure such as names of available methods, variables and classes but also is what really makes reflection possible.  In theory there are nearly no bounds to reflection as it directly modifies the binary of the program.  The current limitations of this process are related to the APIs available for specific languages.  Majority of object-oriented languages have the functionality built in and some like C++ require external libraries to achieve even the basic functionality of Reflection.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===What languages are Supported?===&lt;br /&gt;
Due to the complexity required to support this majority of the languages that support this feature tend to be object oriented.  Some examples of supported languages are [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/JavaScript JavaScript], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], and [http://en.wikipedia.org/wiki/ActionScript ActionScript].  In this page we will cover a select few of the languages above and what native API support is avaliable for each of the languages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Terminology=&lt;br /&gt;
&lt;br /&gt;
*Reflection - the process by which a computer program can observe and modify its own structure and behavior.&lt;br /&gt;
*MetaProgramming - the writing of computer programs that write or manipulate other programs (or themselves) as their data.&lt;br /&gt;
*MetaData - &amp;quot;data about data&amp;quot;.  Describes how and when and by whom a particular set of data was collected, and how the data is formatted.&lt;br /&gt;
*Binding - an object that encapsulates the execution context at some particular place in the code.&lt;br /&gt;
*Instance - an object with functionality and information described by a class.&lt;br /&gt;
*Scope - a location in a program where the value of the variable is available.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in C#=&lt;br /&gt;
&lt;br /&gt;
Reflection in C# is included in the .NET framework provided by microsoft.  The methods and classes usable for reflection are access directly from the System.Reflection namespace and support any class type available under the .NET framework.  The basis of reflection in C# is powered by the Type class which is the way metadata is accessed.  This type object gives information about all available methods, variables, constructors, and more from a given class.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reflection in C# is not as dynamic as some other languages in the fact that it doesn't support the alteration of class variables, methods, and attributes.  As shown above the reflection implementation in C# is more for data collection and analysis for object types.  One of the best applications for Reflection in C# is the flexibility to dynamically load assembly code at runtime, ascertain information about the methods, variables and constructors, and then invoke code directly.  This type of usage makes examples especially hard to include in a short description as this.  For this reason the example has been simplified and is displayed below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
 public class Counter&lt;br /&gt;
 {&lt;br /&gt;
      // Private Variable&lt;br /&gt;
      private int ctr;&lt;br /&gt;
      // Constructor&lt;br /&gt;
      public Counter(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           ctr = temp;&lt;br /&gt;
      }&lt;br /&gt;
      // Increment&lt;br /&gt;
      public int Inc(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           return ctr+=temp;&lt;br /&gt;
      }&lt;br /&gt;
      // Decrement&lt;br /&gt;
      public int Dec(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           return ctr-=temp;&lt;br /&gt;
      }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Suppose we have the basic class as listed above.  There is only one constructor, one private instance variable, and two functions which increment or decrement the instance variable by a certain amount.  We could easily begin obtaining information about this class by performing the code below.&lt;br /&gt;
&lt;br /&gt;
 Counter myCtr = new Counter(1000);&lt;br /&gt;
 Type tempType = myCtr.GetType();&lt;br /&gt;
&lt;br /&gt;
From the instance of myCtr we were able to use the GetType method to instantiate and parse meta-information about the Counter class.  Keep in mind that this class could have been invoked at compile time and that we may have no previous information about it.  We could then dynamically determine what constructors and methods were available by performing the following actions.&lt;br /&gt;
&lt;br /&gt;
 ConstructorInfo [] c_info = tempType.GetConstructors();&lt;br /&gt;
 MethodInfo [] m_info = tempType.GetMethods();&lt;br /&gt;
&lt;br /&gt;
From these two lines of code we now have an array of information for both the available methods and the available constructors.  We can use the information in these two types to dynamically incorporate the class into the system at runtime.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====C# Conclusions=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The included reflection API in the C# language creates a way for programmers to dynamically retrieve information from external assembly code.  They can then proceed to use that information to access the types available from the assembly.  While this is a difficult concept to grasp it does have its usages.  In the System.Reflection.Emit namespace there is a way to dynamically create types.  This form of reflection is typically used by script engines and compilers as they import external types to be used in the current binaries.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in Java=&lt;br /&gt;
&lt;br /&gt;
Reflection in Java is much like the reflection available in C#.  Java's Reflection API is located in the java.lang.reflect package and makes it possible for a programmer to dynamically parse information about classes, interfaces, methods, and fields at runtime.  With this information it is possibly to dynamically incorporate these new classes into the running application.  Probably one of the best examples that this could be used for is the Netbeans compiler.  Netbeans is actually a java application which runs and compiles user's java applications.  Once the user chooses to run it Netbeans then dynamically parses the classes and fields, then loads the class to be run.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Java actually has a few advantages over C# in that it can modify access to class fields and methods.  Once it has an instance of the class it can manually override the access and begin calling private and protected functions that users typically wouldn't be able to do.  This could be very useful for performing unit tests on a class since you now have access to all methods and fields.  An example of how both are performed is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example 1=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
     public class testClass {&lt;br /&gt;
        // Private Variable&lt;br /&gt;
        private String privateString = null;&lt;br /&gt;
        // Constructor&lt;br /&gt;
        public testClass(String temp) {&lt;br /&gt;
           privateString = temp;&lt;br /&gt;
        }&lt;br /&gt;
        // Private Method&lt;br /&gt;
        private String getString(){&lt;br /&gt;
          return privateString;&lt;br /&gt;
        }&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
Suppose we had the simple class shown above.  In this class we have both a private field and a private method which we wish to access to perform unit testing on.  Normally this could only be possible by creating public methods to call the private functions and getters and setters to change the fields.  With reflection we could perform the following.&lt;br /&gt;
&lt;br /&gt;
     // Create/Get an instance of the class.&lt;br /&gt;
     testClass m_Class = new testClass(&amp;quot;MyString&amp;quot;);&lt;br /&gt;
     // Get an instance of the field within the class&lt;br /&gt;
     Field m_Field = testClass.class.getDeclaredField(&amp;quot;privateString&amp;quot;);&lt;br /&gt;
     // Remove the access restricition on the variable&lt;br /&gt;
     m_Field.setAccessible(true);&lt;br /&gt;
     // Print the value of the field for a specific instance.&lt;br /&gt;
     System.out.println((String) m_Field.get(m_Class));&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The process of accomplishing this seems a bit daunting especially when you compare it to Ruby's implementation which is described later.  But the result is direct access to instance variables at run-time no matter what the restriction policy.  If we needed to access the private method we could accomplish that as shown below.&lt;br /&gt;
&lt;br /&gt;
     // Create/Get an instance of the class.&lt;br /&gt;
     testClass m_Class = new testClass(&amp;quot;MyString&amp;quot;);&lt;br /&gt;
     // Get an instance of the method within the class&lt;br /&gt;
     Method m_Method = testClass.class.getDeclaredMethod(&amp;quot;getString&amp;quot;, null);&lt;br /&gt;
     // Remove the access restricition on the method&lt;br /&gt;
     m_Method.setAccessible(true);&lt;br /&gt;
     // Print the result of method for a specific instance.&lt;br /&gt;
     System.out.println((String) m_Method.invoke(m_Class, null));&lt;br /&gt;
&lt;br /&gt;
The result is the same as from the previous section of code.  We simply accessed the private getter rather than calling the instance variable directly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example 2=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
In the C# example we were not able to present any code for dynamically loading classes into the running program due to the complexity and length.  Java has made this process relatively simple and only requires a few lines of code.  Below is how we could dynamically load our previous class example from an outside source.&lt;br /&gt;
&lt;br /&gt;
public class test2Class {&lt;br /&gt;
  // Main Method of invokiing class&lt;br /&gt;
  public static void main(String[] args){&lt;br /&gt;
    // Instance of a classloader as part of this class&lt;br /&gt;
    ClassLoader m_Loader = test2Class.class.getClassLoader();&lt;br /&gt;
    // Try/Catch Block&lt;br /&gt;
    try {&lt;br /&gt;
        Class m_Class = m_Loader.loadClass(&amp;quot;com.myClassPackage.testClass&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Successfully loaded class: &amp;quot; + m_Class.getName());&lt;br /&gt;
    } &lt;br /&gt;
    catch (ClassNotFoundException e) {&lt;br /&gt;
        System.err.println(e)    &lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The result from above is &amp;quot;testClass&amp;quot; as it loaded our example class from before.  From here we could now instantiate the class and call its functions (or search for what functions it has to offer).  This gives real insight to the flexibility of Java's Reflection API and how it could be practically used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Java Conclusions====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Java's Reflection API supplies a great deal of flexibility.  It allows the user almost complete access to classes as well as the ability to dynamically load new classes and utilize their functions.  While some of the method calls aren't trivial majority of the coding is understandable and very useful once you understand what is going on.  Java also has the added advantage to access private functions and variables of a class instance which can allow easier unit testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in Ruby=&lt;br /&gt;
&lt;br /&gt;
The nature of Ruby as an object-oriented language gives great support for Reflection.  The big advantage to ruby is it gives us complete flexibility and control with reflection.  Most usages of reflection is only to obtain information and create new types dynamically but not modify current ones.  With Ruby's reflection api we have the ability to add or remove almost anything, whether that's a method, a class, or even class variables.  Please note that this flexibility can also lead to a programs downfall as with any reflection API.  Too much alteration of the source code can cause many unknown bugs.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The current support for reflection in ruby is built into the language and is accessible through certain functions within the standard Ruby API.  The methods most commonly used for reflection in Ruby along with some basic examples of their usage are shown below.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Kernel.html#M005922 eval] method is defined in the Kernel Module of Ruby and is used to evaluate literals encompassed in strings.  This may not seem useful but the eval method also work in the scope of bindings which represent the scope of execution at a particular place in the code.  This allows programmers to view any variables in any scope for any instance.  An example of eval's usage is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
          def getBinding&lt;br /&gt;
               return binding()&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar is and evaluate it without an accessor method&lt;br /&gt;
     eval(&amp;quot;@myvar&amp;quot;, test1.getBinding)   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
I this example we can see that by acquiring the binding at some scope in the program we can use it to get inside the context of any object instance and determine the value of any instance variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Instance Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Object.html#M000334 instance_eval] method is defined in the Object class and works within the instance of any class.  This method performs much of the same operations as the eval method but works in the scope of an object without requiring the binding statement as above.  In fact we can accomplish the same example as above with the code shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar is and evaluate it without an accessor method&lt;br /&gt;
     test1.instance_eval { @myvar }   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
Again this code performs exactly the same thing as the prior example above.  The result is 17 which is the evaluation of the string literal as a command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Class Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.src/M001650.html class_eval] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object whether that is assigning or accessing variables, declaring instance methods, or even re-defining inherited methods.  The method takes actions either via string literal or a block of code.  This method is one of the strongest and most versatile methods in the Ruby Reflection API since it can access any private methods of any objects and its parents, this giving you full control over control.&lt;br /&gt;
&lt;br /&gt;
=====Example 1=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar by creating an accessor method for this instance.&lt;br /&gt;
     test1.class_eval{ def getVar; @myvar; end }&lt;br /&gt;
     eval(test1.getVar)   #=&amp;gt;  17&lt;br /&gt;
     #Or by simply accessing the local variable as below.&lt;br /&gt;
     eval(test1.class_eval{@myvar})    #=&amp;gt; 17&lt;br /&gt;
&lt;br /&gt;
This example shows the versatility of the class_eval method to work on any class instance.  It performs many of the operations that the previous methods have performed but with the added advantage of assigning instance methods.&lt;br /&gt;
&lt;br /&gt;
=====Example 2=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
       private:&lt;br /&gt;
          def increment&lt;br /&gt;
               @myvar += 1&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     #We can directly use class_eval to call private methods within a class as well.&lt;br /&gt;
     test1.class_eval{ increment() }   #=&amp;gt; 18&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval has even more flexibility to call private functions of a class from outside of the class scope. &lt;br /&gt;
&lt;br /&gt;
=====Example 3=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     # We can directly use class_eval to add variables to the instance of the class&lt;br /&gt;
     test1.class_eval{ instance_variable_set :@myvar2 , 25 }   &lt;br /&gt;
     test1.class_eval{ @myvar2 } #=&amp;gt; 25&lt;br /&gt;
     # Or We can remove variables from an instance of the class&lt;br /&gt;
     test1.class_eval{ remove_instance_variable :@myvar2 }&lt;br /&gt;
     test1.class_eval{ @myvar2 } #=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval is capable of defining and removing instance variables from the instance of a class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Define Method Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.html#M001654 define_method] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object to declare methods directly.  This method can be accomplished by using the class_eval method but is also a bit more flexible in it's notation.  An example of the use of this function is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;This is my String!&amp;quot;)&lt;br /&gt;
     #We can use define_method to create a instance method for this class with multiple parameters.&lt;br /&gt;
     test1.class_eval{ define_method(:getSubString){|start, end| @secret[start,end]} }&lt;br /&gt;
     test1.getSubString(5,9)   #=&amp;gt; &amp;quot;is my&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This example shows how to use define_method to create an instance method with multiple parameters by the common block notation.  Please not that we did have to use class_eval still to access the define_method.  This was due to the fact that define_method is a private method within the Module class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Ruby Conclusions====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The ruby language provides great support for reflection due to the nature of its design.  By using the class_eval method by itself one could completely encompass majority of the required reflection programming.  The other functions do provide some other basic support not granted to the class_eval function, specifically the eval function in combination with bindings.  The use of bindings allow the program to save the context of scope at some particular moment in the program and access it later.  With these functions ruby makes reflection simple.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusions=&lt;br /&gt;
&lt;br /&gt;
All of the Reflection API's had one thing in common.  The ability to analyze classes and determine information about them from the available metadata.  C#'s API allows the usage of dynamically loaded classes but does not seem as trivial to use as the other APIs.  Java has take it a step further and allows instance variables to be monitored during execution as well as the ability to call classes' private functions as needed.  Java has proven to be a very flexible reflection API.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The most flexible Reflection API by far is Ruby's.  The nature of Ruby's language allows it to dynamically create and destroy classes as well as variables and methods within the class.  No other language that we've seen will allow you to add or remove functionality of a class as needed during execution.  This allows Ruby programmers to invent new and interesting uses for this flexibility when designing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
[1] [http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection Wikipedia]&lt;br /&gt;
&lt;br /&gt;
[2] [http://www.codersource.net/published/view/291/reflection_in.aspx Reflection in C# - CoderSource.net]&lt;br /&gt;
&lt;br /&gt;
[3] [http://msdn.microsoft.com/en-us/library/f7ykdhsy.aspx MSDN Visual C# - Reflection Programmers Guide]&lt;br /&gt;
&lt;br /&gt;
[4] [http://www.khelll.com/blog/ruby/ruby-reflection/ Ruby Reflection]&lt;br /&gt;
&lt;br /&gt;
[5] [http://practicalruby.blogspot.com/2007/02/ruby-metaprogramming-introduction.html A Ruby Metaprogramming Introduction]&lt;br /&gt;
&lt;br /&gt;
[6] [http://books.google.com/books?id=jcUbTcr5XWwC&amp;amp;lpg=PA266&amp;amp;ots=fHFlsa2wgC&amp;amp;dq=Ruby%20Reflection%20API&amp;amp;pg=PA265#v=onepage&amp;amp;q=Ruby%20Reflection%20API&amp;amp;f=false Ruby Programming Language - Reflection and Metaprogramming]&lt;br /&gt;
&lt;br /&gt;
[7] [http://tutorials.jenkov.com/java-reflection/index.html Java Reflection Tutorial]&lt;br /&gt;
&lt;br /&gt;
[8] [http://java.sun.com/docs/books/tutorial/reflect/ Java Reflection API]&lt;br /&gt;
&lt;br /&gt;
[9] [http://java.sun.com/j2se/1.4.2/docs/api/java/lang/reflect/package-summary.html Java Reflection API Listing]&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=24614</id>
		<title>CSC/ECE 517 Fall 2009/wiki2 5 jn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=24614"/>
		<updated>2009-10-09T22:22:47Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Reflection APIs (TOC)=&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
====What is Reflection?====&lt;br /&gt;
[http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection] in programming is a technique in which programs are able to dynamically view and alter their own structure and flow.  For example, in reflection one could determine method/variable/class names, add or delete method/variables, alter code to current methods, or simply alter values in variables.  Reflection is a subset of [http://en.wikipedia.org/wiki/Metaprogramming MetaProgramming] which relies heavily on the use of meta-information.  Meta-Information is used to keep track of the program structure such as names of available methods,variables and classes but also is what really makes reflection possible.  In theory there are nearly no bounds to reflection as it directly modifies the binary of the program.  The current limitations of this process are related to the APIs avaliable for specific languages.  Majority of object-oriented languages have the functionality built in and some like C++ require external libraries to achieve even the basic functionality of Reflection.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===What languages are Supported?===&lt;br /&gt;
Due to the complexity required to support this majority of the languages that support this feature tend to be object oriented.  Some examples of supported languages are [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/JavaScript JavaScript], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], and [http://en.wikipedia.org/wiki/ActionScript ActionScript].  In this page we will cover a select few of the languages above and what native API support is avaliable for each of the languages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Terminology=&lt;br /&gt;
&lt;br /&gt;
*Reflection&lt;br /&gt;
*MetaProgramming&lt;br /&gt;
*MetaData&lt;br /&gt;
*Binding&lt;br /&gt;
*Instance&lt;br /&gt;
*Scope&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in C#=&lt;br /&gt;
&lt;br /&gt;
Reflection in C# is included in the .NET framework provided by microsoft.  The methods and classes usable for reflection are access directly from the System.Reflection namespace and support any class type avaliable under the .NET framework.  The basis of reflection in C# is powered by the Type class which is the way metadata is accessed.  This type object gives information about all avaliable methods, variables, constructors, and more from a given class.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reflection in C# is not as dynamic as some other languages in the fact that it doesn't support the alteration of class variables, methods, and attributes.  As shown above the reflection implementation in C# is more for data collection and anaysis for object types.  One of the best applications for Reflection in C# is the flexibility to dyniamically load assembly code at runtime, ascertain information about the methods, variables and constructors, and then invoke code directly.  This type of usage makes examples especially hard to include in a short diescription as this.  For this reason the examples have been simplified and is displayed below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
 public class Counter&lt;br /&gt;
 {&lt;br /&gt;
      // Private Variable&lt;br /&gt;
      private int ctr;&lt;br /&gt;
      // Constructor&lt;br /&gt;
      public Counter(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           ctr = temp;&lt;br /&gt;
      }&lt;br /&gt;
      // Increment&lt;br /&gt;
      public int Inc(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           return ctr+=temp;&lt;br /&gt;
      }&lt;br /&gt;
      // Decrement&lt;br /&gt;
      public int Dec(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           return ctr-=temp;&lt;br /&gt;
      }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Suppose we have the basic class as listed above.  There is only one constructor, one private instance variable, and two functions which increment or decrement the instance variable by a certain amount.  We could easily begin obtaining information about this class by performing the code below.&lt;br /&gt;
&lt;br /&gt;
 Counter myCtr = new Counter(1000);&lt;br /&gt;
 Type tempType = myCtr.GetType();&lt;br /&gt;
&lt;br /&gt;
From the instance of myCtr we were able to use the GetType method to instantiate and parse meta-information about the Counter class.  Keep in mind that this class could have been invoked at compile time and that we may have no previous information about it.  We could then dynamically determine what constructors and methods were avaliable by performing the following actions.&lt;br /&gt;
&lt;br /&gt;
 ConstructorInfo [] c_info = tempType.GetConstructors();&lt;br /&gt;
 MethodInfo [] m_info = tempType.GetMethods();&lt;br /&gt;
&lt;br /&gt;
From these two lines of code we now have an array of infmoration for both the avaliable methods and the avaliable constructors.  We can use the information in these two types to dynamically incoroporate the class into the system at runtime.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====C# Conclusions=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The included reflection API in the C# language creates a way for programmers to dynamically retrieve information from external assembly code.  They can then proceed to use that information to access the types avaliable from the assembly.  While this is a difficult concept to grasp it does have its usages.  In the System.Reflection.Emit namespace there is a way to dynamically create types.  This form of reflection is typically used by script engines and compilers as they import external types to be used in the current binaries.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in Java=&lt;br /&gt;
&lt;br /&gt;
Reflection in Java is much like the reflection avaliable in C#.  Java's Reflection API is located in the java.lang.reflect package and makes it possible for a programmer to dynamically parse information about classes, interfaces, methods, and fields at runtime.  With this information it is possibly to dynamically incorporate these new classes into the running application.  Probably one of the best examples that this could be used for is the Netbeans compiler.  Netbeans is actually a java application which runs and compiles users java applications.  Once the user chooses to run it Netbeans then dynamically parses the classes and fields, then loads the class to be run.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Java actually has a few advantages over C# in that it can modify access to class fields and methods.  Once it has an instance of the class it can manually override the access and begin calling private and protected functions that users typically wouldn't be able to do.  This could be very useful for performing unit tests on a class since you now have access to all methods and fields.  And example of how both are performed is shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example 1=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
     public class testClass {&lt;br /&gt;
        // Private Variable&lt;br /&gt;
        private String privateString = null;&lt;br /&gt;
        // Constructor&lt;br /&gt;
        public testClass(String temp) {&lt;br /&gt;
           privateString = temp;&lt;br /&gt;
        }&lt;br /&gt;
        // Private Method&lt;br /&gt;
        private String getString(){&lt;br /&gt;
          return privateString;&lt;br /&gt;
        }&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
Suppose we had the simple class shown above.  In this class we have both a private field and a private method which we wish to access to perform unit testing on.  Normally this could only be possible by creating public methods to call the private functions and getters and setters to change the fields.  With reflection we could perform the following.&lt;br /&gt;
&lt;br /&gt;
     // Create/Get an instance of the class.&lt;br /&gt;
     testClass m_Class = new testClass(&amp;quot;MyString&amp;quot;);&lt;br /&gt;
     // Get an instance of the field within the class&lt;br /&gt;
     Field m_Field = testClass.class.getDeclaredField(&amp;quot;privateString&amp;quot;);&lt;br /&gt;
     // Remove the access restricition on the variable&lt;br /&gt;
     m_Field.setAccessible(true);&lt;br /&gt;
     // Print the value of the field for a specific instance.&lt;br /&gt;
     System.out.println((String) m_Field.get(m_Class));&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The process of accomplishing this seems a bit daunting especially when you compare it to Ruby's implementation which is described later.  But the result is direct access to instance variables at run-time no matter what the restriction policy.  If we needed to access the private method we could accomplish that as shown below.&lt;br /&gt;
&lt;br /&gt;
     // Create/Get an instance of the class.&lt;br /&gt;
     testClass m_Class = new testClass(&amp;quot;MyString&amp;quot;);&lt;br /&gt;
     // Get an instance of the method within the class&lt;br /&gt;
     Method m_Method = testClass.class.getDeclaredMethod(&amp;quot;getString&amp;quot;, null);&lt;br /&gt;
     // Remove the access restricition on the method&lt;br /&gt;
     m_Method.setAccessible(true);&lt;br /&gt;
     // Print the result of method for a specific instance.&lt;br /&gt;
     System.out.println((String) m_Method.invoke(m_Class, null));&lt;br /&gt;
&lt;br /&gt;
The result is the same as from the previous section of code.  We simply accessed the private getter rather than calling the instance variable directly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example 2=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
In the C# example we were not able to present any code for dynamically loading classes into the running program due to the complexity and length.  Java has made this process relatively simple and only requires a few lines of code.  Below is how we could dynamically load our previous class example from an outside source.&lt;br /&gt;
&lt;br /&gt;
public class test2Class {&lt;br /&gt;
  // Main Method of invokiing class&lt;br /&gt;
  public static void main(String[] args){&lt;br /&gt;
    // Instance of a classloader as part of this class&lt;br /&gt;
    ClassLoader m_Loader = test2Class.class.getClassLoader();&lt;br /&gt;
    // Try/Catch Block&lt;br /&gt;
    try {&lt;br /&gt;
        Class m_Class = m_Loader.loadClass(&amp;quot;com.myClassPackage.testClass&amp;quot;);&lt;br /&gt;
        System.out.println(&amp;quot;Successfully loaded class: &amp;quot; + m_Class.getName());&lt;br /&gt;
    } &lt;br /&gt;
    catch (ClassNotFoundException e) {&lt;br /&gt;
        System.err.println(e)    &lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The result from above is &amp;quot;testClass&amp;quot; as it loaded our example class from before.  From here we could now instantiate the class and call its functions (or search for what functions it has to offer).  This gives real insight to the flexibility of Java's Reflection API and how it could be practically used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Java Conclusions====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Java's Reflection API supplies a great deal of flexibility.  It allows the user almost complete access to classes  as well as the ability to dynamically load new classes and utilize their functions.  While some of the method calls aren't trivial majority of the coding is understandable and very useful once you understand what is going on.  Java also has the added advantage to access private functions and variables of a class instance which can allow easier unit testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in Ruby=&lt;br /&gt;
&lt;br /&gt;
The nature of Ruby as an object-oriented language gives great support for Reflection.  The big advantage to ruby is it gives us complete flexibility and control with reflection.  Most usages of reflection is only to obtain information and create new types dynamically but not modify current ones.  With Ruby's reflection api we have the ability to add or remove almost anything, whether that's a method, a class, or even class variables.  Please note that this flexibiliy can also lead to a programs downfall as with any reflection API.  Too much alteration of the source code can cause many unknown bugs.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The current support for reflection in ruby is built into the language and is accessable through certain fuctions within the standard Ruby API.  The methods most commonly used for reflection in Ruby along with some basic examples of their usage are shown below.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Kernel.html#M005922 eval] method is defined in the Kernel Module of Ruby and is used to evaluate literals encompased in strings.  This may not seem useful but the eval method also work in the scope of bindings which represent the scope of execution at a particular place in the code.  This allows programmers to view any variables in any scope for any instance.  An example of eval's usage is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
          def getBinding&lt;br /&gt;
               return binding()&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar is and evaluate it without an accessor method&lt;br /&gt;
     eval(&amp;quot;@myvar&amp;quot;, test1.getBinding)   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
I this example we can see that by acquiring the binding at some scope in the program we can use it to get inside the context of any object instance and determine the value of any instance variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Instance Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Object.html#M000334 instance_eval] method is defined in the Object class and works within the instance of any class.  This method performs much of the same operations as the eval method but works in the scope of an object without requiring the binding statement as above.  In fact we can accomplish the same example as above with the code shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar is and evaluate it without an accessor method&lt;br /&gt;
     test1.instance_eval { @myvar }   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
Again this code performs exactly the same thing as the prior example above.  The result is 17 which is the evaluation of the string literal as a command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Class Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.src/M001650.html class_eval] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object whether that is assigning or accessing variables, declaring instance methods, or even re-defining inherited methods.  The method takes actions either via string literal or a block of code.  This method is one of the strongest and most versatile methods in the Ruby Reflection API since it can access any private methods of any objects and its parents, this giving you full control over control.&lt;br /&gt;
&lt;br /&gt;
=====Example 1=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar by creating an accessor method for this instance.&lt;br /&gt;
     test1.class_eval{ def getVar; @myvar; end }&lt;br /&gt;
     eval(test1.getVar)   #=&amp;gt;  17&lt;br /&gt;
     #Or by simply accessing the local variable as below.&lt;br /&gt;
     eval(test1.class_eval{@myvar})    #=&amp;gt; 17&lt;br /&gt;
&lt;br /&gt;
This example shows the versatility of the class_eval method to work on any class instance.  It performs many of the operations that the previous methods have performed but with the added advantage of assigning instance methods.&lt;br /&gt;
&lt;br /&gt;
=====Example 2=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
       private:&lt;br /&gt;
          def increment&lt;br /&gt;
               @myvar += 1&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     #We can directly use class_eval to call private methods within a class as well.&lt;br /&gt;
     test1.class_eval{ increment() }   #=&amp;gt; 18&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval has even more flexibility to call private functions of a class from outside of the class scope. &lt;br /&gt;
&lt;br /&gt;
=====Example 3=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     # We can directly use class_eval to add variables to the instance of the class&lt;br /&gt;
     test1.class_eval{ instance_variable_set :@myvar2 , 25 }   &lt;br /&gt;
     test1.class_eval{ @myvar2 } #=&amp;gt; 25&lt;br /&gt;
     # Or We can remove variables from an instance of the class&lt;br /&gt;
     test1.class_eval{ remove_instance_variable :@myvar2 }&lt;br /&gt;
     test1.class_eval{ @myvar2 } #=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval is capable of defining and removing instance variables from the instance of a class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Define Method Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.html#M001654 define_method] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object to declare methods directly.  This method can be accomplished by using the class_eval method but is also a bit more flexible in it's notation.  An example of the use of this function is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;This is my String!&amp;quot;)&lt;br /&gt;
     #We can use define_method to create a instance method for this class with multiple parameters.&lt;br /&gt;
     test1.class_eval{ define_method(:getSubString){|start, end| @secret[start,end]} }&lt;br /&gt;
     test1.getSubString(5,9)   #=&amp;gt; &amp;quot;is my&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This example shows how to use define_method to create an instance method with multiple parameters by the common block notation.  Please not that we did have to use class_eval still to access the define_method.  This was due to the fact that define_method is a private method within the Module class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Ruby Conclusions====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The ruby language provides great support for reflection due to the nature of its design.  By using the class_eval method by itself one could completely encompass majority of the required reflection programming.  The other functions do provide some other basic support not specifically granted to the class_eval function. Specifically the eval function in combination with bindings.  The use of bindings allow the program to save the context of scope at some particular moment in the program and access it later.  With these functions ruby makes reflection simple.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusions=&lt;br /&gt;
&lt;br /&gt;
All of the Reflection API's had one thing in common.  The ability to analyse classes and determine information about them from the avaliable metadata.  C#'s API allows the usage of dynamically loaded classes but does not seem as trivial to use as the other APIs.  Java has take it a step further and allows instance variables to be monitored during execution as well as the ability to call classes' private functions as needed.  Java has proven to be a very flexible reflection API.&lt;br /&gt;
&lt;br /&gt;
The most flexible Reflection API by far is Ruby's.  The nature of Ruby's language allows it to dynamically create and destroy classes as well as variables and methods within the class.  No other language that we've seen will allow you to add or remove functionality of a class as needed during execution.  This allows Ruby programmers to invent new and insteresting uses for this flexibility when designing their code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
[1] [http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection Wikipedia]&lt;br /&gt;
&lt;br /&gt;
[2] [http://www.codersource.net/published/view/291/reflection_in.aspx Reflection in C# - CoderSource.net]&lt;br /&gt;
&lt;br /&gt;
[3] [http://msdn.microsoft.com/en-us/library/f7ykdhsy.aspx MSDN Visual C# - Reflection Programmers Guide]&lt;br /&gt;
&lt;br /&gt;
[4] [http://www.khelll.com/blog/ruby/ruby-reflection/ Ruby Reflection]&lt;br /&gt;
&lt;br /&gt;
[5] [http://practicalruby.blogspot.com/2007/02/ruby-metaprogramming-introduction.html A Ruby Metaprogramming Introduction]&lt;br /&gt;
&lt;br /&gt;
[6] [http://books.google.com/books?id=jcUbTcr5XWwC&amp;amp;lpg=PA266&amp;amp;ots=fHFlsa2wgC&amp;amp;dq=Ruby%20Reflection%20API&amp;amp;pg=PA265#v=onepage&amp;amp;q=Ruby%20Reflection%20API&amp;amp;f=false Ruby Programmging Language - Reflection and Metaprogramming]&lt;br /&gt;
&lt;br /&gt;
[7] [http://tutorials.jenkov.com/java-reflection/index.html Java Reflection Tutorial]&lt;br /&gt;
&lt;br /&gt;
[8] [http://java.sun.com/docs/books/tutorial/reflect/ Java Reflection API]&lt;br /&gt;
&lt;br /&gt;
[9] [http://java.sun.com/j2se/1.4.2/docs/api/java/lang/reflect/package-summary.html Java Reflection API Listing]&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=24167</id>
		<title>CSC/ECE 517 Fall 2009/wiki2 5 jn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=24167"/>
		<updated>2009-10-09T18:16:10Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Reflection APIs (TOC)=&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
====What is Reflection?====&lt;br /&gt;
[http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection] in programming is a technique in which programs are able to dynamically view and alter their own structure and flow.  For example, in reflection one could determine method/variable/class names, add or delete method/variables, alter code to current methods, or simply alter values in variables.  Reflection is a subset of [http://en.wikipedia.org/wiki/Metaprogramming MetaProgramming] which relies heavily on the use of meta-information.  Meta-Information is used to keep track of the program structure such as names of available methods,variables and classes but also is what really makes reflection possible.  In theory there are nearly no bounds to reflection as it directly modifies the binary of the program.  The current limitations of this process are related to the APIs avaliable for specific languages.  Majority of object-oriented languages have the functionality built in and some like C++ require external libraries to achieve even the basic functionality of Reflection.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===What languages are Supported?===&lt;br /&gt;
Due to the complexity required to support this majority of the languages that support this feature tend to be object oriented.  Some examples of supported languages are [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/JavaScript JavaScript], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], and [http://en.wikipedia.org/wiki/ActionScript ActionScript].  In this page we will cover a select few of the languages above and what native API support is avaliable for each of the languages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Terminology=&lt;br /&gt;
&lt;br /&gt;
*Reflection&lt;br /&gt;
*MetaProgramming&lt;br /&gt;
*MetaData&lt;br /&gt;
*Binding&lt;br /&gt;
*Instance&lt;br /&gt;
*Scope&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in C#=&lt;br /&gt;
&lt;br /&gt;
Reflection in C# is included in the .NET framework provided by microsoft.  The methods and classes usable for reflection are access directly from the System.Reflection namespace and support any class type avaliable under the .NET framework.  The basis of reflection in C# is powered by the Type class which is the way metadata is accessed.  This type object gives information about all avaliable methods, variables, constructors, and more from a given class.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reflection in C# is not as dynamic as most other languages in the fact that it doesn't easily support the alteration of class variables, methods, and attributes.  As shown above the reflection implementation in C# is more for data collection and anaysis for object types.  One of the best applications for Reflection in C# is the flexibility to dyniamically load assembly code at runtime, ascertain information about the methods, variables and constructors, and then invoke code from the assembly directly.  This type of usage makes examples especially hard to include in a short diescription as this.  For this reason the examples have been simplified and is displayed below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
 public class Counter&lt;br /&gt;
 {&lt;br /&gt;
      // Private Variable&lt;br /&gt;
      private int ctr;&lt;br /&gt;
      // Constructor&lt;br /&gt;
      public Counter(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           ctr = temp;&lt;br /&gt;
      }&lt;br /&gt;
      // Increment&lt;br /&gt;
      public int Inc(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           return ctr+=temp;&lt;br /&gt;
      }&lt;br /&gt;
      // Decrement&lt;br /&gt;
      public int Dec(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           return ctr-=temp;&lt;br /&gt;
      }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Suppose we have the basic class as listed above.  There is only one constructor, one private instance variable, and two functions which increment or decrement the instance variable by a certain amount.  We could easily begin obtaining information about this class by performing the code below.&lt;br /&gt;
&lt;br /&gt;
 Counter myCtr = new Counter(1000);&lt;br /&gt;
 Type tempType = myCtr.GetType();&lt;br /&gt;
&lt;br /&gt;
From the instance of myCtr we were able to use the GetType method to instantiate and parse meta-information about the Counter class.  Keep in mind that this class could have been invoked at compile time and that we may have no previous information about it.  We could then dynamically determine what constructors and methods were avaliable by performing the following actions.&lt;br /&gt;
&lt;br /&gt;
 ConstructorInfo [] c_info = tempType.GetConstructors();&lt;br /&gt;
 MethodInfo [] m_info = tempType.GetMethods();&lt;br /&gt;
&lt;br /&gt;
From these two lines of code we now have an array of infmoration for both the avaliable methods and the avaliable constructors.  We can use the information in these two types to dynamically incoroporate the class into the system at runtime.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Conclusion=====&lt;br /&gt;
----&lt;br /&gt;
The included reflection API in the C# language creates a way for programmers to dynamically retrieve information from external assembly code.  They can then proceed to use that information to access the types avaliable from the assembly.  While this is a difficult concept to grasp it does have its usages.  In the System.Reflection.Emit namespace there is a way to dynamically create types.  This form of reflection is typically used by script engines and compilers as they import external types to be used in the current binaries.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in Java=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in Ruby=&lt;br /&gt;
&lt;br /&gt;
The nature of Ruby as an object-oriented language gives great support for Reflection.  The big advantage to ruby is it gives us complete flexibility and control with reflection.  Most usages of reflection is only to obtain information and create new types dynamically but not modify current ones.  With Ruby's reflection api we have the ability to add or remove almost anything, whether that's a method, a class, or even class variables.  Please note that this flexibiliy can also lead to a programs downfall as with any reflection API.  Too much alteration of the source code can cause many unknown bugs.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The current support for reflection in ruby is built into the language and is accessable through certain fuctions within the standard Ruby API.  The methods most commonly used for reflection in Ruby along with some basic examples of their usage are shown below.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Kernel.html#M005922 eval] method is defined in the Kernel Module of Ruby and is used to evaluate literals encompased in strings.  This may not seem useful but the eval method also work in the scope of bindings which represent the scope of execution at a particular place in the code.  This allows programmers to view any variables in any scope for any instance.  An example of eval's usage is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
          def getBinding&lt;br /&gt;
               return binding()&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar is and evaluate it without an accessor method&lt;br /&gt;
     eval(&amp;quot;@myvar&amp;quot;, test1.getBinding)   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
I this example we can see that by acquiring the binding at some scope in the program we can use it to get inside the context of any object instance and determine the value of any instance variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Instance Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Object.html#M000334 instance_eval] method is defined in the Object class and works within the instance of any class.  This method performs much of the same operations as the eval method but works in the scope of an object without requiring the binding statement as above.  In fact we can accomplish the same example as above with the code shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar is and evaluate it without an accessor method&lt;br /&gt;
     test1.instance_eval { @myvar }   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
Again this code performs exactly the same thing as the prior example above.  The result is 17 which is the evaluation of the string literal as a command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Class Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.src/M001650.html class_eval] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object whether that is assigning or accessing variables, declaring instance methods, or even re-defining inherited methods.  The method takes actions either via string literal or a block of code.  This method is one of the strongest and most versatile methods in the Ruby Reflection API since it can access any private methods of any objects and its parents, this giving you full control over control.&lt;br /&gt;
&lt;br /&gt;
=====Example 1=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar by creating an accessor method for this instance.&lt;br /&gt;
     test1.class_eval{ def getVar; @myvar; end }&lt;br /&gt;
     eval(test1.getVar)   #=&amp;gt;  17&lt;br /&gt;
     #Or by simply accessing the local variable as below.&lt;br /&gt;
     eval(test1.class_eval{@myvar})    #=&amp;gt; 17&lt;br /&gt;
&lt;br /&gt;
This example shows the versatility of the class_eval method to work on any class instance.  It performs many of the operations that the previous methods have performed but with the added advantage of assigning instance methods.&lt;br /&gt;
&lt;br /&gt;
=====Example 2=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
       private:&lt;br /&gt;
          def increment&lt;br /&gt;
               @myvar += 1&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     #We can directly use class_eval to call private methods within a class as well.&lt;br /&gt;
     test1.class_eval{ increment() }   #=&amp;gt; 18&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval has even more flexibility to call private functions of a class from outside of the class scope. &lt;br /&gt;
&lt;br /&gt;
=====Example 3=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     # We can directly use class_eval to add variables to the instance of the class&lt;br /&gt;
     test1.class_eval{ instance_variable_set :@myvar2 , 25 }   &lt;br /&gt;
     test1.class_eval{ @myvar2 } #=&amp;gt; 25&lt;br /&gt;
     # Or We can remove variables from an instance of the class&lt;br /&gt;
     test1.class_eval{ remove_instance_variable :@myvar2 }&lt;br /&gt;
     test1.class_eval{ @myvar2 } #=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval is capable of defining and removing instance variables from the instance of a class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Define Method Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.html#M001654 define_method] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object to declare methods directly.  This method can be accomplished by using the class_eval method but is also a bit more flexible in it's notation.  An example of the use of this function is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;This is my String!&amp;quot;)&lt;br /&gt;
     #We can use define_method to create a instance method for this class with multiple parameters.&lt;br /&gt;
     test1.class_eval{ define_method(:getSubString){|start, end| @secret[start,end]} }&lt;br /&gt;
     test1.getSubString(5,9)   #=&amp;gt; &amp;quot;is my&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This example shows how to use define_method to create an instance method with multiple parameters by the common block notation.  Please not that we did have to use class_eval still to access the define_method.  This was due to the fact that define_method is a private method within the Module class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Conclusion====&lt;br /&gt;
----&lt;br /&gt;
The ruby language provides great support for reflection due to the nature of its design.  By using the class_eval method by itself one could completely encompass majority of the required reflection programming.  The other functions do provide some other basic support not specifically granted to the class_eval function. Specifically the eval function in combination with bindings.  The use of bindings allow the program to save the context of scope at some particular moment in the program and access it later.  With these functions ruby makes reflection simple.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
=Reflection in PHP=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Reflection in PERL=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusions=&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
[1] [http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection Wikipedia]&lt;br /&gt;
&lt;br /&gt;
[2] [http://www.codersource.net/published/view/291/reflection_in.aspx Reflection in C# - CoderSource.net]&lt;br /&gt;
&lt;br /&gt;
[3] [http://msdn.microsoft.com/en-us/library/f7ykdhsy.aspx MSDN Visual C# - Reflection Programmers Guide]&lt;br /&gt;
&lt;br /&gt;
[4] [http://www.khelll.com/blog/ruby/ruby-reflection/ Ruby Reflection]&lt;br /&gt;
&lt;br /&gt;
[5] [http://practicalruby.blogspot.com/2007/02/ruby-metaprogramming-introduction.html A Ruby Metaprogramming Introduction]&lt;br /&gt;
&lt;br /&gt;
[6] [http://books.google.com/books?id=jcUbTcr5XWwC&amp;amp;lpg=PA266&amp;amp;ots=fHFlsa2wgC&amp;amp;dq=Ruby%20Reflection%20API&amp;amp;pg=PA265#v=onepage&amp;amp;q=Ruby%20Reflection%20API&amp;amp;f=false Ruby Programmging Language - Reflection and Metaprogramming]&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=24157</id>
		<title>CSC/ECE 517 Fall 2009/wiki2 5 jn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=24157"/>
		<updated>2009-10-09T18:09:52Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Reflection APIs (TOC)=&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
====What is Reflection?====&lt;br /&gt;
[http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection] in programming is a technique in which programs are able to dynamically view and alter their own structure and flow.  For example, in reflection one could determine method/variable/class names, add or delete method/variables, alter code to current methods, or simply alter values in variables.  Reflection is a subset of [http://en.wikipedia.org/wiki/Metaprogramming MetaProgramming] which relies heavily on the use of meta-information.  Meta-Information is used to keep track of the program structure such as names of available methods,variables and classes but also is what really makes reflection possible.  In theory there are nearly no bounds to reflection as it directly modifies the binary of the program.  The current limitations of this process are related to the APIs avaliable for specific languages.  Majority of object-oriented languages have the functionality built in and some like C++ require external libraries to achieve even the basic functionality of Reflection.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===What languages are Supported?===&lt;br /&gt;
Due to the complexity required to support this majority of the languages that support this feature tend to be object oriented.  Some examples of supported languages are [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/JavaScript JavaScript], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], and [http://en.wikipedia.org/wiki/ActionScript ActionScript].  In this page we will cover a select few of the languages above and what native API support is avaliable for each of the languages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Terminology=&lt;br /&gt;
&lt;br /&gt;
*Reflection&lt;br /&gt;
*MetaProgramming&lt;br /&gt;
*MetaData&lt;br /&gt;
*Binding&lt;br /&gt;
*Instance&lt;br /&gt;
*Scope&lt;br /&gt;
&lt;br /&gt;
=Available Reflection APIs=&lt;br /&gt;
&lt;br /&gt;
==Reflection in C#==&lt;br /&gt;
&lt;br /&gt;
Reflection in C# is included in the .NET framework provided by microsoft.  The methods and classes usable for reflection are access directly from the System.Reflection namespace and support any class type avaliable under the .NET framework.  The basis of reflection in C# is powered by the Type class which is the way metadata is accessed.  This type object gives information about all avaliable methods, variables, constructors, and more from a given class.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reflection in C# is not as dynamic as most other languages in the fact that it doesn't easily support the alteration of class variables, methods, and attributes.  As shown above the reflection implementation in C# is more for data collection and anaysis for object types.  One of the best applications for Reflection in C# is the flexibility to dyniamically load assembly code at runtime, ascertain information about the methods, variables and constructors, and then invoke code from the assembly directly.  This type of usage makes examples especially hard to include in a short diescription as this.  For this reason the examples have been simplified and is displayed below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
 public class Counter&lt;br /&gt;
 {&lt;br /&gt;
      // Private Variable&lt;br /&gt;
      private int ctr;&lt;br /&gt;
      // Constructor&lt;br /&gt;
      public Counter(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           ctr = temp;&lt;br /&gt;
      }&lt;br /&gt;
      // Increment&lt;br /&gt;
      public int Inc(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           return ctr+=temp;&lt;br /&gt;
      }&lt;br /&gt;
      // Decrement&lt;br /&gt;
      public int Dec(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           return ctr-=temp;&lt;br /&gt;
      }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Suppose we have the basic class as listed above.  There is only one constructor, one private instance variable, and two functions which increment or decrement the instance variable by a certain amount.  We could easily begin obtaining information about this class by performing the code below.&lt;br /&gt;
&lt;br /&gt;
 Counter myCtr = new Counter(1000);&lt;br /&gt;
 Type tempType = myCtr.GetType();&lt;br /&gt;
&lt;br /&gt;
From the instance of myCtr we were able to use the GetType method to instantiate and parse meta-information about the Counter class.  Keep in mind that this class could have been invoked at compile time and that we may have no previous information about it.  We could then dynamically determine what constructors and methods were avaliable by performing the following actions.&lt;br /&gt;
&lt;br /&gt;
 ConstructorInfo [] c_info = tempType.GetConstructors();&lt;br /&gt;
 MethodInfo [] m_info = tempType.GetMethods();&lt;br /&gt;
&lt;br /&gt;
From these two lines of code we now have an array of infmoration for both the avaliable methods and the avaliable constructors.  We can use the information in these two types to dynamically incoroporate the class into the system at runtime.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Conclusion=====&lt;br /&gt;
----&lt;br /&gt;
The included reflection API in the C# language creates a way for programmers to dynamically retrieve information from external assembly code.  They can then proceed to use that information to access the types avaliable from the assembly.  While this is a difficult concept to grasp it does have its usages.  In the System.Reflection.Emit namespace there is a way to dynamically create types.  This form of reflection is typically used by script engines and compilers as they import external types to be used in the current binaries.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Reflection in Java==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Reflection in Ruby==&lt;br /&gt;
&lt;br /&gt;
The nature of Ruby as an object-oriented language gives great support for Reflection.  The big advantage to ruby is it gives us complete flexibility and control with reflection.  Most usages of reflection is only to obtain information and create new types dynamically but not modify current ones.  With Ruby's reflection api we have the ability to add or remove almost anything, whether that's a method, a class, or even class variables.  Please note that this flexibiliy can also lead to a programs downfall as with any reflection API.  Too much alteration of the source code can cause many unknown bugs.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The current support for reflection in ruby is built into the language and is accessable through certain fuctions within the standard Ruby API.  The methods most commonly used for reflection in Ruby along with some basic examples of their usage are shown below.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Kernel.html#M005922 eval] method is defined in the Kernel Module of Ruby and is used to evaluate literals encompased in strings.  This may not seem useful but the eval method also work in the scope of bindings which represent the scope of execution at a particular place in the code.  This allows programmers to view any variables in any scope for any instance.  An example of eval's usage is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
          def getBinding&lt;br /&gt;
               return binding()&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar is and evaluate it without an accessor method&lt;br /&gt;
     eval(&amp;quot;@myvar&amp;quot;, test1.getBinding)   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
I this example we can see that by acquiring the binding at some scope in the program we can use it to get inside the context of any object instance and determine the value of any instance variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Instance Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Object.html#M000334 instance_eval] method is defined in the Object class and works within the instance of any class.  This method performs much of the same operations as the eval method but works in the scope of an object without requiring the binding statement as above.  In fact we can accomplish the same example as above with the code shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar is and evaluate it without an accessor method&lt;br /&gt;
     test1.instance_eval { @myvar }   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
Again this code performs exactly the same thing as the prior example above.  The result is 17 which is the evaluation of the string literal as a command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Class Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.src/M001650.html class_eval] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object whether that is assigning or accessing variables, declaring instance methods, or even re-defining inherited methods.  The method takes actions either via string literal or a block of code.  This method is one of the strongest and most versatile methods in the Ruby Reflection API since it can access any private methods of any objects and its parents, this giving you full control over control.&lt;br /&gt;
&lt;br /&gt;
=====Example 1=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of myvar by creating an accessor method for this instance.&lt;br /&gt;
     test1.class_eval{ def getVar; @myvar; end }&lt;br /&gt;
     eval(test1.getVar)   #=&amp;gt;  17&lt;br /&gt;
     #Or by simply accessing the local variable as below.&lt;br /&gt;
     eval(test1.class_eval{@myvar})    #=&amp;gt; 17&lt;br /&gt;
&lt;br /&gt;
This example shows the versatility of the class_eval method to work on any class instance.  It performs many of the operations that the previous methods have performed but with the added advantage of assigning instance methods.&lt;br /&gt;
&lt;br /&gt;
=====Example 2=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
       private:&lt;br /&gt;
          def increment&lt;br /&gt;
               @myvar += 1&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     #We can directly use class_eval to call private methods within a class as well.&lt;br /&gt;
     test1.class_eval{ increment() }   #=&amp;gt; 18&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval has even more flexibility to call private functions of a class from outside of the class scope. &lt;br /&gt;
&lt;br /&gt;
=====Example 3=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @myvar = var&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     # We can directly use class_eval to add variables to the instance of the class&lt;br /&gt;
     test1.class_eval{ instance_variable_set :@myvar2 , 25 }   &lt;br /&gt;
     test1.class_eval{ @myvar2 } #=&amp;gt; 25&lt;br /&gt;
     # Or We can remove variables from an instance of the class&lt;br /&gt;
     test1.class_eval{ remove_instance_variable :@myvar2 }&lt;br /&gt;
     test1.class_eval{ @myvar2 } #=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval is capable of defining and removing instance variables from the instance of a class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Define Method Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.html#M001654 define_method] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object to declare methods directly.  This method can be accomplished by using the class_eval method but is also a bit more flexible in it's notation.  An example of the use of this function is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;This is my String!&amp;quot;)&lt;br /&gt;
     #We can use define_method to create a instance method for this class with multiple parameters.&lt;br /&gt;
     test1.class_eval{ define_method(:getSubString){|start, end| @secret[start,end]} }&lt;br /&gt;
     test1.getSubString(5,9)   #=&amp;gt; &amp;quot;is my&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This example shows how to use define_method to create an instance method with multiple parameters by the common block notation.  Please not that we did have to use class_eval still to access the define_method.  This was due to the fact that define_method is a private method within the Module class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Conclusion====&lt;br /&gt;
----&lt;br /&gt;
The ruby language provides great support for reflection due to the nature of its design.  By using the class_eval method by itself one could completely encompass majority of the required reflection programming.  The other functions do provide some other basic support not specifically granted to the class_eval function. Specifically the eval function in combination with bindings.  The use of bindings allow the program to save the context of scope at some particular moment in the program and access it later.  With these functions ruby makes reflection simple.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
==Reflection in PHP==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Reflection in PERL==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusions=&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
[1] [http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection Wikipedia]&lt;br /&gt;
&lt;br /&gt;
[2] [http://www.codersource.net/published/view/291/reflection_in.aspx Reflection in C# - CoderSource.net]&lt;br /&gt;
&lt;br /&gt;
[3] [http://msdn.microsoft.com/en-us/library/f7ykdhsy.aspx MSDN Visual C# - Reflection Programmers Guide]&lt;br /&gt;
&lt;br /&gt;
[4] [http://www.khelll.com/blog/ruby/ruby-reflection/ Ruby Reflection]&lt;br /&gt;
&lt;br /&gt;
[5] [http://practicalruby.blogspot.com/2007/02/ruby-metaprogramming-introduction.html A Ruby Metaprogramming Introduction]&lt;br /&gt;
&lt;br /&gt;
[6] [http://books.google.com/books?id=jcUbTcr5XWwC&amp;amp;lpg=PA266&amp;amp;ots=fHFlsa2wgC&amp;amp;dq=Ruby%20Reflection%20API&amp;amp;pg=PA265#v=onepage&amp;amp;q=Ruby%20Reflection%20API&amp;amp;f=false Ruby Programmging Language - Reflection and Metaprogramming]&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=24113</id>
		<title>CSC/ECE 517 Fall 2009/wiki2 5 jn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=24113"/>
		<updated>2009-10-09T17:39:14Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Reflection APIs (TOC)=&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
====What is Reflection?====&lt;br /&gt;
[http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection] in programming is a technique in which programs are able to dynamically view and alter their own structure and flow.  For example, in reflection one could determine method/variable/class names, add or delete method/variables, alter code to current methods, or simply alter values in variables.  Reflection is a subset of [http://en.wikipedia.org/wiki/Metaprogramming MetaProgramming] which relies heavily on the use of meta-information.  Meta-Information is used to keep track of the program structure such as names of available methods,variables and classes but also is what really makes reflection possible.  In theory there are nearly no bounds to reflection as it directly modifies the binary of the program.  The current limitations of this process are related to the APIs avaliable for specific languages.  Majority of object-oriented languages have the functionality built in and some like C++ require external libraries to achieve even the basic functionality of Reflection.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===What languages are Supported?===&lt;br /&gt;
Due to the complexity required to support this majority of the languages that support this feature tend to be object oriented.  Some examples of supported languages are [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/JavaScript JavaScript], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], and [http://en.wikipedia.org/wiki/ActionScript ActionScript].  In this page we will cover a select few of the languages above and what native API support is avaliable for each of the languages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Terminology=&lt;br /&gt;
&lt;br /&gt;
*Reflection&lt;br /&gt;
*MetaProgramming&lt;br /&gt;
*MetaData&lt;br /&gt;
*Binding&lt;br /&gt;
*Instance&lt;br /&gt;
*Scope&lt;br /&gt;
&lt;br /&gt;
=Available Reflection APIs=&lt;br /&gt;
&lt;br /&gt;
==Reflection in C#==&lt;br /&gt;
&lt;br /&gt;
Reflection in C# is included in the .NET framework provided by microsoft.  The methods and classes usable for reflection are access directly from the System.Reflection namespace and support any class type avaliable under the .NET framework.  The basis of reflection in C# is powered by the Type class which is the way metadata is accessed.  This type object gives information about all avaliable methods, variables, constructors, and more from a given class.  &lt;br /&gt;
&lt;br /&gt;
Reflection in C# is not as dynamic as most other languages in the fact that it doesn't easily support the alteration of class variables, methods, and attributes.  As shown above the reflection implementation in C# is more for data collection and anaysis for object types.  One of the best applications for Reflection in C# is the flexibility to dyniamically load assembly code at runtime, ascertain information about the methods, variables and constructors, and then invoke code from the assembly directly.  This type of usage makes examples especially hard to include in a short diescription as this.  For this reason the examples have been simplified and is displayed below.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
=====Example=====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
 public class Counter&lt;br /&gt;
 {&lt;br /&gt;
      // Private Variable&lt;br /&gt;
      private int ctr;&lt;br /&gt;
      // Constructor&lt;br /&gt;
      public Counter(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           ctr = temp;&lt;br /&gt;
      }&lt;br /&gt;
      // Increment&lt;br /&gt;
      public int Inc(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           return ctr+=temp;&lt;br /&gt;
      }&lt;br /&gt;
      // Decrement&lt;br /&gt;
      public int Dec(int temp)&lt;br /&gt;
      {&lt;br /&gt;
           return ctr-=temp;&lt;br /&gt;
      }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Suppose we have the basic class as listed above.  There is only one constructor, one private instance variable, and two functions which increment or decrement the instance variable by a certain amount.  We could easily begin obtaining information about this class by performing the code below.&lt;br /&gt;
&lt;br /&gt;
 Counter myCtr = new Counter(1000);&lt;br /&gt;
 Type tempType = myCtr.GetType();&lt;br /&gt;
&lt;br /&gt;
From the instance of myCtr we were able to use the GetType method to instantiate and parse meta-information about the Counter class.  Keep in mind that this class could have been invoked at compile time and that we may have no previous information about it.  We could then dynamically determine what constructors and methods were avaliable by performing the following actions.&lt;br /&gt;
&lt;br /&gt;
 ConstructorInfo [] c_info = tempType.GetConstructors();&lt;br /&gt;
 MethodInfo [] m_info = tempType.GetMethods();&lt;br /&gt;
&lt;br /&gt;
From these two lines of code we now have an array of infmoration for both the avaliable methods and the avaliable constructors.  We can use the information in these two types to dynamically incoroporate the class into the system at runtime.  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Conclusion====&lt;br /&gt;
----&lt;br /&gt;
The included reflection API in the C# language creates a way for programmers to dynamically retrieve information from external assembly code.  They can then proceed to use that information to access the types avaliable from the assembly.  While this is a difficult concept to grasp it does have its usages.  In the System.Reflection.Emit namespace there is a way to dynamically create types.  This form of reflection is typically used by script engines and compilers as they import external types to be used in the current binaries.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Reflection in Java==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Reflection in Ruby==&lt;br /&gt;
&lt;br /&gt;
The nature of Ruby as an object-oriented language gives great support for Reflection.  The big advantage to ruby is it gives us complete flexibility and control with reflection.  Most usages of reflection is only to obtain information and create new types dynamically but not modify current ones.  With Ruby's reflection api we have the ability to add or remove almost anything, whether that's a method, a class, or even class variables.  Please note that this flexibiliy can also lead to a programs downfall as with any reflection API.  Too much alteration of the source code can cause many unknown bugs.  &lt;br /&gt;
&lt;br /&gt;
The current support for reflection in ruby is built into the language and is accessable through certain fuctions within the standard Ruby API.  The methods most commonly used for reflection in Ruby along with some basic examples of their usage are shown below.  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Kernel.html#M005922 eval] method is defined in the Kernel Module of Ruby and is used to evaluate literals encompased in strings.  This may not seem useful but the eval method also work in the scope of bindings which represent the scope of execution at a particular place in the code.  This allows programmers to view any variables in any scope for any instance.  An example of eval's usage is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
          def getBinding&lt;br /&gt;
               return binding()&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of secret is and evaluate it without an accessor method&lt;br /&gt;
     eval(&amp;quot;@secret&amp;quot;, test1.getBinding)   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
I this example we can see that by acquiring the binding at some scope in the program we can use it to get inside the context of any object instance and determine the value of any instance variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Instance Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Object.html#M000334 instance_eval] method is defined in the Object class and works within the instance of any class.  This method performs much of the same operations as the eval method but works in the scope of an object without requiring the binding statement as above.  In fact we can accomplish the same example as above with the code shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of secret is and evaluate it without an accessor method&lt;br /&gt;
     test1.instance_eval { @secret }   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
Again this code performs exactly the same thing as the prior example above.  The result is 17 which is the evaluation of the string literal as a command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Class Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.src/M001650.html class_eval] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object whether that is assigning or accessing variables, declaring instance methods, or even re-defining inherited methods.  The method takes actions either via string literal or a block of code.  This method is one of the strongest and most versatile methods in the Ruby Reflection API since it can access any private methods of any objects and its parents, this giving you full control over control.&lt;br /&gt;
&lt;br /&gt;
=====Example 1=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of secret by creating an accessor method for this instance.&lt;br /&gt;
     test1.class_eval{ def getSecret; @secret; end }&lt;br /&gt;
     eval(test1.getSecret)   #=&amp;gt;  17&lt;br /&gt;
     #Or by simply accessing the local variable as below.&lt;br /&gt;
     eval(test1.class_eval{@secret})    #=&amp;gt; 17&lt;br /&gt;
&lt;br /&gt;
This example shows the versatility of the class_eval method to work on any class instance.  It performs many of the operations that the previous methods have performed but with the added advantage of assigning instance methods.&lt;br /&gt;
&lt;br /&gt;
=====Example 2=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
       private:&lt;br /&gt;
          def increment&lt;br /&gt;
               @secret += 1&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     #We can directly use class_eval to call private methods within a class as well.&lt;br /&gt;
     test1.class_eval{ increment() }   #=&amp;gt; 18&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval has even more flexibility to call private functions of a class from outside of the class scope. &lt;br /&gt;
&lt;br /&gt;
=====Example 3=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     # We can directly use class_eval to add variables to the instance of the class&lt;br /&gt;
     test1.class_eval{ instance_variable_set :@secret2 , 25 }   &lt;br /&gt;
     test1.class_eval{ @secret2 } #=&amp;gt; 25&lt;br /&gt;
     # Or We can remove variables from an instance of the class&lt;br /&gt;
     test1.class_eval{ remove_instance_variable :@secret2 }&lt;br /&gt;
     test1.class_eval{ @secret2 } #=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval is capable of defining and removing instance variables from the instance of a class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Define Method Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.html#M001654 define_method] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object to declare methods directly.  This method can be accomplished by using the class_eval method but is also a bit more flexible in it's notation.  An example of the use of this function is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;This is my String!&amp;quot;)&lt;br /&gt;
     #We can use define_method to create a instance method for this class with multiple parameters.&lt;br /&gt;
     test1.class_eval{ define_method(:getSubString){|start, end| @secret[start,end]} }&lt;br /&gt;
     test1.getSubString(5,9)   #=&amp;gt; &amp;quot;is my&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This example shows how to use define_method to create an instance method with multiple parameters by the common block notation.  Please not that we did have to use class_eval still to access the define_method.  This was due to the fact that define_method is a private method within the Module class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Conclusion====&lt;br /&gt;
----&lt;br /&gt;
The ruby language provides great support for reflection due to the nature of its design.  By using the class_eval method by itself one could completely encompass majority of the required reflection programming.  The other functions do provide some other basic support not specifically granted to the class_eval function. Specifically the eval function in combination with bindings.  The use of bindings allow the program to save the context of scope at some particular moment in the program and access it later.  With these functions ruby makes reflection simple.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
==Reflection in PHP==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Reflection in PERL==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Reflection in ActionScript==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusions=&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
[1] [http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection Wikipedia]&lt;br /&gt;
&lt;br /&gt;
[2] [http://www.codersource.net/published/view/291/reflection_in.aspx Reflection in C# - CoderSource.net]&lt;br /&gt;
&lt;br /&gt;
[3] [http://msdn.microsoft.com/en-us/library/f7ykdhsy.aspx MSDN Visual C# - Reflection Programmers Guide]&lt;br /&gt;
&lt;br /&gt;
[4]&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=24006</id>
		<title>CSC/ECE 517 Fall 2009/wiki2 5 jn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=24006"/>
		<updated>2009-10-09T16:35:10Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Reflection APIs (TOC)=&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
====What is Reflection?====&lt;br /&gt;
[http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection] in programming is a technique in which programs are able to dynamically view and alter their own structure and flow.  For example, in reflection one could determine method/variable/class names, add or delete method/variables, alter code to current methods, or simply alter values in variables.  Reflection is a subset of [http://en.wikipedia.org/wiki/Metaprogramming MetaProgramming] which relies heavily on the use of meta-information.  Meta-Information is used to keep track of the program structure such as names of available methods,variables and classes but also is what really makes reflection possible.  In theory there are nearly no bounds to reflection as it directly modifies the binary of the program.  The current limitations of this process are related to the APIs avaliable for specific languages.  Majority of object-oriented languages have the functionality built in and some like C++ require external libraries to achieve even the basic functionality of Reflection.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===What languages are Supported?===&lt;br /&gt;
Due to the complexity required to support this majority of the languages that support this feature tend to be object oriented.  Some examples of supported languages are [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/JavaScript JavaScript], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], and [http://en.wikipedia.org/wiki/ActionScript ActionScript].  In this page we will cover a select few of the languages above and what native API support is avaliable for each of the languages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Terminology=&lt;br /&gt;
&lt;br /&gt;
*Reflection&lt;br /&gt;
*MetaProgramming&lt;br /&gt;
*Binding&lt;br /&gt;
*Instance&lt;br /&gt;
*Scope&lt;br /&gt;
&lt;br /&gt;
=Available Reflection APIs=&lt;br /&gt;
&lt;br /&gt;
==Reflection in C#==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Reflection in Java==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Reflection in Ruby==&lt;br /&gt;
&lt;br /&gt;
The nature of Ruby as an object-oriented language gives great support for Reflection.  The current support for reflection in ruby is built into the language and is accessable through certain fuctions within the standard Ruby API.  The methods most commonly used for reflection in Ruby along with some basic examples of their usage are shown below.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Kernel.html#M005922 eval] method is defined in the Kernel Module of Ruby and is used to evaluate literals encompased in strings.  This may not seem useful but the eval method also work in the scope of bindings which represent the scope of execution at a particular place in the code.  This allows programmers to view any variables in any scope for any instance.  An example of eval's usage is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
          def getBinding&lt;br /&gt;
               return binding()&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of secret is and evaluate it without an accessor method&lt;br /&gt;
     eval(&amp;quot;@secret&amp;quot;, test1.getBinding)   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
I this example we can see that by acquiring the binding at some scope in the program we can use it to get inside the context of any object instance and determine the value of any instance variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Instance Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Object.html#M000334 instance_eval] method is defined in the Object class and works within the instance of any class.  This method performs much of the same operations as the eval method but works in the scope of an object without requiring the binding statement as above.  In fact we can accomplish the same example as above with the code shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of secret is and evaluate it without an accessor method&lt;br /&gt;
     test1.instance_eval { @secret }   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
Again this code performs exactly the same thing as the prior example above.  The result is 17 which is the evaluation of the string literal as a command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Class Eval Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.src/M001650.html class_eval] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object whether that is assigning or accessing variables, declaring instance methods, or even re-defining inherited methods.  The method takes actions either via string literal or a block of code.  This method is one of the strongest and most versatile methods in the Ruby Reflection API since it can access any private methods of any objects and its parents, this giving you full control over control.&lt;br /&gt;
&lt;br /&gt;
=====Example 1=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of secret by creating an accessor method for this instance.&lt;br /&gt;
     test1.class_eval{ def getSecret; @secret; end }&lt;br /&gt;
     eval(test1.getSecret)   #=&amp;gt;  17&lt;br /&gt;
     #Or by simply accessing the local variable as below.&lt;br /&gt;
     eval(test1.class_eval{@secret})    #=&amp;gt; 17&lt;br /&gt;
&lt;br /&gt;
This example shows the versatility of the class_eval method to work on any class instance.  It performs many of the operations that the previous methods have performed but with the added advantage of assigning instance methods.&lt;br /&gt;
&lt;br /&gt;
=====Example 2=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
       private:&lt;br /&gt;
          def increment&lt;br /&gt;
               @secret += 1&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     #We can directly use class_eval to call private methods within a class as well.&lt;br /&gt;
     test1.class_eval{ increment() }   #=&amp;gt; 18&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval has even more flexibility to call private functions of a class from outside of the class scope. &lt;br /&gt;
&lt;br /&gt;
=====Example 3=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     # We can directly use class_eval to add variables to the instance of the class&lt;br /&gt;
     test1.class_eval{ instance_variable_set :@secret2 , 25 }   &lt;br /&gt;
     test1.class_eval{ @secret2 } #=&amp;gt; 25&lt;br /&gt;
     # Or We can remove variables from an instance of the class&lt;br /&gt;
     test1.class_eval{ remove_instance_variable :@secret2 }&lt;br /&gt;
     test1.class_eval{ @secret2 } #=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval is capable of defining and removing instance variables from the instance of a class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Define Method Method====&lt;br /&gt;
----&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.html#M001654 define_method] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object to declare methods directly.  This method can be accomplished by using the class_eval method but is also a bit more flexible in it's notation.  An example of the use of this function is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;This is my String!&amp;quot;)&lt;br /&gt;
     #We can use define_method to create a instance method for this class with multiple parameters.&lt;br /&gt;
     test1.class_eval{ define_method(:getSubString){|start, end| @secret[start,end]} }&lt;br /&gt;
     test1.getSubString(5,9)   #=&amp;gt; &amp;quot;is my&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This example shows how to use define_method to create an instance method with multiple parameters by the common block notation.  Please not that we did have to use class_eval still to access the define_method.  This was due to the fact that define_method is a private method within the Module class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
====Conclusion====&lt;br /&gt;
----&lt;br /&gt;
The ruby language provides great support for reflection due to the nature of its design.  By using the class_eval method by itself one could completely encompass majority of the required reflection programming.  The other functions do provide some other basic support not specifically granted to the class_eval function. Specifically the eval function in combination with bindings.  The use of bindings allow the program to save the context of scope at some particular moment in the program and access it later.  With these functions ruby makes reflection simple.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
==Reflection in PHP==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Reflection in PERL==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Reflection in ActionScript==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusions=&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
[1] [http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection Wikipedia]&lt;br /&gt;
&lt;br /&gt;
[2] [http://www.codersource.net/published/view/291/reflection_in.aspx Reflection in C# - CoderSource.net]&lt;br /&gt;
&lt;br /&gt;
[3]&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=23968</id>
		<title>CSC/ECE 517 Fall 2009/wiki2 5 jn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=23968"/>
		<updated>2009-10-09T15:59:39Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Reflection APIs (TOC)=&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
====What is Reflection?====&lt;br /&gt;
[http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection] in programming is a technique in which programs are able to dynamically view and alter their own structure and flow.  For example, in reflection one could determine method/variable/class names, add or delete method/variables, alter code to current methods, or simply alter values in variables.  Reflection is a subset of [http://en.wikipedia.org/wiki/Metaprogramming MetaProgramming] which relies heavily on the use of meta-information.  Meta-Information is used to keep track of the program structure such as names of available methods,variables and classes but also is what really makes reflection possible.  In theory there are nearly no bounds to reflection as it directly modifies the binary of the program.  The current limitations of this process are related to the APIs avaliable for specific languages.  Majority of object-oriented languages have the functionality built in and some like C++ require external libraries to achieve even the basic functionality of Reflection.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===What languages are Supported?===&lt;br /&gt;
Due to the complexity required to support this majority of the languages that support this feature tend to be object oriented.  Some examples of supported languages are [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/JavaScript JavaScript], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], and [http://en.wikipedia.org/wiki/ActionScript ActionScript].  In this page we will cover a select few of the languages above and what native API support is avaliable for each of the languages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Terminology=&lt;br /&gt;
&lt;br /&gt;
*Reflection&lt;br /&gt;
*MetaProgramming&lt;br /&gt;
*Binding&lt;br /&gt;
&lt;br /&gt;
=Available Reflection APIs=&lt;br /&gt;
&lt;br /&gt;
===Reflection in C#===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===Reflection in Java===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===Reflection in Ruby===&lt;br /&gt;
----&lt;br /&gt;
The nature of Ruby as an object-oriented language gives great support for Reflection.  The current support for reflection in ruby is built into the language and is accessable through certain fuctions within the standard Ruby API.  The methods most commonly used for reflection in Ruby along with some basic examples of their usage are shown below.&lt;br /&gt;
&lt;br /&gt;
====Eval Method====&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Kernel.html#M005922 eval] method is defined in the Kernel Module of Ruby and is used to evaluate literals encompased in strings.  This may not seem useful but the eval method also work in the scope of bindings which represent the scope of execution at a particular place in the code.  This allows programmers to view any variables in any scope for any instance.  An example of eval's usage is shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
          def getBinding&lt;br /&gt;
               return binding()&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of secret is and evaluate it without an accessor method&lt;br /&gt;
     eval(&amp;quot;@secret&amp;quot;, test1.getBinding)   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
I this example we can see that by acquiring the binding at some scope in the program we can use it to get inside the context of any object instance and determine the value of any instance variables.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Instance Eval Method====&lt;br /&gt;
&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Object.html#M000334 instance_eval] method is defined in the Object class and works within the instance of any class.  This method performs much of the same operations as the eval method but works in the scope of an object without requiring the binding statement as above.  In fact we can accomplish the same example as above with the code shown below.&lt;br /&gt;
&lt;br /&gt;
=====Example=====&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of secret is and evaluate it without an accessor method&lt;br /&gt;
     test1.instance_eval { @secret }   #=&amp;gt;  17&lt;br /&gt;
&lt;br /&gt;
Again this code performs exactly the same thing as the prior example above.  The result is 17 which is the evaluation of the string literal as a command.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Class Eval Method====&lt;br /&gt;
&lt;br /&gt;
The [http://ruby-doc.org/core/classes/Module.src/M001650.html class_eval] method is defined in the Module class and works within the instance of any class.  This method can be used to work within the context of any object whether that is assigning or accessing variables, declaring instance methods, or even re-defining inherited methods.  The method takes actions either via string literal or a block of code.  An example of adding accesor methods to the previous Test class is shown in example 1.&lt;br /&gt;
&lt;br /&gt;
=====Example 1=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(&amp;quot;12+5&amp;quot;)&lt;br /&gt;
     #We can determine what test1's instance of secret by creating an accessor method for this instance.&lt;br /&gt;
     test1.class_eval{ def getSecret; @secret; end }&lt;br /&gt;
     eval(test1.getSecret)   #=&amp;gt;  17&lt;br /&gt;
     #Or by simply accessing the local variable as below.&lt;br /&gt;
     eval(test1.class_eval{@secret})    #=&amp;gt; 17&lt;br /&gt;
&lt;br /&gt;
This example shows the versatility of the class_eval method to work on any class instance.  It performs many of the operations that the previous methods have performed but with the added advantage of assigning instance methods.&lt;br /&gt;
&lt;br /&gt;
=====Example 2=====&lt;br /&gt;
&lt;br /&gt;
     class Test&lt;br /&gt;
          def initialize(var)&lt;br /&gt;
               @secret = n&lt;br /&gt;
          end &lt;br /&gt;
       private:&lt;br /&gt;
          def increment&lt;br /&gt;
               @secret += 1&lt;br /&gt;
          end&lt;br /&gt;
     end&lt;br /&gt;
     test1 = Test.new(17)&lt;br /&gt;
     #We can directly use class_eval to call private methods within a class as well.&lt;br /&gt;
     test1.class_eval{ increment() }   #=&amp;gt; 18&lt;br /&gt;
&lt;br /&gt;
This example shows that class_eval has even more flexibility to call private functions of a class from outside of the class scope. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Reflection in PHP===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===Reflection in PERL===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===Reflection in ActionScript===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=Conclusions=&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
[1] [http://en.wikipedia.org/wiki/Reflection_(computer_science) Reflection Wikipedia]&lt;br /&gt;
&lt;br /&gt;
[2] [http://www.codersource.net/published/view/291/reflection_in.aspx Reflection in C# - CoderSource.net]&lt;br /&gt;
&lt;br /&gt;
[3]&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=23838</id>
		<title>CSC/ECE 517 Fall 2009/wiki2 5 jn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=23838"/>
		<updated>2009-10-09T13:50:30Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Reflection APIs=&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
====What is Reflection?====&lt;br /&gt;
Reflection in programming is a technique in which programs are able to dynamically view and alter their own structure and flow.  For example, in reflection one could determine method/variable/class names, add or delete method/variables, alter code to current methods, or simply alter values in variables.  In theory there are nearly no bounds to reflection as it directly modifies the binary of the program.  The current limitations of this process are directly related to the APIs avaliable for certain languages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====What languages are Supported?====&lt;br /&gt;
Due to the complexity required to support this majority of the languages that support this feature tend to be object oriented.  Some examples of supported languages are [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/JavaScript JavaScript], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], and [http://en.wikipedia.org/wiki/ActionScript ActionScript].  In this page we will cover a select few of the languages above and what native API support is avaliable for each of the languages.&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=23837</id>
		<title>CSC/ECE 517 Fall 2009/wiki2 5 jn</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki2_5_jn&amp;diff=23837"/>
		<updated>2009-10-09T13:47:39Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Reflection APIs=&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
====What is Reflection?====&lt;br /&gt;
Reflection in programming is a technique in which programs are able to dynamically view and alter their own structure and flow.  For example, in reflection one could determine method/variable/class names, add or delete method/variables, alter code to current methods, or simply alter values in variables.  In theory there are nearly no bounds to reflection as it directly modifies the binary of the program.  The current limitations of this process are directly related to the APIs avaliable for certain languages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====What languages are Supported?====&lt;br /&gt;
Due to the complexity required to support this majority of the languages that support this feature tend to be object oriented.  Some examples of supported languages are [http://en.wikipedia.org/wiki/Java_(programming_language) Java],[http://en.wikipedia.org/wiki/Ruby_(programming_language) Ruby], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/Perl Perl], [http://en.wikipedia.org/wiki/PHP PHP], [http://en.wikipedia.org/wiki/JavaScript JavaScript], [http://en.wikipedia.org/wiki/Python_(programming_language) Python], and [http://en.wikipedia.org/wiki/ActionScript ActionScript].  In this tutorial we will cover a select few of the languages above and what native API support is avaliable for each of the languages.&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=22351</id>
		<title>CSC/ECE 517 Fall 2009/wiki1b 7 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=22351"/>
		<updated>2009-09-29T01:45:10Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Resources For Ruby: Table of Contents=&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Learning a new program language can sometimes prove to be very difficult especially if the language has new programming concepts that the user has never previously learned.  Such an example would be moving from C to C++ and the introduction of classes and all they have to offer.  [http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 Ruby] is a language that has a number of special features not commonly found in most programming languages and sometimes can be difficult to learn, especially from [http://en.wikipedia.org/wiki/Integrated_development_environment Integrated Development Environment (IDE)].  In this page we hope to introduce the reader to a number of Ruby tutorials and give an understanding of the tutorials strengths.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Tutorial Overview=&lt;br /&gt;
&lt;br /&gt;
Every tutorial has one common goal and that is to supply some form of informative material about the Ruby programming language, but some can be better than others.  In our descriptions we try to remain objective about the contents of each tutorial and try to introduce personal opinions only when clarifications may be needed.  &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Core Ruby Programming==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Erwin Aligam&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://rubylearning.com/satishtalim/tutorial.html&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  Aug. 1st, 2008&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded examples in text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
This is a tutorial available only online as a webpage.  It is fairly simple to navigate but the website has a number of ads on the page and can sometimes make the usage a bit cumbersome.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:MethodDefine.jpg|300px|thumb|Method Definition Example]]&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby 1.9: The Pragmatic Programmers’ Guide and follows the structure fairly closely.  It has been fully updated to the newest version of Ruby as covered in the book and contains an informal install guide for Ruby making it easier for newer users.  The tutorial covers a variety of introductory topics and continues to more advanced topics such as Inheritance, Overloading Methods, Exceptions, Duck Typing, and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial contains embedded examples which are very simple and straight forward.  These aid in user learning, but the examples typically do not display the output or results.  This can be confusing and requires the user to run the code for themselves to gain an understanding of the code and what it does.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A major advantage of the tutorial is that it displays embedded links to Ruby’s API pages for the user.  This can supplement the user's knowledge of method availability in the standard API.  The author uses pictures and figures for more challenging object-oriented constructs as well as in depth descriptions that explain concepts efficiently.  Also the author supplies summaries at the end of each section which allow the material to be assimilated by repetition.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
The picture to the right is an example of the embedded programming sample and displays one of the big advantages to this tutorial.  As shown in the picture a full listing of the sample code is given along with the corresponding output.  This can drastically help the student by not making them infer what will result.  Also this can save the user time since they will not be required to run the code themselves if they find themselves confused on the output.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
&lt;br /&gt;
Over all the tutorial is very versatile and has the added advantage that it was produced from a renown book in the Ruby programming language.  It covers a large number of topics and has been fully updated to the latest version of Ruby. &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
==Programming Ruby:  The Pragmatic Programmers’ Guide==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Addison Longman&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.rubycentral.com/pickaxe&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  2001&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Intermediate&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded examples in text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
This tutorial is available only online as a webpage.  Each item in the table of contents covers a large section of material and sometimes makes it a bit difficult to find a specific topic of choice.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:ToStringExample.jpg|300px|thumb|To String Definition Example]]&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby: The Pragmatic Programmers’ Guide.  This webpage is based on the first edition of the book which covers the older version of Ruby 1.8.  The tutorial covers a wide range of introductory and advanced topics but also includes more unique topics such as Ruby TK, Threads, Ruby’s Standard Library, Network Libraries, and more.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The layout of the tutorial is easy to follow and is logically ordered.  The tutorial contains an extensive number of example code embedded in it and has the advantage that the output of each is typically shown.  This makes it easier for the user to understand what to expect from the code without having to run it themselves.  Each example is also paired with an adequate description and clarification of the subject.  No photos are typically used to portray concepts but instead the use of the examples provide the user with the understanding needed.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
The picture to the right is a sample example from the tutorial.  As shown in the picture there is only a partial code listing which requires you to make inferences on your own.  Sometimes it is easier to learn by repetition of code.  If the user is able to see the entire code they can reaffirm previous concepts.  This could be an advantage for some readers as it will reduce the clutter and only show what is important to the topic of discussion.  Regardless it does have the added advantage that it displays the output from the topic of conversation. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
&lt;br /&gt;
Overall the page is a good tutorial on Ruby 1.8 but can be a bit mundane at times.  The examples are straight forward and easy to understand but can sometimes feel like reading straight from the Ruby API.  The main advantage is the amount of topics covered which are very unique compared to other tutorials.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Little Book of Ruby==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Huw Collingbourne&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.sapphiresteel.com/The-Little-Book-Of-Ruby&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  June 17th, 2006&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner - Intermediate&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Available for download online&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
The Little Book of Ruby tutorial is a PDF (link) available free online for download.  The added convenience of the tutorial being in PDF format makes it easily viewable when not connected to the internet.  &lt;br /&gt;
&lt;br /&gt;
[[Image:SampleAside.jpg|300px|thumb|Sample Aside From the Tutorial]]&lt;br /&gt;
This tutorial is a very structured guide to learning ruby and has great flow between topics.  It is geared towards individuals who are just beginning to learn programming and may not have a solid understanding of basic programming constructs.  The material covers more basic topics involving basic method declarations, basic data structures, loops and control statements, as well as an introduction to classes and their usage.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author injects a number of aside boxes that introduce the user into the subtleties of the language.  This can help the user understand the major advantages of this language over others.  The example below displays exactly how important these subtleties can be.&lt;br /&gt;
&lt;br /&gt;
The author does no use a large number of photos but does use them for more difficult to visualize concepts.  The rest of the material has very solidly written clarifications for the topics to help prevent the need for visualization.  The author also includes vocabulary definitions making it easier for novice users to understand the material.  Overall this is a great tutorial for beginner to intermediate programmers to learn ruby.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
The picture to the right is an example of an aside in the book.  This is an important syntax example for most students, as most are used to the concept that white space is typically ignored.  In this specific example the user gets great insight to the requirements of creating accessor methods for variables and the proper syntax required by Ruby.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
&lt;br /&gt;
Over all this is a great tutorial especially for newer programmers.  It does its best job at clarifying subtleties for these newer programmers to help them avoid confusion during their first few programs.  It other major feature is that is has a separate download to acquire all the coding examples.  This is the only tutorial covered that has this feature.  &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby’s User Guide==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Mark Slagell&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.rubyist.net/~slagell/ruby/&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  2005&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded into the tutorial.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
The Ruby’s User Guide is available online as a webpage and is not available for download.  But the general layout of the website makes it very easy to navigate and utilize.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:FactorExample.jpg|300px|thumb|Sample Factor Code]]&lt;br /&gt;
The tutorial itself is not a structured as majority of the others covered in this Wikipedia, but is more of a subject based topic coverage.  The user has the option to jump around easily and learn specific topics that they may be interested in.  This is great for more advanced users that wish to learn specific things, but can hinder learning for newer programmers since it is not as structured.  The material covers from basic to advanced topics involving basic method declarations, basic data structures, loops and control statements, classes, regular expressions, iterators, inheritance, method redefinitions, exceptions and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author uses a number of examples within the tutorial to help the users understand topics and some of the subtleties of the language.  These can be invaluable to learning ruby but the drawback is that explanations are many times not adequate and can leave the user to interpret the results for themselves.  This may be due to the fact that the document was originally translated from Japanese.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
The picture to the right is an example of code take from the webpage and it displays a simple recursive algorithm for computing the factorial of a number.  What isn't displayed is what follows that code listing.  Each line from the program is broken down and explained one by one.  This can make it very simple for new users to understand exactly what each line is doing.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
&lt;br /&gt;
The entire tutorial seems to be more useful to more advanced users that know how to program already.  The main advantages of the guide is that it covers more advanced topics not normally found in tutorials and covers many unique attributes to the Ruby programming language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby Quick Reference==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Ryan Davis&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.zenspider.com/Languages/Ruby/QuickRef.html&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:''' Sept. 13th, 2009&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Intermediate – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded Syntax Examples&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
The Ruby Quick Reference is available only online but can easily be saved as a single webpage for offline viewing.  The website is a bit more difficult to navigate since the entire listing is on a single page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:ClassDefine.jpg|300px|thumb|Class Definition Example]]&lt;br /&gt;
This is not a conventional tutorial as it has little or no descriptions on each of the topics.  The purpose of this tutorial is to supply the user with the syntax of the Ruby language.  This reference is designed for intermediate to advanced users that know how the language works but are unfamiliar with the syntax.  It covers simple things from basic class definitions all the way to more advanced topics such as environment variables, exceptions, standard library modules, testing, and debugger controls.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
The picture to the right is an example taken from the webpage on syntax for defining a class.  There is a lot of information displayed in 6 short lines of code.  The example shows how a typical class is declared along with how inheritance is accomplished.  The second three lines tell the user how to create an instance method that belongs to an single instance of a class.    &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
&lt;br /&gt;
Overall this is not a tutorial at all but more of a guide on syntax in the Ruby Language.  While this is not a tutorial it is listed here because it is a valuable learning tool as it gives the users a quick way to look up programming examples.  This is ideal for users that have already used one of the previous tutorials and understand the Ruby language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
&lt;br /&gt;
All of the listed examples have a number of advantages over the others; the key to choosing one is based on the users specific needs.  One of the major differences between tutorials usually relates to the type of examples and how they are incorporated into learning.  The other main difference is the range of topics covered.  While majority of the tutorials here cover the same introductory and intermediate topics, they differ greatly on the more advanced topics.  Pay close attention to the advanced topics that may be of use for you when choosing a tutorial.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last thing to keep in mind is the last time the tutorials have been updated.  A few of the tutorials only cover Ruby 1.8 which has subtle differences from the newest version of Ruby.  While this may not be a problem for most users it is something to keep in mind while choosing a tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
[1] http://www.rubycentral.com/pickaxe/&lt;br /&gt;
&lt;br /&gt;
[2] http://rubylearning.com/satishtalim/tutorial.html&lt;br /&gt;
&lt;br /&gt;
[3] http://www.sapphiresteel.com/The-Little-Book-Of-Ruby&lt;br /&gt;
&lt;br /&gt;
[4] http://www.rubyist.net/~slagell/ruby/index.html&lt;br /&gt;
&lt;br /&gt;
[5] http://www.zenspider.com/Languages/Ruby/QuickRef.html&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=22160</id>
		<title>CSC/ECE 517 Fall 2009/wiki1b 7 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=22160"/>
		<updated>2009-09-28T15:52:40Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Resources For Ruby: Table of Contents=&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Learning a new program language can sometimes prove to be very difficult especially if the language has new programming concepts that the user has never previously learned.  Such an example would be moving from C to C++ and the introduction of classes and all they have to offer.  [http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 Ruby] is a language that has a number of special features not commonly found in most programming languages and sometimes can be difficult to learn, especially from [http://en.wikipedia.org/wiki/Integrated_development_environment Integrated Development Environment (IDE)].  In this page we hope to introduce the reader to a number of Ruby tutorials and give an understanding of the tutorials strengths.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Tutorial Overview=&lt;br /&gt;
&lt;br /&gt;
Every tutorial has one common goal and that is to supply some form of informative material about the Ruby programming language, but some can be better than others.  In our descriptions we try to remain objective about the contents of each tutorial and try to introduce personal opinions only when clarifications may be needed.  &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Core Ruby Programming==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Erwin Aligam&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://rubylearning.com/satishtalim/tutorial.html&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  Aug. 1st, 2008&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded examples in text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
This is a tutorial available only online as a webpage.  It is fairly simple to navigate but the website has a number of ads on the page and can sometimes make the usage a bit cumbersome.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:MethodDefine.jpg|300px|thumb|Method Definition Example]]&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby 1.9: The Pragmatic Programmers’ Guide and follows the structure fairly closely.  It has been fully updated to the newest version of Ruby as covered in the book and contains an informal install guide for Ruby making it easier for newer users.  The tutorial covers a variety of introductory topics and continues to more advanced topics such as Inheritance, Overloading Methods, Exceptions, Duck Typing, and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial contains embedded examples which are very simple and straight forward.  These aid in user learning, but the examples typically do not display the output or results.  This can be confusing and requires the user to run the code for themselves to gain an understanding of the code and what it does.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A major advantage of the tutorial is that it displays embedded links to Ruby’s API pages for the user.  This can supplement the user's knowledge of method availability in the standard API.  The author uses pictures and figures for more challenging object-oriented constructs as well as in depth descriptions that explain concepts efficiently.  Also the author supplies summaries at the end of each section which allow the material to be assimilated by repetition.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Disadvantage===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
The picture to the right is an example of the embedded programming sample and displays one of the big advantages to this tutorial.  As shown in the picture a full listing of the sample code is given along with the corresponding output.  This can drastically help the student by not making them infer what will result.  Also this can save the user time since they will not be required to run the code themselves if they find themselves confused on the output.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
&lt;br /&gt;
Over all the tutorial is very versatile and has the added advantage that it was produced from a renown book in the Ruby programming language.  It covers a large number of topics and has been fully updated to the latest version of Ruby. &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
==Programming Ruby:  The Pragmatic Programmers’ Guide==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Addison Longman&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.rubycentral.com/pickaxe&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  2001&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Intermediate&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded examples in text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
This tutorial is available only online as a webpage.  Each item in the table of contents covers a large section of material and sometimes makes it a bit difficult to find a specific topic of choice.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:ToStringExample.jpg|300px|thumb|To String Definition Example]]&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby: The Pragmatic Programmers’ Guide.  This webpage is based on the first edition of the book which covers the older version of Ruby 1.8.  The tutorial covers a wide range of introductory and advanced topics but also includes more unique topics such as Ruby TK, Threads, Ruby’s Standard Library, Network Libraries, and more.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The layout of the tutorial is easy to follow and is logically ordered.  The tutorial contains an extensive number of example code embedded in it and has the advantage that the output of each is typically shown.  This makes it easier for the user to understand what to expect from the code without having to run it themselves.  Each example is also paired with an adequate description and clarification of the subject.  No photos are typically used to portray concepts but instead the use of the examples provide the user with the understanding needed.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Disadvantage===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
The picture to the right is a sample example from the tutorial.  As shown in the picture there is only a partial code listing which requires you to make inferences on your own.  Sometimes it is easier to learn by repetition of code.  If the user is able to see the entire code they can reaffirm previous concepts.  This could be an advantage for some readers as it will reduce the clutter and only show what is important to the topic of discussion.  Regardless it does have the added advantage that it displays the output from the topic of conversation. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
&lt;br /&gt;
Overall the page is a good tutorial on Ruby 1.8 but can be a bit mundane at times.  The examples are straight forward and easy to understand but can sometimes feel like reading straight from the Ruby API.  The main advantage is the amount of topics covered which are very unique compared to other tutorials.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Little Book of Ruby==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Huw Collingbourne&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.sapphiresteel.com/The-Little-Book-Of-Ruby&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  June 17th, 2006&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner - Intermediate&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Available for download online&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
The Little Book of Ruby tutorial is a PDF (link) available free online for download.  The added convenience of the tutorial being in PDF format makes it easily viewable when not connected to the internet.  &lt;br /&gt;
&lt;br /&gt;
[[Image:SampleAside.jpg|300px|thumb|Sample Aside From the Tutorial]]&lt;br /&gt;
This tutorial is a very structured guide to learning ruby and has great flow between topics.  It is geared towards individuals who are just beginning to learn programming and may not have a solid understanding of basic programming constructs.  The material covers more basic topics involving basic method declarations, basic data structures, loops and control statements, as well as an introduction to classes and their usage.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author injects a number of aside boxes that introduce the user into the subtleties of the language.  This can help the user understand the major advantages of this language over others.  The example below displays exactly how important these subtleties can be.&lt;br /&gt;
&lt;br /&gt;
The author does no use a large number of photos but does use them for more difficult to visualize concepts.  The rest of the material has very solidly written clarifications for the topics to help prevent the need for visualization.  The author also includes vocabulary definitions making it easier for novice users to understand the material.  Overall this is a great tutorial for beginner to intermediate programmers to learn ruby.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Disadvantage===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
The picture to the right is an example of an aside in the book.  This is an important syntax example for most students, as most are used to the concept that white space is typically ignored.  In this specific example the user gets great insight to the requirements of creating accessor methods for variables and the proper syntax required by Ruby.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
&lt;br /&gt;
Over all this is a great tutorial especially for newer programmers.  It does its best job at clarifying subtleties for these newer programmers to help them avoid confusion during their first few programs.  It other major feature is that is has a separate download to acquire all the coding examples.  This is the only tutorial covered that has this feature.  &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby’s User Guide==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Mark Slagell&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.rubyist.net/~slagell/ruby/&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  2005&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded into the tutorial.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
The Ruby’s User Guide is available online as a webpage and is not available for download.  But the general layout of the website makes it very easy to navigate and utilize.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:FactorExample.jpg|300px|thumb|Sample Factor Code]]&lt;br /&gt;
The tutorial itself is not a structured as majority of the others covered in this Wikipedia, but is more of a subject based topic coverage.  The user has the option to jump around easily and learn specific topics that they may be interested in.  This is great for more advanced users that wish to learn specific things, but can hinder learning for newer programmers since it is not as structured.  The material covers from basic to advanced topics involving basic method declarations, basic data structures, loops and control statements, classes, regular expressions, iterators, inheritance, method redefinitions, exceptions and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author uses a number of examples within the tutorial to help the users understand topics and some of the subtleties of the language.  These can be invaluable to learning ruby but the drawback is that explanations are many times not adequate and can leave the user to interpret the results for themselves.  This may be due to the fact that the document was originally translated from Japanese.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Disadvantage===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
The picture to the right is an example of code take from the webpage and it displays a simple recursive algorithm for computing the factorial of a number.  What isn't displayed is what follows that code listing.  Each line from the program is broken down and explained one by one.  This can make it very simple for new users to understand exactly what each line is doing.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
&lt;br /&gt;
The entire tutorial seems to be more useful to more advanced users that know how to program already.  The main advantages of the guide is that it covers more advanced topics not normally found in tutorials and covers many unique attributes to the Ruby programming language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby Quick Reference==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Ryan Davis&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.zenspider.com/Languages/Ruby/QuickRef.html&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:''' Sept. 13th, 2009&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Intermediate – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded Syntax Examples&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
The Ruby Quick Reference is available only online but can easily be saved as a single webpage for offline viewing.  The website is a bit more difficult to navigate since the entire listing is on a single page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:ClassDefine.jpg|300px|thumb|Class Definition Example]]&lt;br /&gt;
This is not a conventional tutorial as it has little or no descriptions on each of the topics.  The purpose of this tutorial is to supply the user with the syntax of the Ruby language.  This reference is designed for intermediate to advanced users that know how the language works but are unfamiliar with the syntax.  It covers simple things from basic class definitions all the way to more advanced topics such as environment variables, exceptions, standard library modules, testing, and debugger controls.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Disadvantage===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
The picture to the right is an example taken from the webpage on syntax for defining a class.  There is a lot of information displayed in 6 short lines of code.  The example shows how a typical class is declared along with how inheritance is accomplished.  The second three lines tell the user how to create an instance method that belongs to an single instance of a class.    &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
&lt;br /&gt;
Overall this is not a tutorial at all but more of a guide on syntax in the Ruby Language.  While this is not a tutorial it is listed here because it is a valuable learning tool as it gives the users a quick way to look up programming examples.  This is ideal for users that have already used one of the previous tutorials and understand the Ruby language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
&lt;br /&gt;
All of the listed examples have a number of advantages over the others; the key to choosing one is based on the users specific needs.  One of the major differences between tutorials usually relates to the type of examples and how they are incorporated into learning.  The other main difference is the range of topics covered.  While majority of the tutorials here cover the same introductory and intermediate topics, they differ greatly on the more advanced topics.  Pay close attention to the advanced topics that may be of use for you when choosing a tutorial.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last thing to keep in mind is the last time the tutorials have been updated.  A few of the tutorials only cover Ruby 1.8 which has subtle differences from the newest version of Ruby.  While this may not be a problem for most users it is something to keep in mind while choosing a tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
[1] http://www.rubycentral.com/pickaxe/&lt;br /&gt;
&lt;br /&gt;
[2] http://rubylearning.com/satishtalim/tutorial.html&lt;br /&gt;
&lt;br /&gt;
[3] http://www.sapphiresteel.com/The-Little-Book-Of-Ruby&lt;br /&gt;
&lt;br /&gt;
[4] http://www.rubyist.net/~slagell/ruby/index.html&lt;br /&gt;
&lt;br /&gt;
[5] http://www.zenspider.com/Languages/Ruby/QuickRef.html&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=22158</id>
		<title>CSC/ECE 517 Fall 2009/wiki1b 7 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=22158"/>
		<updated>2009-09-28T15:47:03Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Resources For Ruby: Table of Contents=&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Learning a new program language can sometimes prove to be very difficult especially if the language has new programming concepts that the user has never previously learned.  Such an example would be moving from C to C++ and the introduction of classes and all they have to offer.  [http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 Ruby] is a language that has a number of special features not commonly found in most programming languages and sometimes can be difficult to learn, especially from [http://en.wikipedia.org/wiki/Integrated_development_environment Integrated Development Environment (IDE)].  In this page we hope to introduce the reader to a number of Ruby tutorials and give an understanding of the tutorials strengths.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Tutorial Overview=&lt;br /&gt;
&lt;br /&gt;
Every tutorial has one common goal and that is to supply some form of informative material about the Ruby programming language, but some can be better than others.  In our descriptions we try to remain objective about the contents of each tutorial and try to introduce personal opinions only when clarifications may be needed.  &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Core Ruby Programming==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Erwin Aligam&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://rubylearning.com/satishtalim/tutorial.html&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  Aug. 1st, 2008&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded examples in text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
This is a tutorial available only online as a webpage.  It is fairly simple to navigate but the website has a number of ads on the page and can sometimes make the usage a bit cumbersome.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:MethodDefine.jpg|300px|thumb|Method Definition Example]]&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby 1.9: The Pragmatic Programmers’ Guide and follows the structure fairly closely.  It has been fully updated to the newest version of Ruby as covered in the book and contains an informal install guide for Ruby making it easier for newer users.  The tutorial covers a variety of introductory topics and continues to more advanced topics such as Inheritance, Overloading Methods, Exceptions, Duck Typing, and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial contains embedded examples which are very simple and straight forward.  These aid in user learning, but the examples typically do not display the output or results.  This can be confusing and requires the user to run the code for themselves to gain an understanding of the code and what it does.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A major advantage of the tutorial is that it displays embedded links to Ruby’s API pages for the user.  This can supplement the users knowledge of method availability in the standard API.  The author uses pictures and figures for more challenging object-oriented constructs as well as in depth descriptions that explain concepts efficiently.  Also the author supplies summaries at the end of each section which allow the material to be assimilated by repetition.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Disadvantage===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
The picture to the right is an example of the embedded programming sample and displays one of the big advantages to this tutorial.  As shown in the picture a full listing of the sample code is given along with the corresponding output.  This can drastically help the student by not making them infer what will result.  Also this can save the user time since they will not be required to run the code themselves if they find themselves confused on the output.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
&lt;br /&gt;
Over all the tutorial is very versatile and has the added advantage that it was produced from a renown book in the Ruby programming language.  It covers a large number of topics and has been fully updated to the latest version of Ruby. &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
==Programming Ruby:  The Pragmatic Programmers’ Guide==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Addison Longman&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.rubycentral.com/pickaxe&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  2001&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Intermediate&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded examples in text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
This tutorial is available only online as a webpage.  Each item in the table of contents covers a large section of material and sometimes makes it a bit difficult to find a specific topic of choice.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:ToStringExample.jpg|300px|thumb|To String Definition Example]]&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby: The Pragmatic Programmers’ Guide.  This webpage is based on the first edition of the book which covers the older version of Ruby 1.8.  The tutorial covers a wide range of introductory and advanced topics but also includes more unique topics such as Ruby TK, Threads, Ruby’s Standard Library, Network Libraries, and more.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The layout of the tutorial is easy to follow and is logically ordered.  The tutorial contains an extensive number of example code embedded in it and has the advantage that the output of each is typically shown.  This makes it easier for the user to understand what to expect from the code without having to run it themselves.  Each example is also paired with an adequate description and clarification of the subject.  No photos are typically used to portray concepts but instead the use of the examples provide the user with the understanding needed.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Disadvantage===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
The picture to the right is a sample example from the tutorial.  As shown in the picture there is only a partial code listing which requires you to make inferences on your own.  Sometimes it is easier to learn by repetition of code.  If the user is able to see the entire code they can reaffirm previous concepts.  This could be an advantage for some readers as it will reduce the clutter and only show what is important to the topic of discussion.  Regardless it does have the added advantage that it displays the output from the topic of conversation. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
&lt;br /&gt;
Overall the page is a good tutorial on Ruby 1.8 but can be a bit mundane at times.  The examples are straight forward and easy to understand but can sometimes feel like reading straight from the Ruby API.  The main advantage is the amount of topics covered which are very unique compared to other tutorials.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Little Book of Ruby==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Huw Collingbourne&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.sapphiresteel.com/The-Little-Book-Of-Ruby&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  June 17th, 2006&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner - Intermediate&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Available for download online&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
The Little Book of Ruby tutorial is a PDF (link) available free online for download.  The added convenience of the tutorial being in PDF format makes it easily viewable when not connected to the internet.  &lt;br /&gt;
&lt;br /&gt;
[[Image:SampleAside.jpg|300px|thumb|Sample Aside From the Tutorial]]&lt;br /&gt;
This tutorial is a very structured guide to learning ruby and has great flow between topics.  It is geared towards individuals who are just beginning to learn programming and may not have a solid understanding of basic programming constructs.  The material covers more basic topics involving basic method declarations, basic data structures, loops and control statements, as well as an introduction to classes and their usage.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author injects a number of aside boxes that introduce the user into the subtleties of the language.  This can help the user understand the major advantages of this language over others.  The example below displays exactly how important these subtleties can be.&lt;br /&gt;
&lt;br /&gt;
The author does no use a large number of photos but does use them for more difficult to visualize concepts.  The rest of the material has very solidly written clarifications for the topics to help prevent the need for visualization.  The author also includes vocabulary definitions making it easier for novice users to understand the material.  Overall this is a great tutorial for beginner to intermediate programmers to learn ruby.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Disadvantage===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
The picture to the right is an example of an aside in the book.  This is an important syntax example for most students, as most are used to the concept that white space is typically ignored.  In this specific example the user gets great insight to the requirements of creating accessor methods for variables and the proper syntax required by Ruby.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
&lt;br /&gt;
Over all this is a great tutorial especially for newer programmers.  It does its best job at clarifying subtleties for these newer programmers to help them avoid confusion during their first few programs.  It other major feature is that is has a sperate download to acquire all the coding exmaples.  This is the only tutorial covered that has this feature.  &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby’s User Guide==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Mark Slagell&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.rubyist.net/~slagell/ruby/&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  2005&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded into the tutorial.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
The Ruby’s User Guide is available online as a webpage and is not available for download.  But the general layout of the website makes it very easy to navigate and utilize.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:FactorExample.jpg|300px|thumb|Sample Factor Code]]&lt;br /&gt;
The tutorial itself is not a structured as majority of the others covered in this Wikipedia, but is more of a subject based topic coverage.  The user has the option to jump around easily and learn specific topics that they may be interested in.  This is great for more advanced users that wish to learn specific things, but can hinder learning for newer programmers since it is not as structured.  The material covers from basic to advanced topics involving basic method declarations, basic data structures, loops and control statements, classes, regular expressions, iterators, inheritance, method redefinitions, exceptions and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author uses a number of examples within the tutorial to help the users understand topics and some of the subtleties of the language.  These can be invaluable to learning ruby but the drawback is that explanations are many times not adequate and can leave the user to interpret the results for themselves.  This may be due to the fact that the document was originally translated from Japanese.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Disadvantage===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
The picture to the right is an example of code take from the webpage and it displays a simple recursive algorithm for computing the factorial of a number.  What isn't displayed is what follows that code listing.  Each line from the program is broken down and explained one by one.  This can make it very simple for new users to understand exactly what each line is doing.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
&lt;br /&gt;
The entire tutorial seems to be more useful to more advanced users that know how to program already.  The main advantages of the guide is that it covers more advanced topics not normally found in tutorials and covers many unique attributes to the Ruby programming language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby Quick Reference==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Ryan Davis&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.zenspider.com/Languages/Ruby/QuickRef.html&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:''' Sept. 13th, 2009&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Intermediate – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded Syntax Examples&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
The Ruby Quick Reference is available only online but can easily be saved as a single webpage for offline viewing.  The website is a bit more difficult to navigate since the entire listing is on a single page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:ClassDefine.jpg|300px|thumb|Class Definition Example]]&lt;br /&gt;
This is not a conventional tutorial as it has little or no descriptions on each of the topics.  The purpose of this tutorial is to supply the user with the syntax of the Ruby language.  This reference is designed for intermediate to advanced users that know how the language works but are unfamiliar with the syntax.  It covers simple things from basic class definitions all the way to more advanced topics such as environment variables, exceptions, standard library modules, testing, and debugger controls.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Disadvantage===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
The picture to the right is an example taken from the webpage on syntax for defining a class.  There is alot of information displayed in 6 short lines of code.  The example shows how a typical class is declared along with how inheritance is accomplished.  The second three lines tell the user how to create an instance method that belongs to an single instance of a class.    &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
&lt;br /&gt;
Overall this is not a tutorial at all but more of a guide on syntax in the Ruby Language.  While this is not a tutorial it is listed here because it is a valuable learning tool as it gives the users a quick way to look up programming examples.  This is ideal for users that have already used one of the previous tutorials and understand the Ruby language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
&lt;br /&gt;
All of the listed examples have a number of advantages over the others, the key to choosing one is based on the users specific needs.  One of the major differences between tutorials usually relates to the type of examples and how they are incorporated into learning.  The other main difference is the range of topics covered.  While majority of the tutorials here cover the same introductory and intermediate topics, they differ greatly on the more advanced topics.  Pay close attention to the advanced topics that may be of use for you when choosing a tutorial.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last thing to keep in mind is the last time the tutorials have been updated.  A few of the tutorials only cover Ruby 1.8 which has subtle differences from the newest version of Ruby.  While this may not be a problem for most users it is something to keep in mind while choosing a tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
[1] http://www.rubycentral.com/pickaxe/&lt;br /&gt;
&lt;br /&gt;
[2] http://rubylearning.com/satishtalim/tutorial.html&lt;br /&gt;
&lt;br /&gt;
[3] http://www.sapphiresteel.com/The-Little-Book-Of-Ruby&lt;br /&gt;
&lt;br /&gt;
[4] http://www.rubyist.net/~slagell/ruby/index.html&lt;br /&gt;
&lt;br /&gt;
[5] http://www.zenspider.com/Languages/Ruby/QuickRef.html&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=22157</id>
		<title>CSC/ECE 517 Fall 2009/wiki1b 7 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=22157"/>
		<updated>2009-09-28T15:45:18Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
=Resources For Ruby=&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Learning a new program language can sometimes prove to be very difficult especially if the language has new programming concepts that the user has never previously learned.  Such an example would be moving from C to C++ and the introduction of classes and all they have to offer.  [http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 Ruby] is a language that has a number of special features not commonly found in most programming languages and sometimes can be difficult to learn, especially from [http://en.wikipedia.org/wiki/Integrated_development_environment Integrated Development Environment (IDE)].  In this page we hope to introduce the reader to a number of Ruby tutorials and give an understanding of the tutorials strengths.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Tutorial Overview=&lt;br /&gt;
&lt;br /&gt;
Every tutorial has one common goal and that is to supply some form of informative material about the Ruby programming language, but some can be better than others.  In our descriptions we try to remain objective about the contents of each tutorial and try to introduce personal opinions only when clarifications may be needed.  &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Core Ruby Programming==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Erwin Aligam&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://rubylearning.com/satishtalim/tutorial.html&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  Aug. 1st, 2008&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded examples in text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
This is a tutorial available only online as a webpage.  It is fairly simple to navigate but the website has a number of ads on the page and can sometimes make the usage a bit cumbersome.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:MethodDefine.jpg|300px|thumb|Method Definition Example]]&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby 1.9: The Pragmatic Programmers’ Guide and follows the structure fairly closely.  It has been fully updated to the newest version of Ruby as covered in the book and contains an informal install guide for Ruby making it easier for newer users.  The tutorial covers a variety of introductory topics and continues to more advanced topics such as Inheritance, Overloading Methods, Exceptions, Duck Typing, and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial contains embedded examples which are very simple and straight forward.  These aid in user learning, but the examples typically do not display the output or results.  This can be confusing and requires the user to run the code for themselves to gain an understanding of the code and what it does.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A major advantage of the tutorial is that it displays embedded links to Ruby’s API pages for the user.  This can supplement the users knowledge of method availability in the standard API.  The author uses pictures and figures for more challenging object-oriented constructs as well as in depth descriptions that explain concepts efficiently.  Also the author supplies summaries at the end of each section which allow the material to be assimilated by repetition.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Disadvantage===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
The picture to the right is an example of the embedded programming sample and displays one of the big advantages to this tutorial.  As shown in the picture a full listing of the sample code is given along with the corresponding output.  This can drastically help the student by not making them infer what will result.  Also this can save the user time since they will not be required to run the code themselves if they find themselves confused on the output.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
&lt;br /&gt;
Over all the tutorial is very versatile and has the added advantage that it was produced from a renown book in the Ruby programming language.  It covers a large number of topics and has been fully updated to the latest version of Ruby. &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
==Programming Ruby:  The Pragmatic Programmers’ Guide==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Addison Longman&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.rubycentral.com/pickaxe&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  2001&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Intermediate&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded examples in text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
This tutorial is available only online as a webpage.  Each item in the table of contents covers a large section of material and sometimes makes it a bit difficult to find a specific topic of choice.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:ToStringExample.jpg|300px|thumb|To String Definition Example]]&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby: The Pragmatic Programmers’ Guide.  This webpage is based on the first edition of the book which covers the older version of Ruby 1.8.  The tutorial covers a wide range of introductory and advanced topics but also includes more unique topics such as Ruby TK, Threads, Ruby’s Standard Library, Network Libraries, and more.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The layout of the tutorial is easy to follow and is logically ordered.  The tutorial contains an extensive number of example code embedded in it and has the advantage that the output of each is typically shown.  This makes it easier for the user to understand what to expect from the code without having to run it themselves.  Each example is also paired with an adequate description and clarification of the subject.  No photos are typically used to portray concepts but instead the use of the examples provide the user with the understanding needed.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Disadvantage===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
The picture to the right is a sample example from the tutorial.  As shown in the picture there is only a partial code listing which requires you to make inferences on your own.  Sometimes it is easier to learn by repetition of code.  If the user is able to see the entire code they can reaffirm previous concepts.  This could be an advantage for some readers as it will reduce the clutter and only show what is important to the topic of discussion.  Regardless it does have the added advantage that it displays the output from the topic of conversation. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
&lt;br /&gt;
Overall the page is a good tutorial on Ruby 1.8 but can be a bit mundane at times.  The examples are straight forward and easy to understand but can sometimes feel like reading straight from the Ruby API.  The main advantage is the amount of topics covered which are very unique compared to other tutorials.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Little Book of Ruby==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Huw Collingbourne&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.sapphiresteel.com/The-Little-Book-Of-Ruby&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  June 17th, 2006&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner - Intermediate&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Available for download online&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
The Little Book of Ruby tutorial is a PDF (link) available free online for download.  The added convenience of the tutorial being in PDF format makes it easily viewable when not connected to the internet.  &lt;br /&gt;
&lt;br /&gt;
[[Image:SampleAside.jpg|300px|thumb|Sample Aside From the Tutorial]]&lt;br /&gt;
This tutorial is a very structured guide to learning ruby and has great flow between topics.  It is geared towards individuals who are just beginning to learn programming and may not have a solid understanding of basic programming constructs.  The material covers more basic topics involving basic method declarations, basic data structures, loops and control statements, as well as an introduction to classes and their usage.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author injects a number of aside boxes that introduce the user into the subtleties of the language.  This can help the user understand the major advantages of this language over others.  The example below displays exactly how important these subtleties can be.&lt;br /&gt;
&lt;br /&gt;
The author does no use a large number of photos but does use them for more difficult to visualize concepts.  The rest of the material has very solidly written clarifications for the topics to help prevent the need for visualization.  The author also includes vocabulary definitions making it easier for novice users to understand the material.  Overall this is a great tutorial for beginner to intermediate programmers to learn ruby.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Disadvantage===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
The picture to the right is an example of an aside in the book.  This is an important syntax example for most students, as most are used to the concept that white space is typically ignored.  In this specific example the user gets great insight to the requirements of creating accessor methods for variables and the proper syntax required by Ruby.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
&lt;br /&gt;
Over all this is a great tutorial especially for newer programmers.  It does its best job at clarifying subtleties for these newer programmers to help them avoid confusion during their first few programs.  It other major feature is that is has a sperate download to acquire all the coding exmaples.  This is the only tutorial covered that has this feature.  &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby’s User Guide==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Mark Slagell&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.rubyist.net/~slagell/ruby/&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  2005&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded into the tutorial.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
The Ruby’s User Guide is available online as a webpage and is not available for download.  But the general layout of the website makes it very easy to navigate and utilize.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:FactorExample.jpg|300px|thumb|Sample Factor Code]]&lt;br /&gt;
The tutorial itself is not a structured as majority of the others covered in this Wikipedia, but is more of a subject based topic coverage.  The user has the option to jump around easily and learn specific topics that they may be interested in.  This is great for more advanced users that wish to learn specific things, but can hinder learning for newer programmers since it is not as structured.  The material covers from basic to advanced topics involving basic method declarations, basic data structures, loops and control statements, classes, regular expressions, iterators, inheritance, method redefinitions, exceptions and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author uses a number of examples within the tutorial to help the users understand topics and some of the subtleties of the language.  These can be invaluable to learning ruby but the drawback is that explanations are many times not adequate and can leave the user to interpret the results for themselves.  This may be due to the fact that the document was originally translated from Japanese.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Disadvantage===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
The picture to the right is an example of code take from the webpage and it displays a simple recursive algorithm for computing the factorial of a number.  What isn't displayed is what follows that code listing.  Each line from the program is broken down and explained one by one.  This can make it very simple for new users to understand exactly what each line is doing.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
&lt;br /&gt;
The entire tutorial seems to be more useful to more advanced users that know how to program already.  The main advantages of the guide is that it covers more advanced topics not normally found in tutorials and covers many unique attributes to the Ruby programming language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby Quick Reference==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Ryan Davis&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.zenspider.com/Languages/Ruby/QuickRef.html&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:''' Sept. 13th, 2009&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Intermediate – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded Syntax Examples&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
The Ruby Quick Reference is available only online but can easily be saved as a single webpage for offline viewing.  The website is a bit more difficult to navigate since the entire listing is on a single page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:ClassDefine.jpg|300px|thumb|Class Definition Example]]&lt;br /&gt;
This is not a conventional tutorial as it has little or no descriptions on each of the topics.  The purpose of this tutorial is to supply the user with the syntax of the Ruby language.  This reference is designed for intermediate to advanced users that know how the language works but are unfamiliar with the syntax.  It covers simple things from basic class definitions all the way to more advanced topics such as environment variables, exceptions, standard library modules, testing, and debugger controls.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Disadvantage===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
The picture to the right is an example taken from the webpage on syntax for defining a class.  There is alot of information displayed in 6 short lines of code.  The example shows how a typical class is declared along with how inheritance is accomplished.  The second three lines tell the user how to create an instance method that belongs to an single instance of a class.    &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
&lt;br /&gt;
Overall this is not a tutorial at all but more of a guide on syntax in the Ruby Language.  While this is not a tutorial it is listed here because it is a valuable learning tool as it gives the users a quick way to look up programming examples.  This is ideal for users that have already used one of the previous tutorials and understand the Ruby language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
&lt;br /&gt;
All of the listed examples have a number of advantages over the others, the key to choosing one is based on the users specific needs.  One of the major differences between tutorials usually relates to the type of examples and how they are incorporated into learning.  The other main difference is the range of topics covered.  While majority of the tutorials here cover the same introductory and intermediate topics, they differ greatly on the more advanced topics.  Pay close attention to the advanced topics that may be of use for you when choosing a tutorial.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last thing to keep in mind is the last time the tutorials have been updated.  A few of the tutorials only cover Ruby 1.8 which has subtle differences from the newest version of Ruby.  While this may not be a problem for most users it is something to keep in mind while choosing a tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
[1] http://www.rubycentral.com/pickaxe/&lt;br /&gt;
&lt;br /&gt;
[2] http://rubylearning.com/satishtalim/tutorial.html&lt;br /&gt;
&lt;br /&gt;
[3] http://www.sapphiresteel.com/The-Little-Book-Of-Ruby&lt;br /&gt;
&lt;br /&gt;
[4] http://www.rubyist.net/~slagell/ruby/index.html&lt;br /&gt;
&lt;br /&gt;
[5] http://www.zenspider.com/Languages/Ruby/QuickRef.html&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=22156</id>
		<title>CSC/ECE 517 Fall 2009/wiki1b 7 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=22156"/>
		<updated>2009-09-28T15:44:05Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
=Resources For Ruby=&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Learning a new program language can sometimes prove to be very difficult especially if the language has new programming concepts that the user has never previously learned.  Such an example would be moving from C to C++ and the introduction of classes and all they have to offer.  [http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 Ruby] is a language that has a number of special features not commonly found in most programming languages and sometimes can be difficult to learn, especially from [http://en.wikipedia.org/wiki/Integrated_development_environment Integrated Development Environment (IDE)].  In this page we hope to introduce the reader to a number of Ruby tutorials and give an understanding of the tutorials strengths.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Tutorial Overview=&lt;br /&gt;
&lt;br /&gt;
Every tutorial has one common goal and that is to supply some form of informative material about the Ruby programming language, but some can be better than others.  In our descriptions we try to remain objective about the contents of each tutorial and try to introduce personal opinions only when clarifications may be needed.  &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Core Ruby Programming==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Erwin Aligam&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://rubylearning.com/satishtalim/tutorial.html&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  Aug. 1st, 2008&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded examples in text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
This is a tutorial available only online as a webpage.  It is fairly simple to navigate but the website has a number of ads on the page and can sometimes make the usage a bit cumbersome.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:MethodDefine.jpg|300px|thumb|Method Definition Example]]&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby 1.9: The Pragmatic Programmers’ Guide and follows the structure fairly closely.  It has been fully updated to the newest version of Ruby as covered in the book and contains an informal install guide for Ruby making it easier for newer users.  The tutorial covers a variety of introductory topics and continues to more advanced topics such as Inheritance, Overloading Methods, Exceptions, Duck Typing, and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial contains embedded examples which are very simple and straight forward.  These aid in user learning, but the examples typically do not display the output or results.  This can be confusing and requires the user to run the code for themselves to gain an understanding of the code and what it does.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A major advantage of the tutorial is that it displays embedded links to Ruby’s API pages for the user.  This can supplement the users knowledge of method availability in the standard API.  The author uses pictures and figures for more challenging object-oriented constructs as well as in depth descriptions that explain concepts efficiently.  Also the author supplies summaries at the end of each section which allow the material to be assimilated by repetition.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Disadvantage===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
To the right is an example of the embedded programming sample and displays one of the big advantages to this tutorial.  As shown in the picture a full listing of the sample code is given along with the corresponding output.  This can drastically help the student by not making them infer what will result.  Also this can save the user time since they will not be required to run the code themselves if they find themselves confused on the output.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
&lt;br /&gt;
Over all the tutorial is very versatile and has the added advantage that it was produced from a renown book in the Ruby programming language.  It covers a large number of topics and has been fully updated to the latest version of Ruby. &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
==Programming Ruby:  The Pragmatic Programmers’ Guide==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Addison Longman&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.rubycentral.com/pickaxe&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  2001&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Intermediate&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded examples in text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
This tutorial is available only online as a webpage.  Each item in the table of contents covers a large section of material and sometimes makes it a bit difficult to find a specific topic of choice.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:ToStringExample.jpg|300px|thumb|To String Definition Example]]&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby: The Pragmatic Programmers’ Guide.  This webpage is based on the first edition of the book which covers the older version of Ruby 1.8.  The tutorial covers a wide range of introductory and advanced topics but also includes more unique topics such as Ruby TK, Threads, Ruby’s Standard Library, Network Libraries, and more.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The layout of the tutorial is easy to follow and is logically ordered.  The tutorial contains an extensive number of example code embedded in it and has the advantage that the output of each is typically shown.  This makes it easier for the user to understand what to expect from the code without having to run it themselves.  Each example is also paired with an adequate description and clarification of the subject.  No photos are typically used to portray concepts but instead the use of the examples provide the user with the understanding needed.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Disadvantage===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
To the right is a sample example from the tutorial.  As shown in the picture there is only a partial code listing which requires you to make inferences on your own.  Sometimes it is easier to learn by repetition of code.  If the user is able to see the entire code they can reaffirm previous concepts.  This could be an advantage for some readers as it will reduce the clutter and only show what is important to the topic of discussion.  Regardless it does have the added advantage that it displays the output from the topic of conversation. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
&lt;br /&gt;
Overall the page is a good tutorial on Ruby 1.8 but can be a bit mundane at times.  The examples are straight forward and easy to understand but can sometimes feel like reading straight from the Ruby API.  The main advantage is the amount of topics covered which are very unique compared to other tutorials.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Little Book of Ruby==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Huw Collingbourne&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.sapphiresteel.com/The-Little-Book-Of-Ruby&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  June 17th, 2006&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner - Intermediate&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Available for download online&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
The Little Book of Ruby tutorial is a PDF (link) available free online for download.  The added convenience of the tutorial being in PDF format makes it easily viewable when not connected to the internet.  &lt;br /&gt;
&lt;br /&gt;
[[Image:SampleAside.jpg|300px|thumb|Sample Aside From the Tutorial]]&lt;br /&gt;
This tutorial is a very structured guide to learning ruby and has great flow between topics.  It is geared towards individuals who are just beginning to learn programming and may not have a solid understanding of basic programming constructs.  The material covers more basic topics involving basic method declarations, basic data structures, loops and control statements, as well as an introduction to classes and their usage.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author injects a number of aside boxes that introduce the user into the subtleties of the language.  This can help the user understand the major advantages of this language over others.  The example below displays exactly how important these subtleties can be.&lt;br /&gt;
&lt;br /&gt;
The author does no use a large number of photos but does use them for more difficult to visualize concepts.  The rest of the material has very solidly written clarifications for the topics to help prevent the need for visualization.  The author also includes vocabulary definitions making it easier for novice users to understand the material.  Overall this is a great tutorial for beginner to intermediate programmers to learn ruby.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Disadvantage===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
To the right is an example of an aside in the book.  This is an important syntax example for most students, as most are used to the concept that white space is typically ignored.  In this specific example the user gets great insight to the requirements of creating accessor methods for variables and the proper syntax required by Ruby.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
&lt;br /&gt;
Over all this is a great tutorial especially for newer programmers.  It does its best job at clarifying subtleties for these newer programmers to help them avoid confusion during their first few programs.  It other major feature is that is has a sperate download to acquire all the coding exmaples.  This is the only tutorial covered that has this feature.  &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby’s User Guide==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Mark Slagell&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.rubyist.net/~slagell/ruby/&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  2005&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded into the tutorial.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
The Ruby’s User Guide is available online as a webpage and is not available for download.  But the general layout of the website makes it very easy to navigate and utilize.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:FactorExample.jpg|300px|thumb|Sample Factor Code]]&lt;br /&gt;
The tutorial itself is not a structured as majority of the others covered in this Wikipedia, but is more of a subject based topic coverage.  The user has the option to jump around easily and learn specific topics that they may be interested in.  This is great for more advanced users that wish to learn specific things, but can hinder learning for newer programmers since it is not as structured.  The material covers from basic to advanced topics involving basic method declarations, basic data structures, loops and control statements, classes, regular expressions, iterators, inheritance, method redefinitions, exceptions and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author uses a number of examples within the tutorial to help the users understand topics and some of the subtleties of the language.  These can be invaluable to learning ruby but the drawback is that explanations are many times not adequate and can leave the user to interpret the results for themselves.  This may be due to the fact that the document was originally translated from Japanese.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Disadvantage===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
To the right is an example of code take from the webpage and it displays a simple recursive algorithm for computing the factorial of a number.  What isn't displayed is what follows that code listing.  Each line from the program is broken down and explained one by one.  This can make it very simple for new users to understand exactly what each line is doing.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
&lt;br /&gt;
The entire tutorial seems to be more useful to more advanced users that know how to program already.  The main advantages of the guide is that it covers more advanced topics not normally found in tutorials and covers many unique attributes to the Ruby programming language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby Quick Reference==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Ryan Davis&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.zenspider.com/Languages/Ruby/QuickRef.html&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:''' Sept. 13th, 2009&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Intermediate – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded Syntax Examples&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
The Ruby Quick Reference is available only online but can easily be saved as a single webpage for offline viewing.  The website is a bit more difficult to navigate since the entire listing is on a single page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:ClassDefine.jpg|300px|thumb|Class Definition Example]]&lt;br /&gt;
This is not a conventional tutorial as it has little or no descriptions on each of the topics.  The purpose of this tutorial is to supply the user with the syntax of the Ruby language.  This reference is designed for intermediate to advanced users that know how the language works but are unfamiliar with the syntax.  It covers simple things from basic class definitions all the way to more advanced topics such as environment variables, exceptions, standard library modules, testing, and debugger controls.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Disadvantage===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
To the right is an example taken from the webpage on syntax for defining a class.  There is alot of information displayed in 6 short lines of code.  The example shows how a typical class is declared along with how inheritance is accomplished.  The second three lines tell the user how to create an instance method that belongs to an single instance of a class.    &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
&lt;br /&gt;
Overall this is not a tutorial at all but more of a guide on syntax in the Ruby Language.  While this is not a tutorial it is listed here because it is a valuable learning tool as it gives the users a quick way to look up programming examples.  This is ideal for users that have already used one of the previous tutorials and understand the Ruby language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
&lt;br /&gt;
All of the listed examples have a number of advantages over the others, the key to choosing one is based on the users specific needs.  One of the major differences between tutorials usually relates to the type of examples and how they are incorporated into learning.  The other main difference is the range of topics covered.  While majority of the tutorials here cover the same introductory and intermediate topics, they differ greatly on the more advanced topics.  Pay close attention to the advanced topics that may be of use for you when choosing a tutorial.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last thing to keep in mind is the last time the tutorials have been updated.  A few of the tutorials only cover Ruby 1.8 which has subtle differences from the newest version of Ruby.  While this may not be a problem for most users it is something to keep in mind while choosing a tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
[1] http://www.rubycentral.com/pickaxe/&lt;br /&gt;
&lt;br /&gt;
[2] http://rubylearning.com/satishtalim/tutorial.html&lt;br /&gt;
&lt;br /&gt;
[3] http://www.sapphiresteel.com/The-Little-Book-Of-Ruby&lt;br /&gt;
&lt;br /&gt;
[4] http://www.rubyist.net/~slagell/ruby/index.html&lt;br /&gt;
&lt;br /&gt;
[5] http://www.zenspider.com/Languages/Ruby/QuickRef.html&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=22153</id>
		<title>CSC/ECE 517 Fall 2009/wiki1b 7 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=22153"/>
		<updated>2009-09-28T15:06:13Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
=Resources For Ruby=&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Learning a new program language can sometimes prove to be very difficult especially if the language has new programming concepts that the user has never previously learned.  Such an example would be moving from C to C++ and the introduction of classes and all they have to offer.  [http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 Ruby] is a language that has a number of special features not commonly found in most programming languages and sometimes can be difficult to learn, especially from [http://en.wikipedia.org/wiki/Integrated_development_environment Integrated Development Environment (IDE)].  In this page we hope to introduce the reader to a number of Ruby tutorials and give an understanding of the tutorials strengths.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Tutorial Overview=&lt;br /&gt;
&lt;br /&gt;
Every tutorial has one common goal and that is to supply some form of informative material about the Ruby programming language, but some can be better than others.  In our descriptions we try to remain objective about the contents of each tutorial and try to introduce personal opinions only when clarifications may be needed.  &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Core Ruby Programming==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Erwin Aligam&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://rubylearning.com/satishtalim/tutorial.html&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  Aug. 1st, 2008&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded examples in text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
This is a tutorial available only online as a webpage.  It is fairly simple to navigate but the website has a number of ads on the page and can sometimes make the usage a bit cumbersome.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:MethodDefine.jpg|300px|thumb|Method Definition Example]]&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby 1.9: The Pragmatic Programmers’ Guide and follows the structure fairly closely.  It has been fully updated to the newest version of Ruby as covered in the book and contains an informal install guide for Ruby making it easier for newer users.  The tutorial covers a variety of introductory topics and continues to more advanced topics such as Inheritance, Overloading Methods, Exceptions, Duck Typing, and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial contains embedded examples which are very simple and straight forward.  These aid in user learning, but the examples typically do not display the output or results.  This can be confusing and requires the user to run the code for themselves to gain an understanding of the code and what it does.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A major advantage of the tutorial is that it displays embedded links to Ruby’s API pages for the user.  This can supplement the users knowledge of method availability in the standard API.  The author uses pictures and figures for more challenging object-oriented constructs as well as in depth descriptions that explain concepts efficiently.  Also the author supplies summaries at the end of each section which allow the material to be assimilated by repetition.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Disadvantage===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
To the right is an example of the embedded programming sample.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
&lt;br /&gt;
Over all the tutorial is very versatile and has the added advantage that it was produced from a renown book in the Ruby programming language.  It covers a large number of topics and has been fully updated to the latest version of Ruby. &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
==Programming Ruby:  The Pragmatic Programmers’ Guide==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Addison Longman&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.rubycentral.com/pickaxe&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  2001&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Intermediate&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded examples in text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
This tutorial is available only online as a webpage.  Each item in the table of contents covers a large section of material and sometimes makes it a bit difficult to find a specific topic of choice.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:ToStringExample.jpg|300px|thumb|To String Definition Example]]&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby: The Pragmatic Programmers’ Guide.  This webpage is based on the first edition of the book which covers the older version of Ruby 1.8.  The tutorial covers a wide range of introductory and advanced topics but also includes more unique topics such as Ruby TK, Threads, Ruby’s Standard Library, Network Libraries, and more.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The layout of the tutorial is easy to follow and is logically ordered.  The tutorial contains an extensive number of example code embedded in it and has the advantage that the output of each is typically shown.  This makes it easier for the user to understand what to expect from the code without having to run it themselves.  Each example is also paired with an adequate description and clarification of the subject.  No photos are typically used to portray concepts but instead the use of the examples provide the user with the understanding needed.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Disadvantage===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
To the right is a sample example from the tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
&lt;br /&gt;
Overall the page is a good tutorial on Ruby 1.8 but can be a bit mundane at times.  The examples are straight forward and easy to understand but can sometimes feel like reading straight from the Ruby API.  The main advantage is the amount of topics covered which are very unique compared to other tutorials.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Little Book of Ruby==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Huw Collingbourne&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.sapphiresteel.com/The-Little-Book-Of-Ruby&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  June 17th, 2006&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner - Intermediate&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Available for download online&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
The Little Book of Ruby tutorial is a PDF (link) available free online for download.  The added convenience of the tutorial being in PDF format makes it easily viewable when not connected to the internet.  &lt;br /&gt;
&lt;br /&gt;
[[Image:SampleAside.jpg|300px|thumb|Sample Aside From the Tutorial]]&lt;br /&gt;
This tutorial is a very structured guide to learning ruby and has great flow between topics.  It is geared towards individuals who are just beginning to learn programming and may not have a solid understanding of basic programming constructs.  The material covers more basic topics involving basic method declarations, basic data structures, loops and control statements, as well as an introduction to classes and their usage.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author injects a number of aside boxes that introduce the user into the subtleties of the language.  This can help the user understand the major advantages of this language over others.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Disadvantage===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
To the right is an example of an aside in the book.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
&lt;br /&gt;
The author does no use a large number of photos but does use them for more difficult to visualize concepts.  The rest of the material has very solidly written clarifications for the topics to help prevent the need for visualization.  The author also includes vocabulary definitions making it easier for novice users to understand the material.  Overall this is a great tutorial for beginner to intermediate programmers to learn ruby.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby’s User Guide==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Mark Slagell&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.rubyist.net/~slagell/ruby/&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  2005&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded into the tutorial.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
The Ruby’s User Guide is available online as a webpage and is not available for download.  But the general layout of the website makes it very easy to navigate and utilize.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:FactorExample.jpg|300px|thumb|Sample Factor Code]]&lt;br /&gt;
The tutorial itself is not a structured as majority of the others covered in this Wikipedia, but is more of a subject based topic coverage.  The user has the option to jump around easily and learn specific topics that they may be interested in.  This is great for more advanced users that wish to learn specific things, but can hinder learning for newer programmers since it is not as structured.  The material covers from basic to advanced topics involving basic method declarations, basic data structures, loops and control statements, classes, regular expressions, iterators, inheritance, method redefinitions, exceptions and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author uses a number of examples within the tutorial to help the users understand topics and some of the subtleties of the language.  These can be invaluable to learning ruby but the drawback is that explanations are many times not adequate and can leave the user to interpret the results for themselves.  This may be due to the fact that the document was originally translated from Japanese.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Disadvantage===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
To the right is an example of code take from the webpage.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
&lt;br /&gt;
The entire tutorial seems to be more useful to more advanced users that know how to program already.  The main advantages of the guide is that it covers more advanced topics not normally found in tutorials and covers many unique attributes to the Ruby programming language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby Quick Reference==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Ryan Davis&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.zenspider.com/Languages/Ruby/QuickRef.html&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:''' Sept. 13th, 2009&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Intermediate – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded Syntax Examples&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Overview===&lt;br /&gt;
&lt;br /&gt;
The Ruby Quick Reference is available only online but can easily be saved as a single webpage for offline viewing.  The website is a bit more difficult to navigate since the entire listing is on a single page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:ClassDefine.jpg|300px|thumb|Class Definition Example]]&lt;br /&gt;
This is not a conventional tutorial as it has little or no descriptions on each of the topics.  The purpose of this tutorial is to supply the user with the syntax of the Ruby language.  This reference is designed for intermediate to advanced users that know how the language works but are unfamiliar with the syntax.  It covers simple things from basic class definitions all the way to more advanced topics such as environment variables, exceptions, standard library modules, testing, and debugger controls.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Disadvantage===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
To the right is an example taken from the webpage on syntax for defining a class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Conclusion===&lt;br /&gt;
&lt;br /&gt;
Overall this is not a tutorial at all but more of a guide on syntax in the Ruby Language.  While this is not a tutorial it is listed here because it is a valuable learning tool as it gives the users a quick way to look up programming examples.  This is ideal for users that have already used one of the previous tutorials and understand the Ruby language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
&lt;br /&gt;
All of the listed examples have a number of advantages over the others, the key to choosing one is based on the users specific needs.  One of the major differences between tutorials usually relates to the type of examples and how they are incorporated into learning.  The other main difference is the range of topics covered.  While majority of the tutorials here cover the same introductory and intermediate topics, they differ greatly on the more advanced topics.  Pay close attention to the advanced topics that may be of use for you when choosing a tutorial.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last thing to keep in mind is the last time the tutorials have been updated.  A few of the tutorials only cover Ruby 1.8 which has subtle differences from the newest version of Ruby.  While this may not be a problem for most users it is something to keep in mind while choosing a tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
[1] http://www.rubycentral.com/pickaxe/&lt;br /&gt;
&lt;br /&gt;
[2] http://rubylearning.com/satishtalim/tutorial.html&lt;br /&gt;
&lt;br /&gt;
[3] http://www.sapphiresteel.com/The-Little-Book-Of-Ruby&lt;br /&gt;
&lt;br /&gt;
[4] http://www.rubyist.net/~slagell/ruby/index.html&lt;br /&gt;
&lt;br /&gt;
[5] http://www.zenspider.com/Languages/Ruby/QuickRef.html&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=21049</id>
		<title>CSC/ECE 517 Fall 2009/wiki1b 7 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=21049"/>
		<updated>2009-09-21T15:47:53Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
=Resources For Ruby=&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Learning a new program language can sometimes prove to be very difficult especially if the language has new programming concepts that the user has never previously learned.  Such an example would be moving from C to C++ and the introduction of classes and all they have to offer.  [http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 Ruby] is a language that has a number of special features not commonly found in most programming languages and sometimes can be difficult to learn, especially from [http://en.wikipedia.org/wiki/Integrated_development_environment Integrated Development Environment (IDE)].  In this page we hope to introduce the reader to a number of Ruby tutorials and give an understanding of the tutorials strengths.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Tutorial Overview=&lt;br /&gt;
&lt;br /&gt;
Every tutorial has one common goal and that is to supply some form of informative material about the Ruby programming language, but some can be better than others.  In our descriptions we try to remain objective about the contents of each tutorial and try to introduce personal opinions only when clarifications may be needed.  &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Core Ruby Programming==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Erwin Aligam&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://rubylearning.com/satishtalim/tutorial.html&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  Aug. 1st, 2008&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded examples in text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is a tutorial available only online as a webpage.  It is fairly simple to navigate but the website has a number of ads on the page and can sometimes make the usage a bit cumbersome.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:MethodDefine.jpg|300px|thumb|Method Definition Example]]&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby 1.9: The Pragmatic Programmers’ Guide and follows the structure fairly closely.  It has been fully updated to the newest version of Ruby as covered in the book and contains an informal install guide for Ruby making it easier for newer users.  The tutorial covers a variety of introductory topics and continues to more advanced topics such as Inheritance, Overloading Methods, Exceptions, Duck Typing, and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial contains embedded examples which are very simple and straight forward.  These aid in user learning, but the examples typically do not display the output or results.  This can be confusing and requires the user to run the code for themselves to gain an understanding of the code and what it does.  To the right is an example of the embedded programming sample.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A major advantage of the tutorial is that it displays embedded links to Ruby’s API pages for the user.  This can supplement the users knowledge of method availability in the standard API.  The author uses pictures and figures for more challenging object-oriented constructs as well as in depth descriptions that explain concepts efficiently.  Also the author supplies summaries at the end of each section which allow the material to be assimilated by repetition.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over all the tutorial is very versatile and has the added advantage that it was produced from a renown book in the Ruby programming language.  It covers a large number of topics and has been fully updated to the latest version of Ruby. &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
==Programming Ruby:  The Pragmatic Programmers’ Guide==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Addison Longman&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.rubycentral.com/pickaxe&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  2001&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Intermediate&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded examples in text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This tutorial is available only online as a webpage.  Each item in the table of contents covers a large section of material and sometimes makes it a bit difficult to find a specific topic of choice.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:ToStringExample.jpg|300px|thumb|To String Definition Example]]&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby: The Pragmatic Programmers’ Guide.  This webpage is based on the first edition of the book which covers the older version of Ruby 1.8.  The tutorial covers a wide range of introductory and advanced topics but also includes more unique topics such as Ruby TK, Threads, Ruby’s Standard Library, Network Libraries, and more.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The layout of the tutorial is easy to follow and is logically ordered.  The tutorial contains an extensive number of example code embedded in it and has the advantage that the output of each is typically shown.  This makes it easier for the user to understand what to expect from the code without having to run it themselves.  Each example is also paired with an adequate description and clarification of the subject.  No photos are typically used to portray concepts but instead the use of the examples provide the user with the understanding needed.  To the right is a sample example from the tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Overall the page is a good tutorial on Ruby 1.8 but can be a bit mundane at times.  The examples are straight forward and easy to understand but can sometimes feel like reading straight from the Ruby API.  The main advantage is the amount of topics covered which are very unique compared to other tutorials.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Little Book of Ruby==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Huw Collingbourne&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.sapphiresteel.com/The-Little-Book-Of-Ruby&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  June 17th, 2006&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner - Intermediate&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Available for download online&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Little Book of Ruby tutorial is a PDF (link) available free online for download.  The added convenience of the tutorial being in PDF format makes it easily viewable when not connected to the internet.  &lt;br /&gt;
&lt;br /&gt;
[[Image:SampleAside.jpg|300px|thumb|Sample Aside From the Tutorial]]&lt;br /&gt;
This tutorial is a very structured guide to learning ruby and has great flow between topics.  It is geared towards individuals who are just beginning to learn programming and may not have a solid understanding of basic programming constructs.  The material covers more basic topics involving basic method declarations, basic data structures, loops and control statements, as well as an introduction to classes and their usage.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author injects a number of aside boxes that introduce the user into the subtleties of the language.  This can help the user understand the major advantages of this language over others.  To the right is an example of an aside in the book.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author does no use a large number of photos but does use them for more difficult to visualize concepts.  The rest of the material has very solidly written clarifications for the topics to help prevent the need for visualization.  The author also includes vocabulary definitions making it easier for novice users to understand the material.  Overall this is a great tutorial for beginner to intermediate programmers to learn ruby.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby’s User Guide==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Mark Slagell&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.rubyist.net/~slagell/ruby/&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  2005&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded into the tutorial.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Ruby’s User Guide is available online as a webpage and is not available for download.  But the general layout of the website makes it very easy to navigate and utilize.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:FactorExample.jpg|300px|thumb|Sample Factor Code]]&lt;br /&gt;
The tutorial itself is not a structured as majority of the others covered in this Wikipedia, but is more of a subject based topic coverage.  The user has the option to jump around easily and learn specific topics that they may be interested in.  This is great for more advanced users that wish to learn specific things, but can hinder learning for newer programmers since it is not as structured.  The material covers from basic to advanced topics involving basic method declarations, basic data structures, loops and control statements, classes, regular expressions, iterators, inheritance, method redefinitions, exceptions and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author uses a number of examples within the tutorial to help the users understand topics and some of the subtleties of the language.  These can be invaluable to learning ruby but the drawback is that explanations are many times not adequate and can leave the user to interpret the results for themselves.  This may be due to the fact that the document was originally translated from Japanese.  To the right is an example of code take from the webpage.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The entire tutorial seems to be more useful to more advanced users that know how to program already.  The main advantages of the guide is that it covers more advanced topics not normally found in tutorials and covers many unique attributes to the Ruby programming language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby Quick Reference==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Ryan Davis&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.zenspider.com/Languages/Ruby/QuickRef.html&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:''' Sept. 13th, 2009&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Intermediate – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded Syntax Examples&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Ruby Quick Reference is available only online but can easily be saved as a single webpage for offline viewing.  The website is a bit more difficult to navigate since the entire listing is on a single page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:ClassDefine.jpg|300px|thumb|Class Definition Example]]&lt;br /&gt;
This is not a conventional tutorial as it has little or no descriptions on each of the topics.  The purpose of this tutorial is to supply the user with the syntax of the Ruby language.  This reference is designed for intermediate to advanced users that know how the language works but are unfamiliar with the syntax.  It covers simple things from basic class definitions all the way to more advanced topics such as environment variables, exceptions, standard library modules, testing, and debugger controls.  To the right is an example taken from the webpage on syntax for defining a class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Overall this is not a tutorial at all but more of a guide on syntax in the Ruby Language.  While this is not a tutorial it is listed here because it is a valuable learning tool as it gives the users a quick way to look up programming examples.  This is ideal for users that have already used one of the previous tutorials and understand the Ruby language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
&lt;br /&gt;
All of the listed examples have a number of advantages over the others, the key to choosing one is based on the users specific needs.  One of the major differences between tutorials usually relates to the type of examples and how they are incorporated into learning.  The other main difference is the range of topics covered.  While majority of the tutorials here cover the same introductory and intermediate topics, they differ greatly on the more advanced topics.  Pay close attention to the advanced topics that may be of use for you when choosing a tutorial.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last thing to keep in mind is the last time the tutorials have been updated.  A few of the tutorials only cover Ruby 1.8 which has subtle differences from the newest version of Ruby.  While this may not be a problem for most users it is something to keep in mind while choosing a tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
[1] http://www.rubycentral.com/pickaxe/&lt;br /&gt;
&lt;br /&gt;
[2] http://rubylearning.com/satishtalim/tutorial.html&lt;br /&gt;
&lt;br /&gt;
[3] http://www.sapphiresteel.com/The-Little-Book-Of-Ruby&lt;br /&gt;
&lt;br /&gt;
[4] http://www.rubyist.net/~slagell/ruby/index.html&lt;br /&gt;
&lt;br /&gt;
[5] http://www.zenspider.com/Languages/Ruby/QuickRef.html&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=21046</id>
		<title>CSC/ECE 517 Fall 2009/wiki1b 7 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=21046"/>
		<updated>2009-09-21T15:44:14Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
=Resources For Ruby=&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Learning a new program language can sometimes prove to be very difficult especially if the language has new programming concepts that the user has never previously learned.  Such an example would be moving from C to C++ and the introduction of classes and all they have to offer.  [http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 Ruby] is a language that has a number of special features not commonly found in most programming languages and sometimes can be difficult to learn, especially from [http://en.wikipedia.org/wiki/Integrated_development_environment Integrated Development Environment (IDE)].  In this page we hope to introduce the reader to a number of Ruby tutorials and give an understanding of the tutorials strengths.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Tutorial Overview=&lt;br /&gt;
&lt;br /&gt;
Every tutorial has one common goal and that is to supply some form of informative material about the Ruby programming language, but some can be better than others.  In our descriptions we try to remain objective about the contents of each tutorial and try to introduce personal opinions only when clarifications may be needed.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Core Ruby Programming==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Erwin Aligam&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://rubylearning.com/satishtalim/tutorial.html&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  Aug. 1st, 2008&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded examples in text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is a tutorial available only online as a webpage.  It is fairly simple to navigate but the website has a number of ads on the page and can sometimes make the usage a bit cumbersome.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:MethodDefine.jpg|thumb|Method Definition Example]]&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby 1.9: The Pragmatic Programmers’ Guide and follows the structure fairly closely.  It has been fully updated to the newest version of Ruby as covered in the book and contains an informal install guide for Ruby making it easier for newer users.  The tutorial covers a variety of introductory topics and continues to more advanced topics such as Inheritance, Overloading Methods, Exceptions, Duck Typing, and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial contains embedded examples which are very simple and straight forward.  These aid in user learning, but the examples typically do not display the output or results.  This can be confusing and requires the user to run the code for themselves to gain an understanding of the code and what it does.  To the right is an example of the embedded programming sample.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A major advantage of the tutorial is that it displays embedded links to Ruby’s API pages for the user.  This can supplement the users knowledge of method availability in the standard API.  The author uses pictures and figures for more challenging object-oriented constructs as well as in depth descriptions that explain concepts efficiently.  Also the author supplies summaries at the end of each section which allow the material to be assimilated by repetition.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over all the tutorial is very versatile and has the added advantage that it was produced from a renown book in the Ruby programming language.  It covers a large number of topics and has been fully updated to the latest version of Ruby. &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
==Programming Ruby:  The Pragmatic Programmers’ Guide==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Addison Longman&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.rubycentral.com/pickaxe&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  2001&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Intermediate&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded examples in text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This tutorial is available only online as a webpage.  Each item in the table of contents covers a large section of material and sometimes makes it a bit difficult to find a specific topic of choice.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:ToStringExample.jpg|thumb|To String Definition Example]]&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby: The Pragmatic Programmers’ Guide.  This webpage is based on the first edition of the book which covers the older version of Ruby 1.8.  The tutorial covers a wide range of introductory and advanced topics but also includes more unique topics such as Ruby TK, Threads, Ruby’s Standard Library, Network Libraries, and more.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The layout of the tutorial is easy to follow and is logically ordered.  The tutorial contains an extensive number of example code embedded in it and has the advantage that the output of each is typically shown.  This makes it easier for the user to understand what to expect from the code without having to run it themselves.  Each example is also paired with an adequate description and clarification of the subject.  No photos are typically used to portray concepts but instead the use of the examples provide the user with the understanding needed.  To the right is a sample example from the tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Overall the page is a good tutorial on Ruby 1.8 but can be a bit mundane at times.  The examples are straight forward and easy to understand but can sometimes feel like reading straight from the Ruby API.  The main advantage is the amount of topics covered which are very unique compared to other tutorials.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Little Book of Ruby==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Huw Collingbourne&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.sapphiresteel.com/The-Little-Book-Of-Ruby&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  June 17th, 2006&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner - Intermediate&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Available for download online&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Little Book of Ruby tutorial is a PDF (link) available free online for download.  The added convenience of the tutorial being in PDF format makes it easily viewable when not connected to the internet.  &lt;br /&gt;
&lt;br /&gt;
[[Image:SampleAside.jpg|thumb|Sample Aside From the Tutorial]]&lt;br /&gt;
This tutorial is a very structured guide to learning ruby and has great flow between topics.  It is geared towards individuals who are just beginning to learn programming and may not have a solid understanding of basic programming constructs.  The material covers more basic topics involving basic method declarations, basic data structures, loops and control statements, as well as an introduction to classes and their usage.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author injects a number of aside boxes that introduce the user into the subtleties of the language.  This can help the user understand the major advantages of this language over others.  To the right is an example of an aside in the book.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author does no use a large number of photos but does use them for more difficult to visualize concepts.  The rest of the material has very solidly written clarifications for the topics to help prevent the need for visualization.  The author also includes vocabulary definitions making it easier for novice users to understand the material.  Overall this is a great tutorial for beginner to intermediate programmers to learn ruby.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby’s User Guide==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Mark Slagell&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.rubyist.net/~slagell/ruby/&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  2005&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded into the tutorial.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Ruby’s User Guide is available online as a webpage and is not available for download.  But the general layout of the website makes it very easy to navigate and utilize.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:FactorExample.jpg|thumb|Sample Factor Code]]&lt;br /&gt;
The tutorial itself is not a structured as majority of the others covered in this Wikipedia, but is more of a subject based topic coverage.  The user has the option to jump around easily and learn specific topics that they may be interested in.  This is great for more advanced users that wish to learn specific things, but can hinder learning for newer programmers since it is not as structured.  The material covers from basic to advanced topics involving basic method declarations, basic data structures, loops and control statements, classes, regular expressions, iterators, inheritance, method redefinitions, exceptions and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author uses a number of examples within the tutorial to help the users understand topics and some of the subtleties of the language.  These can be invaluable to learning ruby but the drawback is that explanations are many times not adequate and can leave the user to interpret the results for themselves.  This may be due to the fact that the document was originally translated from Japanese.  To the right is an example of code take from the webpage.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The entire tutorial seems to be more useful to more advanced users that know how to program already.  The main advantages of the guide is that it covers more advanced topics not normally found in tutorials and covers many unique attributes to the Ruby programming language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby Quick Reference==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Ryan Davis&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.zenspider.com/Languages/Ruby/QuickRef.html&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:''' Sept. 13th, 2009&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Intermediate – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded Syntax Examples&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Ruby Quick Reference is available only online but can easily be saved as a single webpage for offline viewing.  The website is a bit more difficult to navigate since the entire listing is on a single page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:ClassDefine.jpg|thumb|Class Definition Example]]&lt;br /&gt;
This is not a conventional tutorial as it has little or no descriptions on each of the topics.  The purpose of this tutorial is to supply the user with the syntax of the Ruby language.  This reference is designed for intermediate to advanced users that know how the language works but are unfamiliar with the syntax.  It covers simple things from basic class definitions all the way to more advanced topics such as environment variables, exceptions, standard library modules, testing, and debugger controls.  To the right is an example taken from the webpage on syntax for defining a class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Overall this is not a tutorial at all but more of a guide on syntax in the Ruby Language.  While this is not a tutorial it is listed here because it is a valuable learning tool as it gives the users a quick way to look up programming examples.  This is ideal for users that have already used one of the previous tutorials and understand the Ruby language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
&lt;br /&gt;
All of the listed examples have a number of advantages over the others, the key to choosing one is based on the users specific needs.  One of the major differences between tutorials usually relates to the type of examples and how they are incorporated into learning.  The other main difference is the range of topics covered.  While majority of the tutorials here cover the same introductory and intermediate topics, they differ greatly on the more advanced topics.  Pay close attention to the advanced topics that may be of use for you when choosing a tutorial.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last thing to keep in mind is the last time the tutorials have been updated.  A few of the tutorials only cover Ruby 1.8 which has subtle differences from the newest version of Ruby.  While this may not be a problem for most users it is something to keep in mind while choosing a tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
[1] http://www.rubycentral.com/pickaxe/&lt;br /&gt;
&lt;br /&gt;
[2] http://rubylearning.com/satishtalim/tutorial.html&lt;br /&gt;
&lt;br /&gt;
[3] http://www.sapphiresteel.com/The-Little-Book-Of-Ruby&lt;br /&gt;
&lt;br /&gt;
[4] http://www.rubyist.net/~slagell/ruby/index.html&lt;br /&gt;
&lt;br /&gt;
[5] http://www.zenspider.com/Languages/Ruby/QuickRef.html&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:ToStringExample.jpg&amp;diff=21045</id>
		<title>File:ToStringExample.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:ToStringExample.jpg&amp;diff=21045"/>
		<updated>2009-09-21T15:44:08Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: To String Definition Example from the Ruby Programming Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To String Definition Example from the Ruby Programming Tutorial&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:MethodDefine.jpg&amp;diff=21044</id>
		<title>File:MethodDefine.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:MethodDefine.jpg&amp;diff=21044"/>
		<updated>2009-09-21T15:43:37Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: A Method Definition Example from the Core Ruby Programming Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A Method Definition Example from the Core Ruby Programming Tutorial&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:SampleAside.jpg&amp;diff=21038</id>
		<title>File:SampleAside.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:SampleAside.jpg&amp;diff=21038"/>
		<updated>2009-09-21T15:35:52Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: Example Aside from the Little Book of Ruby Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Example Aside from the Little Book of Ruby Tutorial&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:FactorExample.jpg&amp;diff=21037</id>
		<title>File:FactorExample.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:FactorExample.jpg&amp;diff=21037"/>
		<updated>2009-09-21T15:33:56Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: A sample of factoring code listed in the Ruby Users Guide Tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A sample of factoring code listed in the Ruby Users Guide Tutorial&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=21032</id>
		<title>CSC/ECE 517 Fall 2009/wiki1b 7 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=21032"/>
		<updated>2009-09-21T15:26:35Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
=Resources For Ruby=&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Learning a new program language can sometimes prove to be very difficult especially if the language has new programming concepts that the user has never previously learned.  Such an example would be moving from C to C++ and the introduction of classes and all they have to offer.  [http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 Ruby] is a language that has a number of special features not commonly found in most programming languages and sometimes can be difficult to learn, especially from [http://en.wikipedia.org/wiki/Integrated_development_environment Integrated Development Environment (IDE)].  In this page we hope to introduce the reader to a number of Ruby tutorials and give an understanding of the tutorials strengths.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Tutorial Overview=&lt;br /&gt;
&lt;br /&gt;
Every tutorial has one common goal and that is to supply some form of informative material about the Ruby programming language, but some can be better than others.  In our descriptions we try to remain objective about the contents of each tutorial and try to introduce personal opinions only when clarifications may be needed.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Core Ruby Programming==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Erwin Aligam&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://rubylearning.com/satishtalim/tutorial.html&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  Aug. 1st, 2008&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded examples in text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is a tutorial available only online as a webpage.  It is fairly simple to navigate but the website has a number of ads on the page and can sometimes make the usage a bit cumbersome.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby 1.9: The Pragmatic Programmers’ Guide and follows the structure fairly closely.  It has been fully updated to the newest version of Ruby as covered in the book and contains an informal install guide for Ruby making it easier for newer users.  The tutorial covers a variety of introductory topics and continues to more advanced topics such as Inheritance, Overloading Methods, Exceptions, Duck Typing, and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial contains embedded examples which are very simple and straight forward.  These aid in user learning, but the examples typically do not display the output or results.  This can be confusing and requires the user to run the code for themselves to gain an understanding of the code and what it does.  Below is an example of the embedded programming sample:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Example from page&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A major advantage of the tutorial is that it displays embedded links to Ruby’s API pages for the user.  This can supplement the users knowledge of method availability in the standard API.  The author uses pictures and figures for more challenging object-oriented constructs as well as in depth descriptions that explain concepts efficiently.  Also the author supplies summaries at the end of each section which allow the material to be assimilated by repetition.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over all the tutorial is very versatile and has the added advantage that it was produced from a renown book in the Ruby programming language.  It covers a large number of topics and has been fully updated to the latest version of Ruby. &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
==Programming Ruby:  The Pragmatic Programmers’ Guide==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Addison Longman&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.rubycentral.com/pickaxe&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  2001&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Intermediate&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded examples in text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This tutorial is available only online as a webpage.  Each item in the table of contents covers a large section of material and sometimes makes it a bit difficult to find a specific topic of choice.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby: The Pragmatic Programmers’ Guide.  This webpage is based on the first edition of the book which covers the older version of Ruby 1.8.  The tutorial covers a wide range of introductory and advanced topics but also includes more unique topics such as Ruby TK, Threads, Ruby’s Standard Library, Network Libraries, and more.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The layout of the tutorial is easy to follow and is logically ordered.  The tutorial contains an extensive number of example code embedded in it and has the advantage that the output of each is typically shown.  This makes it easier for the user to understand what to expect from the code without having to run it themselves.  Each example is also paired with an adequate description and clarification of the subject.  No photos are typically used to portray concepts but instead the use of the examples provide the user with the understanding needed.  Below is a sample example from the tutorial:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;example from page&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Overall the page is a good tutorial on Ruby 1.8 but can be a bit mundane at times.  The examples are straight forward and easy to understand but can sometimes feel like reading straight from the Ruby API.  The main advantage is the amount of topics covered which are very unique compared to other tutorials.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Little Book of Ruby==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Huw Collingbourne&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.sapphiresteel.com/The-Little-Book-Of-Ruby&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  June 17th, 2006&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner - Intermediate&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Available for download online&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Little Book of Ruby tutorial is a PDF (link) available free online for download.  The added convenience of the tutorial being in PDF format makes it easily viewable when not connected to the internet.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This tutorial is a very structured guide to learning ruby and has great flow between topics.  It is geared towards individuals who are just beginning to learn programming and may not have a solid understanding of basic programming constructs.  The material covers more basic topics involving basic method declarations, basic data structures, loops and control statements, as well as an introduction to classes and their usage.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author injects a number of aside boxes that introduce the user into the subtleties of the language.  This can help the user understand the major advantages of this language over others.  Below is an example of an aside in the book:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Example from bottom of page 32&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author does no use a large number of photos but does use them for more difficult to visualize concepts.  The rest of the material has very solidly written clarifications for the topics to help prevent the need for visualization.  The author also includes vocabulary definitions making it easier for novice users to understand the material.  Overall this is a great tutorial for beginner to intermediate programmers to learn ruby.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby’s User Guide==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Mark Slagell&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.rubyist.net/~slagell/ruby/&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  2005&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded into the tutorial.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Ruby’s User Guide is available online as a webpage and is not available for download.  But the general layout of the website makes it very easy to navigate and utilize.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial itself is not a structured as majority of the others covered in this Wikipedia, but is more of a subject based topic coverage.  The user has the option to jump around easily and learn specific topics that they may be interested in.  This is great for more advanced users that wish to learn specific things, but can hinder learning for newer programmers since it is not as structured.  The material covers from basic to advanced topics involving basic method declarations, basic data structures, loops and control statements, classes, regular expressions, iterators, inheritance, method redefinitions, exceptions and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author uses a number of examples within the tutorial to help the users understand topics and some of the subtleties of the language.  These can be invaluable to learning ruby but the drawback is that explanations are many times not adequate and can leave the user to interpret the results for themselves.  This may be due to the fact that the document was originally translated from Japanese.  Below is an example of code take from the webpage:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Example Code from Page&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The entire tutorial seems to be more useful to more advanced users that know how to program already.  The main advantages of the guide is that it covers more advanced topics not normally found in tutorials and covers many unique attributes to the Ruby programming language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby Quick Reference==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Ryan Davis&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.zenspider.com/Languages/Ruby/QuickRef.html&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:''' Sept. 13th, 2009&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Intermediate – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded Syntax Examples&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Ruby Quick Reference is available only online but can easily be saved as a single webpage for offline viewing.  The website is a bit more difficult to navigate since the entire listing is on a single page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:ClassDefine.jpg|thumb|Class Definition Example]]&lt;br /&gt;
This is not a conventional tutorial as it has little or no descriptions on each of the topics.  The purpose of this tutorial is to supply the user with the syntax of the Ruby language.  This reference is designed for intermediate to advanced users that know how the language works but are unfamiliar with the syntax.  It covers simple things from basic class definitions all the way to more advanced topics such as environment variables, exceptions, standard library modules, testing, and debugger controls.  Below is an example taken from the webpage on syntax for defining a class:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Overall this is not a tutorial at all but more of a guide on syntax in the Ruby Language.  While this is not a tutorial it is listed here because it is a valuable learning tool as it gives the users a quick way to look up programming examples.  This is ideal for users that have already used one of the previous tutorials and understand the Ruby language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
&lt;br /&gt;
All of the listed examples have a number of advantages over the others, the key to choosing one is based on the users specific needs.  One of the major differences between tutorials usually relates to the type of examples and how they are incorporated into learning.  The other main difference is the range of topics covered.  While majority of the tutorials here cover the same introductory and intermediate topics, they differ greatly on the more advanced topics.  Pay close attention to the advanced topics that may be of use for you when choosing a tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
[1] http://www.rubycentral.com/pickaxe/&lt;br /&gt;
&lt;br /&gt;
[2] http://rubylearning.com/satishtalim/tutorial.html&lt;br /&gt;
&lt;br /&gt;
[3] http://www.sapphiresteel.com/The-Little-Book-Of-Ruby&lt;br /&gt;
&lt;br /&gt;
[4] http://www.rubyist.net/~slagell/ruby/index.html&lt;br /&gt;
&lt;br /&gt;
[5] http://www.zenspider.com/Languages/Ruby/QuickRef.html&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:ClassDefine.jpg&amp;diff=21030</id>
		<title>File:ClassDefine.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:ClassDefine.jpg&amp;diff=21030"/>
		<updated>2009-09-21T15:26:22Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: This is an example from the Ruby Quick Reference Guide for syntax on how to declare a class in Ruby.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is an example from the Ruby Quick Reference Guide for syntax on how to declare a class in Ruby.&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=21028</id>
		<title>CSC/ECE 517 Fall 2009/wiki1b 7 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=21028"/>
		<updated>2009-09-21T15:20:54Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Resources For Ruby=&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Learning a new program language can sometimes prove to be very difficult especially if the language has new programming concepts that the user has never previously learned.  Such an example would be moving from C to C++ and the introduction of classes and all they have to offer.  [http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 Ruby] is a language that has a number of special features not commonly found in most programming languages and sometimes can be difficult to learn, especially from [http://en.wikipedia.org/wiki/Integrated_development_environment Integrated Development Environment (IDE)].  In this page we hope to introduce the reader to a number of Ruby tutorials and give an understanding of the tutorials strengths.&lt;br /&gt;
&lt;br /&gt;
=Tutorial Overview=&lt;br /&gt;
&lt;br /&gt;
Every tutorial has one common goal and that is to supply some form of informative material about the Ruby programming language, but some can be better than others.  In our descriptions we try to remain objective about the contents of each tutorial and try to introduce personal opinions only when clarifications may be needed.  &lt;br /&gt;
 &lt;br /&gt;
==Core Ruby Programming==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Erwin Aligam&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://rubylearning.com/satishtalim/tutorial.html&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  Aug. 1st, 2008&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded examples in text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is a tutorial available only online as a webpage.  It is fairly simple to navigate but the website has a number of ads on the page and can sometimes make the usage a bit cumbersome.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby 1.9: The Pragmatic Programmers’ Guide and follows the structure fairly closely.  It has been fully updated to the newest version of Ruby as covered in the book and contains an informal install guide for Ruby making it easier for newer users.  The tutorial covers a variety of introductory topics and continues to more advanced topics such as Inheritance, Overloading Methods, Exceptions, Duck Typing, and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial contains embedded examples which are very simple and straight forward.  These aid in user learning, but the examples typically do not display the output or results.  This can be confusing and requires the user to run the code for themselves to gain an understanding of the code and what it does.  Below is an example of the embedded programming sample:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Example from page&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A major advantage of the tutorial is that it displays embedded links to Ruby’s API pages for the user.  This can supplement the users knowledge of method availability in the standard API.  The author uses pictures and figures for more challenging object-oriented constructs as well as in depth descriptions that explain concepts efficiently.  Also the author supplies summaries at the end of each section which allow the material to be assimilated by repetition.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over all the tutorial is very versatile and has the added advantage that it was produced from a renown book in the Ruby programming language.  It covers a large number of topics and has been fully updated to the latest version of Ruby. &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
==Programming Ruby:  The Pragmatic Programmers’ Guide==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Addison Longman&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.rubycentral.com/pickaxe&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  2001&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Intermediate&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded examples in text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This tutorial is available only online as a webpage.  Each item in the table of contents covers a large section of material and sometimes makes it a bit difficult to find a specific topic of choice.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby: The Pragmatic Programmers’ Guide.  This webpage is based on the first edition of the book which covers the older version of Ruby 1.8.  The tutorial covers a wide range of introductory and advanced topics but also includes more unique topics such as Ruby TK, Threads, Ruby’s Standard Library, Network Libraries, and more.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The layout of the tutorial is easy to follow and is logically ordered.  The tutorial contains an extensive number of example code embedded in it and has the advantage that the output of each is typically shown.  This makes it easier for the user to understand what to expect from the code without having to run it themselves.  Each example is also paired with an adequate description and clarification of the subject.  No photos are typically used to portray concepts but instead the use of the examples provide the user with the understanding needed.  Below is a sample example from the tutorial:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;example from page&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Overall the page is a good tutorial on Ruby 1.8 but can be a bit mundane at times.  The examples are straight forward and easy to understand but can sometimes feel like reading straight from the Ruby API.  The main advantage is the amount of topics covered which are very unique compared to other tutorials.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Little Book of Ruby==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Huw Collingbourne&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.sapphiresteel.com/The-Little-Book-Of-Ruby&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  June 17th, 2006&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner - Intermediate&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Available for download online&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Little Book of Ruby tutorial is a PDF (link) available free online for download.  The added convenience of the tutorial being in PDF format makes it easily viewable when not connected to the internet.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This tutorial is a very structured guide to learning ruby and has great flow between topics.  It is geared towards individuals who are just beginning to learn programming and may not have a solid understanding of basic programming constructs.  The material covers more basic topics involving basic method declarations, basic data structures, loops and control statements, as well as an introduction to classes and their usage.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author injects a number of aside boxes that introduce the user into the subtleties of the language.  This can help the user understand the major advantages of this language over others.  Below is an example of an aside in the book:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Example from bottom of page 32&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author does no use a large number of photos but does use them for more difficult to visualize concepts.  The rest of the material has very solidly written clarifications for the topics to help prevent the need for visualization.  The author also includes vocabulary definitions making it easier for novice users to understand the material.  Overall this is a great tutorial for beginner to intermediate programmers to learn ruby.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby’s User Guide==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Mark Slagell&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.rubyist.net/~slagell/ruby/&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  2005&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded into the tutorial.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Ruby’s User Guide is available online as a webpage and is not available for download.  But the general layout of the website makes it very easy to navigate and utilize.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial itself is not a structured as majority of the others covered in this Wikipedia, but is more of a subject based topic coverage.  The user has the option to jump around easily and learn specific topics that they may be interested in.  This is great for more advanced users that wish to learn specific things, but can hinder learning for newer programmers since it is not as structured.  The material covers from basic to advanced topics involving basic method declarations, basic data structures, loops and control statements, classes, regular expressions, iterators, inheritance, method redefinitions, exceptions and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author uses a number of examples within the tutorial to help the users understand topics and some of the subtleties of the language.  These can be invaluable to learning ruby but the drawback is that explanations are many times not adequate and can leave the user to interpret the results for themselves.  This may be due to the fact that the document was originally translated from Japanese.  Below is an example of code take from the webpage:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Example Code from Page&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The entire tutorial seems to be more useful to more advanced users that know how to program already.  The main advantages of the guide is that it covers more advanced topics not normally found in tutorials and covers many unique attributes to the Ruby programming language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby Quick Reference==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Ryan Davis&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.zenspider.com/Languages/Ruby/QuickRef.html&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:''' Sept. 13th, 2009&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Intermediate – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded Syntax Examples&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Ruby Quick Reference is available only online but can easily be saved as a single webpage for offline viewing.  The website is a bit more difficult to navigate since the entire listing is on a single page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is not a conventional tutorial as it has little or no descriptions on each of the topics.  The purpose of this tutorial is to supply the user with the syntax of the Ruby language.  This reference is designed for intermediate to advanced users that know how the language works but are unfamiliar with the syntax.  It covers simple things from basic class definitions all the way to more advanced topics such as environment variables, exceptions, standard library modules, testing, and debugger controls.  Below is an example taken from the webpage on syntax for defining a class:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;class example&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Overall this is not a tutorial at all but more of a guide on syntax in the Ruby Language.  While this is not a tutorial it is listed here because it is a valuable learning tool as it gives the users a quick way to look up programming examples.  This is ideal for users that have already used one of the previous tutorials and understand the Ruby language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
&lt;br /&gt;
All of the listed examples have a number of advantages over the others, the key to choosing one is based on the users specific needs.  One of the major differences between tutorials usually relates to the type of examples and how they are incorporated into learning.  The other main difference is the range of topics covered.  While majority of the tutorials here cover the same introductory and intermediate topics, they differ greatly on the more advanced topics.  Pay close attention to the advanced topics that may be of use for you when choosing a tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
&lt;br /&gt;
[1] http://www.rubycentral.com/pickaxe/&lt;br /&gt;
&lt;br /&gt;
[2] http://rubylearning.com/satishtalim/tutorial.html&lt;br /&gt;
&lt;br /&gt;
[3] http://www.sapphiresteel.com/The-Little-Book-Of-Ruby&lt;br /&gt;
&lt;br /&gt;
[4] http://www.rubyist.net/~slagell/ruby/index.html&lt;br /&gt;
&lt;br /&gt;
[5] http://www.zenspider.com/Languages/Ruby/QuickRef.html&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=21025</id>
		<title>CSC/ECE 517 Fall 2009/wiki1b 7 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=21025"/>
		<updated>2009-09-21T15:16:22Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Resources For Ruby=&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Learning a new program language can sometimes prove to be very difficult especially if the language has new programming concepts that the user has never previously learned.  Such an example would be moving from C to C++ and the introduction of classes and all they have to offer.  [http://en.wikipedia.org/wiki/Ruby_%28programming_language%29 Ruby] is a language that has a number of special features not commonly found in most programming languages and sometimes can be difficult to learn, especially from [http://en.wikipedia.org/wiki/Integrated_development_environment Integrated Development Environment (IDE)].  In this page we hope to introduce the reader to a number of Ruby tutorials and give an understanding of the tutorials strengths.&lt;br /&gt;
&lt;br /&gt;
=Tutorial Overview=&lt;br /&gt;
&lt;br /&gt;
Every tutorial has one common goal and that is to supply some form of informative material about the Ruby programming language, but some can be better than others.  In our descriptions we try to remain objective about the contents of each tutorial and try to introduce personal opinions only when clarifications may be needed.  &lt;br /&gt;
 &lt;br /&gt;
==Core Ruby Programming==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Erwin Aligam&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://rubylearning.com/satishtalim/tutorial.html&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  Aug. 1st, 2008&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded examples in text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is a tutorial available only online as a webpage.  It is fairly simple to navigate but the website has a number of ads on the page and can sometimes make the usage a bit cumbersome.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby 1.9: The Pragmatic Programmers’ Guide and follows the structure fairly closely.  It has been fully updated to the newest version of Ruby as covered in the book and contains an informal install guide for Ruby making it easier for newer users.  The tutorial covers a variety of introductory topics and continues to more advanced topics such as Inheritance, Overloading Methods, Exceptions, Duck Typing, and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial contains embedded examples which are very simple and straight forward.  These aid in user learning, but the examples typically do not display the output or results.  This can be confusing and requires the user to run the code for themselves to gain an understanding of the code and what it does.  Below is an example of the embedded programming sample:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Example from page&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A major advantage of the tutorial is that it displays embedded links to Ruby’s API pages for the user.  This can supplement the users knowledge of method availability in the standard API.  The author uses pictures and figures for more challenging object-oriented constructs as well as in depth descriptions that explain concepts efficiently.  Also the author supplies summaries at the end of each section which allow the material to be assimilated by repetition.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over all the tutorial is very versatile and has the added advantage that it was produced from a renown book in the Ruby programming language.  It covers a large number of topics and has been fully updated to the latest version of Ruby. &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
==Programming Ruby:  The Pragmatic Programmers’ Guide==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Addison Longman&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.rubycentral.com/pickaxe&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  2001&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Intermediate&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded examples in text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This tutorial is available only online as a webpage.  Each item in the table of contents covers a large section of material and sometimes makes it a bit difficult to find a specific topic of choice.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby: The Pragmatic Programmers’ Guide.  This webpage is based on the first edition of the book which covers the older version of Ruby 1.8.  The tutorial covers a wide range of introductory and advanced topics but also includes more unique topics such as Ruby TK, Threads, Ruby’s Standard Library, Network Libraries, and more.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The layout of the tutorial is easy to follow and is logically ordered.  The tutorial contains an extensive number of example code embedded in it and has the advantage that the output of each is typically shown.  This makes it easier for the user to understand what to expect from the code without having to run it themselves.  Each example is also paired with an adequate description and clarification of the subject.  No photos are typically used to portray concepts but instead the use of the examples provide the user with the understanding needed.  Below is a sample example from the tutorial:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;example from page&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Overall the page is a good tutorial on Ruby 1.8 but can be a bit mundane at times.  The examples are straight forward and easy to understand but can sometimes feel like reading straight from the Ruby API.  The main advantage is the amount of topics covered which are very unique compared to other tutorials.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Little Book of Ruby==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Huw Collingbourne&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.sapphiresteel.com/The-Little-Book-Of-Ruby&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  June 17th, 2006&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner - Intermediate&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Available for download online&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Little Book of Ruby tutorial is a PDF (link) available free online for download.  The added convenience of the tutorial being in PDF format makes it easily viewable when not connected to the internet.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This tutorial is a very structured guide to learning ruby and has great flow between topics.  It is geared towards individuals who are just beginning to learn programming and may not have a solid understanding of basic programming constructs.  The material covers more basic topics involving basic method declarations, basic data structures, loops and control statements, as well as an introduction to classes and their usage.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author injects a number of aside boxes that introduce the user into the subtleties of the language.  This can help the user understand the major advantages of this language over others.  Below is an example of an aside in the book:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Example from bottom of page 32&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author does no use a large number of photos but does use them for more difficult to visualize concepts.  The rest of the material has very solidly written clarifications for the topics to help prevent the need for visualization.  The author also includes vocabulary definitions making it easier for novice users to understand the material.  Overall this is a great tutorial for beginner to intermediate programmers to learn ruby.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby’s User Guide==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Mark Slagell&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.rubyist.net/~slagell/ruby/&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:'''  2005&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Beginner – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded into the tutorial.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Ruby’s User Guide is available online as a webpage and is not available for download.  But the general layout of the website makes it very easy to navigate and utilize.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial itself is not a structured as majority of the others covered in this Wikipedia, but is more of a subject based topic coverage.  The user has the option to jump around easily and learn specific topics that they may be interested in.  This is great for more advanced users that wish to learn specific things, but can hinder learning for newer programmers since it is not as structured.  The material covers from basic to advanced topics involving basic method declarations, basic data structures, loops and control statements, classes, regular expressions, iterators, inheritance, method redefinitions, exceptions and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author uses a number of examples within the tutorial to help the users understand topics and some of the subtleties of the language.  These can be invaluable to learning ruby but the drawback is that explanations are many times not adequate and can leave the user to interpret the results for themselves.  This may be due to the fact that the document was originally translated from Japanese.  Below is an example of code take from the webpage:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Example Code from Page&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The entire tutorial seems to be more useful to more advanced users that know how to program already.  The main advantages of the guide is that it covers more advanced topics not normally found in tutorials and covers many unique attributes to the Ruby programming language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby Quick Reference==&lt;br /&gt;
&lt;br /&gt;
'''Author:'''  Ryan Davis&amp;lt;br&amp;gt;&lt;br /&gt;
'''Website:'''  http://www.zenspider.com/Languages/Ruby/QuickRef.html&amp;lt;br&amp;gt;&lt;br /&gt;
'''Last Update:''' Sept. 13th, 2009&amp;lt;br&amp;gt;&lt;br /&gt;
'''Level:'''  Intermediate – Advanced&amp;lt;br&amp;gt;&lt;br /&gt;
'''Source Code:'''  Embedded Syntax Examples&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Ruby Quick Reference is available only online but can easily be saved as a single webpage for offline viewing.  The website is a bit more difficult to navigate since the entire listing is on a single page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is not a conventional tutorial as it has little or no descriptions on each of the topics.  The purpose of this tutorial is to supply the user with the syntax of the Ruby language.  This reference is designed for intermediate to advanced users that know how the language works but are unfamiliar with the syntax.  It covers simple things from basic class definitions all the way to more advanced topics such as environment variables, exceptions, standard library modules, testing, and debugger controls.  Below is an example taken from the webpage on syntax for defining a class:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;class example&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Overall this is not a tutorial at all but more of a guide on syntax in the Ruby Language.  While this is not a tutorial it is listed here because it is a valuable learning tool as it gives the users a quick way to look up programming examples.  This is ideal for users that have already used one of the previous tutorials and understand the Ruby language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
&lt;br /&gt;
All of the listed examples have a number of advantages over the others, the key to choosing one is based on the users specific needs.  One of the major differences between tutorials usually relates to the type of examples and how they are incorporated into learning.  The other main difference is the range of topics covered.  While majority of the tutorials here cover the same introductory and intermediate topics, they differ greatly on the more advanced topics.  Pay close attention to the advanced topics that may be of use for you when choosing a tutorial.&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=21018</id>
		<title>CSC/ECE 517 Fall 2009/wiki1b 7 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=21018"/>
		<updated>2009-09-21T15:09:01Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Resources For Ruby=&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Learning a new program language can sometimes prove to be very difficult especially if the language has new programming concepts that the user has never previously learned.  Such an example would be moving from C to C++ and the introduction of classes and all they have to offer.  Ruby language is a language that has a number of special features not commonly found in most programming languages and sometimes can be difficult to learn, especially from Integrated Development Environments (IDE).  In this page we hope to introduce the reader to a number of Ruby tutorials and give an understanding of the tutorials strengths.&lt;br /&gt;
&lt;br /&gt;
=Tutorial Overview=&lt;br /&gt;
&lt;br /&gt;
Every tutorial has one common goal and that is to supply some form of informative material about the Ruby programming language, but some can be better than others.  In our descriptions we try to remain objective about the contents of each tutorial and try to introduce personal opinions only when clarifications may be needed.  &lt;br /&gt;
 &lt;br /&gt;
==Core Ruby Programming==&lt;br /&gt;
&lt;br /&gt;
Author:  Erwin Aligam&lt;br /&gt;
Website:  http://rubylearning.com/satishtalim/tutorial.html&lt;br /&gt;
Last Update:  Aug. 1st, 2008&lt;br /&gt;
Level:  Beginner – Advanced&lt;br /&gt;
Source Code:  Embedded examples in text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is a tutorial available only online as a webpage.  It is fairly simple to navigate but the website has a number of ads on the page and can sometimes make the usage a bit cumbersome.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby 1.9: The Pragmatic Programmers’ Guide and follows the structure fairly closely.  It has been fully updated to the newest version of Ruby as covered in the book and contains an informal install guide for Ruby making it easier for newer users.  The tutorial covers a variety of introductory topics and continues to more advanced topics such as Inheritance, Overloading Methods, Exceptions, Duck Typing, and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial contains embedded examples which are very simple and straight forward.  These aid in user learning, but the examples typically do not display the output or results.  This can be confusing and requires the user to run the code for themselves to gain an understanding of the code and what it does.  Below is an example of the embedded programming sample:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Example from page&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A major advantage of the tutorial is that it displays embedded links to Ruby’s API pages for the user.  This can supplement the users knowledge of method availability in the standard API.  The author uses pictures and figures for more challenging object-oriented constructs as well as in depth descriptions that explain concepts efficiently.  Also the author supplies summaries at the end of each section which allow the material to be assimilated by repetition.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over all the tutorial is very versatile and has the added advantage that it was produced from a renown book in the Ruby programming language.  It covers a large number of topics and has been fully updated to the latest version of Ruby. &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
==Programming Ruby:  The Pragmatic Programmers’ Guide==&lt;br /&gt;
&lt;br /&gt;
Author:  Addison Longman&lt;br /&gt;
Website:  http://www.rubycentral.com/pickaxe&lt;br /&gt;
Last Update:  2001&lt;br /&gt;
Level:  Beginner – Intermediate&lt;br /&gt;
Source Code:  Embedded examples in text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This tutorial is available only online as a webpage.  Each item in the table of contents covers a large section of material and sometimes makes it a bit difficult to find a specific topic of choice.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby: The Pragmatic Programmers’ Guide.  This webpage is based on the first edition of the book which covers the older version of Ruby 1.8.  The tutorial covers a wide range of introductory and advanced topics but also includes more unique topics such as Ruby TK, Threads, Ruby’s Standard Library, Network Libraries, and more.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The layout of the tutorial is easy to follow and is logically ordered.  The tutorial contains an extensive number of example code embedded in it and has the advantage that the output of each is typically shown.  This makes it easier for the user to understand what to expect from the code without having to run it themselves.  Each example is also paired with an adequate description and clarification of the subject.  No photos are typically used to portray concepts but instead the use of the examples provide the user with the understanding needed.  Below is a sample example from the tutorial:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;example from page&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Overall the page is a good tutorial on Ruby 1.8 but can be a bit mundane at times.  The examples are straight forward and easy to understand but can sometimes feel like reading straight from the Ruby API.  The main advantage is the amount of topics covered which are very unique compared to other tutorials.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Little Book of Ruby==&lt;br /&gt;
&lt;br /&gt;
Author:  Huw Collingbourne&lt;br /&gt;
Website:  http://www.sapphiresteel.com/The-Little-Book-Of-Ruby&lt;br /&gt;
Last Update:  June 17th, 2006&lt;br /&gt;
Level:  Beginner - Intermediate&lt;br /&gt;
Source Code:  Available for download online&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Little Book of Ruby tutorial is a PDF (link) available free online for download.  The added convenience of the tutorial being in PDF format makes it easily viewable when not connected to the internet.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This tutorial is a very structured guide to learning ruby and has great flow between topics.  It is geared towards individuals who are just beginning to learn programming and may not have a solid understanding of basic programming constructs.  The material covers more basic topics involving basic method declarations, basic data structures, loops and control statements, as well as an introduction to classes and their usage.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author injects a number of aside boxes that introduce the user into the subtleties of the language.  This can help the user understand the major advantages of this language over others.  Below is an example of an aside in the book:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Example from bottom of page 32&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author does no use a large number of photos but does use them for more difficult to visualize concepts.  The rest of the material has very solidly written clarifications for the topics to help prevent the need for visualization.  The author also includes vocabulary definitions making it easier for novice users to understand the material.  Overall this is a great tutorial for beginner to intermediate programmers to learn ruby.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby’s User Guide==&lt;br /&gt;
&lt;br /&gt;
Author:  Mark Slagell&lt;br /&gt;
Website:  http://www.rubyist.net/~slagell/ruby/&lt;br /&gt;
Last Update:  2005&lt;br /&gt;
Level:  Beginner – Advanced&lt;br /&gt;
Source Code:  Embedded into the tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Ruby’s User Guide is available online as a webpage and is not available for download.  But the general layout of the website makes it very easy to navigate and utilize.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial itself is not a structured as majority of the others covered in this Wikipedia, but is more of a subject based topic coverage.  The user has the option to jump around easily and learn specific topics that they may be interested in.  This is great for more advanced users that wish to learn specific things, but can hinder learning for newer programmers since it is not as structured.  The material covers from basic to advanced topics involving basic method declarations, basic data structures, loops and control statements, classes, regular expressions, iterators, inheritance, method redefinitions, exceptions and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author uses a number of examples within the tutorial to help the users understand topics and some of the subtleties of the language.  These can be invaluable to learning ruby but the drawback is that explanations are many times not adequate and can leave the user to interpret the results for themselves.  This may be due to the fact that the document was originally translated from Japanese.  Below is an example of code take from the webpage:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Example Code from Page&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The entire tutorial seems to be more useful to more advanced users that know how to program already.  The main advantages of the guide is that it covers more advanced topics not normally found in tutorials and covers many unique attributes to the Ruby programming language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby Quick Reference==&lt;br /&gt;
&lt;br /&gt;
Author:  Ryan Davis&lt;br /&gt;
Website:  http://www.zenspider.com/Languages/Ruby/QuickRef.html&lt;br /&gt;
Last Update: Sept. 13th, 2009&lt;br /&gt;
Level:  Intermediate – Advanced&lt;br /&gt;
Source Code:  Embedded Syntax Examples&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Ruby Quick Reference is available only online but can easily be saved as a single webpage for offline viewing.  The website is a bit more difficult to navigate since the entire listing is on a single page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is not a conventional tutorial as it has little or no descriptions on each of the topics.  The purpose of this tutorial is to supply the user with the syntax of the Ruby language.  This reference is designed for intermediate to advanced users that know how the language works but are unfamiliar with the syntax.  It covers simple things from basic class definitions all the way to more advanced topics such as environment variables, exceptions, standard library modules, testing, and debugger controls.  Below is an example taken from the webpage on syntax for defining a class:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;class example&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Overall this is not a tutorial at all but more of a guide on syntax in the Ruby Language.  While this is not a tutorial it is listed here because it is a valuable learning tool as it gives the users a quick way to look up programming examples.  This is ideal for users that have already used one of the previous tutorials and understand the Ruby language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
&lt;br /&gt;
All of the listed examples have a number of advantages over the others, the key to choosing one is based on the users specific needs.  One of the major differences between tutorials usually relates to the type of examples and how they are incorporated into learning.  The other main difference is the range of topics covered.  While majority of the tutorials here cover the same introductory and intermediate topics, they differ greatly on the more advanced topics.  Pay close attention to the advanced topics that may be of use for you when choosing a tutorial.&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=21017</id>
		<title>CSC/ECE 517 Fall 2009/wiki1b 7 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=21017"/>
		<updated>2009-09-21T15:08:06Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Resources For Ruby=&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Learning a new program language can sometimes prove to be very difficult especially if the language has new programming concepts that the user has never previously learned.  Such an example would be moving from C to C++ and the introduction of classes and all they have to offer.  Ruby language is a language that has a number of special features not commonly found in most programming languages and sometimes can be difficult to learn, especially from Integrated Development Environments (IDE).  In this page we hope to introduce the reader to a number of Ruby tutorials and give an understanding of the tutorials strengths.&lt;br /&gt;
&lt;br /&gt;
=Tutorial Overview=&lt;br /&gt;
&lt;br /&gt;
Every tutorial has one common goal and that is to supply some form of informative material about the Ruby programming language, but some can be better than others.  In our descriptions we try to remain objective about the contents of each tutorial and try to introduce personal opinions only when clarifications may be needed.  &lt;br /&gt;
 &lt;br /&gt;
==Core Ruby Programming==&lt;br /&gt;
&lt;br /&gt;
Author:  Erwin Aligam&lt;br /&gt;
Website:  http://rubylearning.com/satishtalim/tutorial.html&lt;br /&gt;
Last Update:  Aug. 1st, 2008&lt;br /&gt;
Level:  Beginner – Advanced&lt;br /&gt;
Source Code:  Embedded examples in text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is a tutorial available only online as a webpage.  It is fairly simple to navigate but the website has a number of ads on the page and can sometimes make the usage a bit cumbersome.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby 1.9: The Pragmatic Programmers’ Guide and follows the structure fairly closely.  It has been fully updated to the newest version of Ruby as covered in the book and contains an informal install guide for Ruby making it easier for newer users.  The tutorial covers a variety of introductory topics and continues to more advanced topics such as Inheritance, Overloading Methods, Exceptions, Duck Typing, and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial contains embedded examples which are very simple and straight forward.  These aid in user learning, but the examples typically do not display the output or results.  This can be confusing and requires the user to run the code for themselves to gain an understanding of the code and what it does.  Below is an example of the embedded programming sample:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Example from page&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A major advantage of the tutorial is that it displays embedded links to Ruby’s API pages for the user.  This can supplement the users knowledge of method availability in the standard API.  The author uses pictures and figures for more challenging object-oriented constructs as well as in depth descriptions that explain concepts efficiently.  Also the author supplies summaries at the end of each section which allow the material to be assimilated by repetition.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Over all the tutorial is very versatile and has the added advantage that it was produced from a renown book in the Ruby programming language.  It covers a large number of topics and has been fully updated to the latest version of Ruby. &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
==Programming Ruby:  The Pragmatic Programmers’ Guide==&lt;br /&gt;
&lt;br /&gt;
Author:  Addison Longman&lt;br /&gt;
Website:  http://www.rubycentral.com/pickaxe&lt;br /&gt;
Last Update:  2001&lt;br /&gt;
Level:  Beginner – Intermediate&lt;br /&gt;
Source Code:  Embedded examples in text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This tutorial is available only online as a webpage.  Each item in the table of contents covers a large section of material and sometimes makes it a bit difficult to find a specific topic of choice.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby: The Pragmatic Programmers’ Guide.  This webpage is based on the first edition of the book which covers the older version of Ruby 1.8.  The tutorial covers a wide range of introductory and advanced topics but also includes more unique topics such as Ruby TK, Threads, Ruby’s Standard Library, Network Libraries, and more.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The layout of the tutorial is easy to follow and is logically ordered.  The tutorial contains an extensive number of example code embedded in it and has the advantage that the output of each is typically shown.  This makes it easier for the user to understand what to expect from the code without having to run it themselves.  Each example is also paired with an adequate description and clarification of the subject.  No photos are typically used to portray concepts but instead the use of the examples provide the user with the understanding needed.  Below is a sample example from the tutorial:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;example from page&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Overall the page is a good tutorial on Ruby 1.8 but can be a bit mundane at times.  The examples are straight forward and easy to understand but can sometimes feel like reading straight from the Ruby API.  The main advantage is the amount of topics covered which are very unique compared to other tutorials.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Little Book of Ruby==&lt;br /&gt;
&lt;br /&gt;
Author:  Huw Collingbourne&lt;br /&gt;
Website:  http://www.sapphiresteel.com/The-Little-Book-Of-Ruby&lt;br /&gt;
Last Update:  June 17th, 2006&lt;br /&gt;
Level:  Beginner - Intermediate&lt;br /&gt;
Source Code:  Available for download online&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Little Book of Ruby tutorial is a PDF (link) available free online for download.  The added convenience of the tutorial being in PDF format makes it easily viewable when not connected to the internet.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This tutorial is a very structured guide to learning ruby and has great flow between topics.  It is geared towards individuals who are just beginning to learn programming and may not have a solid understanding of basic programming constructs.  The material covers more basic topics involving basic method declarations, basic data structures, loops and control statements, as well as an introduction to classes and their usage.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author injects a number of aside boxes that introduce the user into the subtleties of the language.  This can help the user understand the major advantages of this language over others.  Below is an example of an aside in the book:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Example from bottom of page 32&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author does no use a large number of photos but does use them for more difficult to visualize concepts.  The rest of the material has very solidly written clarifications for the topics to help prevent the need for visualization.  The author also includes vocabulary definitions making it easier for novice users to understand the material.  Overall this is a great tutorial for beginner to intermediate programmers to learn ruby.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby’s User Guide==&lt;br /&gt;
&lt;br /&gt;
Author:  Mark Slagell&lt;br /&gt;
Website:  http://www.rubyist.net/~slagell/ruby/&lt;br /&gt;
Last Update:  2005&lt;br /&gt;
Level:  Beginner – Advanced&lt;br /&gt;
Source Code:  Embedded into the tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Ruby’s User Guide is available online as a webpage and is not available for download.  But the general layout of the website makes it very easy to navigate and utilize.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The tutorial itself is not a structured as majority of the others covered in this Wikipedia, but is more of a subject based topic coverage.  The user has the option to jump around easily and learn specific topics that they may be interested in.  This is great for more advanced users that wish to learn specific things, but can hinder learning for newer programmers since it is not as structured.  The material covers from basic to advanced topics involving basic method declarations, basic data structures, loops and control statements, classes, regular expressions, iterators, inheritance, method redefinitions, exceptions and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The author uses a number of examples within the tutorial to help the users understand topics and some of the subtleties of the language.  These can be invaluable to learning ruby but the drawback is that explanations are many times not adequate and can leave the user to interpret the results for themselves.  This may be due to the fact that the document was originally translated from Japanese.  Below is an example of code take from the webpage:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code example&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The entire tutorial seems to be more useful to more advanced users that know how to program already.  The main advantages of the guide is that it covers more advanced topics not normally found in tutorials and covers many unique attributes to the Ruby programming language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby Quick Reference==&lt;br /&gt;
&lt;br /&gt;
Author:  Ryan Davis&lt;br /&gt;
Website:  http://www.zenspider.com/Languages/Ruby/QuickRef.html&lt;br /&gt;
Last Update: Sept. 13th, 2009&lt;br /&gt;
Level:  Intermediate – Advanced&lt;br /&gt;
Source Code:  Embedded Syntax Examples&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Ruby Quick Reference is available only online but can easily be saved as a single webpage for offline viewing.  The website is a bit more difficult to navigate since the entire listing is on a single page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is not a conventional tutorial as it has little or no descriptions on each of the topics.  The purpose of this tutorial is to supply the user with the syntax of the Ruby language.  This reference is designed for intermediate to advanced users that know how the language works but are unfamiliar with the syntax.  It covers simple things from basic class definitions all the way to more advanced topics such as environment variables, exceptions, standard library modules, testing, and debugger controls.  Below is an example taken from the webpage on syntax for defining a class:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;class example&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Overall this is not a tutorial at all but more of a guide on syntax in the Ruby Language.  While this is not a tutorial it is listed here because it is a valuable learning tool as it gives the users a quick way to look up programming examples.  This is ideal for users that have already used one of the previous tutorials and understand the Ruby language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
&lt;br /&gt;
All of the listed examples have a number of advantages over the others, the key to choosing one is based on the users specific needs.  One of the major differences between tutorials usually relates to the type of examples and how they are incorporated into learning.  The other main difference is the range of topics covered.  While majority of the tutorials here cover the same introductory and intermediate topics, they differ greatly on the more advanced topics.  Pay close attention to the advanced topics that may be of use for you when choosing a tutorial.&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=21014</id>
		<title>CSC/ECE 517 Fall 2009/wiki1b 7 aj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki1b_7_aj&amp;diff=21014"/>
		<updated>2009-09-21T15:06:27Z</updated>

		<summary type="html">&lt;p&gt;InteliSavant: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Resources For Ruby=&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
&lt;br /&gt;
Learning a new program language can sometimes prove to be very difficult especially if the language has new programming concepts that the user has never previously learned.  Such an example would be moving from C to C++ and the introduction of classes and all they have to offer.  Ruby language is a language that has a number of special features not commonly found in most programming languages and sometimes can be difficult to learn, especially from Integrated Development Environments (IDE).  In this page we hope to introduce the reader to a number of Ruby tutorials and give an understanding of the tutorials strengths.&lt;br /&gt;
&lt;br /&gt;
=Tutorial Overview=&lt;br /&gt;
&lt;br /&gt;
Every tutorial has one common goal and that is to supply some form of informative material about the Ruby programming language, but some can be better than others.  In our descriptions we try to remain objective about the contents of each tutorial and try to introduce personal opinions only when clarifications may be needed.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Core Ruby Programming==&lt;br /&gt;
&lt;br /&gt;
Author:  Erwin Aligam&lt;br /&gt;
Website:  http://rubylearning.com/satishtalim/tutorial.html&lt;br /&gt;
Last Update:  Aug. 1st, 2008&lt;br /&gt;
Level:  Beginner – Advanced&lt;br /&gt;
Source Code:  Embedded examples in text.&lt;br /&gt;
&lt;br /&gt;
This is a tutorial available only online as a webpage.  It is fairly simple to navigate but the website has a number of ads on the page and can sometimes make the usage a bit cumbersome.  &lt;br /&gt;
&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby 1.9: The Pragmatic Programmers’ Guide and follows the structure fairly closely.  It has been fully updated to the newest version of Ruby as covered in the book and contains an informal install guide for Ruby making it easier for newer users.  The tutorial covers a variety of introductory topics and continues to more advanced topics such as Inheritance, Overloading Methods, Exceptions, Duck Typing, and more.&lt;br /&gt;
&lt;br /&gt;
The tutorial contains embedded examples which are very simple and straight forward.  These aid in user learning, but the examples typically do not display the output or results.  This can be confusing and requires the user to run the code for themselves to gain an understanding of the code and what it does.  Below is an example of the embedded programming sample:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Example from page&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A major advantage of the tutorial is that it displays embedded links to Ruby’s API pages for the user.  This can supplement the users knowledge of method availability in the standard API.  The author uses pictures and figures for more challenging object-oriented constructs as well as in depth descriptions that explain concepts efficiently.  Also the author supplies summaries at the end of each section which allow the material to be assimilated by repetition.&lt;br /&gt;
&lt;br /&gt;
Over all the tutorial is very versatile and has the added advantage that it was produced from a renown book in the Ruby programming language.  It covers a large number of topics and has been fully updated to the latest version of Ruby. &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Programming Ruby:  The Pragmatic Programmers’ Guide==&lt;br /&gt;
&lt;br /&gt;
Author:  Addison Longman&lt;br /&gt;
Website:  http://www.rubycentral.com/pickaxe&lt;br /&gt;
Last Update:  2001&lt;br /&gt;
Level:  Beginner – Intermediate&lt;br /&gt;
Source Code:  Embedded examples in text.&lt;br /&gt;
&lt;br /&gt;
This tutorial is available only online as a webpage.  Each item in the table of contents covers a large section of material and sometimes makes it a bit difficult to find a specific topic of choice.&lt;br /&gt;
&lt;br /&gt;
The tutorial is extracted from the book Programming Ruby: The Pragmatic Programmers’ Guide.  This webpage is based on the first edition of the book which covers the older version of Ruby 1.8.  The tutorial covers a wide range of introductory and advanced topics but also includes more unique topics such as Ruby TK, Threads, Ruby’s Standard Library, Network Libraries, and more.  &lt;br /&gt;
&lt;br /&gt;
The layout of the tutorial is easy to follow and is logically ordered.  The tutorial contains an extensive number of example code embedded in it and has the advantage that the output of each is typically shown.  This makes it easier for the user to understand what to expect from the code without having to run it themselves.  Each example is also paired with an adequate description and clarification of the subject.  No photos are typically used to portray concepts but instead the use of the examples provide the user with the understanding needed.  Below is a sample example from the tutorial:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;example from page&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Overall the page is a good tutorial on Ruby 1.8 but can be a bit mundane at times.  The examples are straight forward and easy to understand but can sometimes feel like reading straight from the Ruby API.  The main advantage is the amount of topics covered which are very unique compared to other tutorials.  &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Little Book of Ruby==&lt;br /&gt;
&lt;br /&gt;
Author:  Huw Collingbourne&lt;br /&gt;
Website:  http://www.sapphiresteel.com/The-Little-Book-Of-Ruby&lt;br /&gt;
Last Update:  June 17th, 2006&lt;br /&gt;
Level:  Beginner - Intermediate&lt;br /&gt;
Source Code:  Available for download online&lt;br /&gt;
&lt;br /&gt;
The Little Book of Ruby tutorial is a PDF (link) available free online for download.  The added convenience of the tutorial being in PDF format makes it easily viewable when not connected to the internet.  &lt;br /&gt;
&lt;br /&gt;
This tutorial is a very structured guide to learning ruby and has great flow between topics.  It is geared towards individuals who are just beginning to learn programming and may not have a solid understanding of basic programming constructs.  The material covers more basic topics involving basic method declarations, basic data structures, loops and control statements, as well as an introduction to classes and their usage.  &lt;br /&gt;
&lt;br /&gt;
The author injects a number of aside boxes that introduce the user into the subtleties of the language.  This can help the user understand the major advantages of this language over others.  Below is an example of an aside in the book:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Example from bottom of page 32&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The author does no use a large number of photos but does use them for more difficult to visualize concepts.  The rest of the material has very solidly written clarifications for the topics to help prevent the need for visualization.  The author also includes vocabulary definitions making it easier for novice users to understand the material.  Overall this is a great tutorial for beginner to intermediate programmers to learn ruby.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby’s User Guide==&lt;br /&gt;
&lt;br /&gt;
Author:  Mark Slagell&lt;br /&gt;
Website:  http://www.rubyist.net/~slagell/ruby/&lt;br /&gt;
Last Update:  2005&lt;br /&gt;
Level:  Beginner – Advanced&lt;br /&gt;
Source Code:  Embedded into the tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Ruby’s User Guide is available online as a webpage and is not available for download.  But the general layout of the website makes it very easy to navigate and utilize.&lt;br /&gt;
&lt;br /&gt;
The tutorial itself is not a structured as majority of the others covered in this Wikipedia, but is more of a subject based topic coverage.  The user has the option to jump around easily and learn specific topics that they may be interested in.  This is great for more advanced users that wish to learn specific things, but can hinder learning for newer programmers since it is not as structured.  The material covers from basic to advanced topics involving basic method declarations, basic data structures, loops and control statements, classes, regular expressions, iterators, inheritance, method redefinitions, exceptions and more.&lt;br /&gt;
&lt;br /&gt;
The author uses a number of examples within the tutorial to help the users understand topics and some of the subtleties of the language.  These can be invaluable to learning ruby but the drawback is that explanations are many times not adequate and can leave the user to interpret the results for themselves.  This may be due to the fact that the document was originally translated from Japanese.  Below is an example of code take from the webpage:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code example&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The entire tutorial seems to be more useful to more advanced users that know how to program already.  The main advantages of the guide is that it covers more advanced topics not normally found in tutorials and covers many unique attributes to the Ruby programming language.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
==Ruby Quick Reference==&lt;br /&gt;
&lt;br /&gt;
Author:  Ryan Davis&lt;br /&gt;
Website:  http://www.zenspider.com/Languages/Ruby/QuickRef.html&lt;br /&gt;
Last Update: Sept. 13th, 2009&lt;br /&gt;
Level:  Intermediate – Advanced&lt;br /&gt;
Source Code:  Embedded Syntax Examples&lt;br /&gt;
&lt;br /&gt;
The Ruby Quick Reference is available only online but can easily be saved as a single webpage for offline viewing.  The website is a bit more difficult to navigate since the entire listing is on a single page.&lt;br /&gt;
&lt;br /&gt;
This is not a conventional tutorial as it has little or no descriptions on each of the topics.  The purpose of this tutorial is to supply the user with the syntax of the Ruby language.  This reference is designed for intermediate to advanced users that know how the language works but are unfamiliar with the syntax.  It covers simple things from basic class definitions all the way to more advanced topics such as environment variables, exceptions, standard library modules, testing, and debugger controls.  Below is an example taken from the webpage on syntax for defining a class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;class example&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Overall this is not a tutorial at all but more of a guide on syntax in the Ruby Language.  While this is not a tutorial it is listed here because it is a valuable learning tool as it gives the users a quick way to look up programming examples.  This is ideal for users that have already used one of the previous tutorials and understand the Ruby language.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
&lt;br /&gt;
All of the listed examples have a number of advantages over the others, the key to choosing one is based on the users specific needs.  One of the major differences between tutorials usually relates to the type of examples and how they are incorporated into learning.  The other main difference is the range of topics covered.  While majority of the tutorials here cover the same introductory and intermediate topics, they differ greatly on the more advanced topics.  Pay close attention to the advanced topics that may be of use for you when choosing a tutorial.&lt;/div&gt;</summary>
		<author><name>InteliSavant</name></author>
	</entry>
</feed>