<?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=Mrmanrin</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=Mrmanrin"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Mrmanrin"/>
	<updated>2026-07-01T06:27:05Z</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_2011/ch6_6b_mm&amp;diff=56201</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=56201"/>
		<updated>2011-11-22T18:10:57Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* Design by Contract */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Reasons For Subclassing==&lt;br /&gt;
&lt;br /&gt;
There are many different reasons out there for why subclassing is helpful:&lt;br /&gt;
&lt;br /&gt;
* '''Specialization''' - If an existing class has the basic functionality needed (ex: a circle class) but is missing some small details (say a method to determine the center of the circle), then subclassing is very useful. It allows the programmer to get most of the functionality needed and provides a means to specialize the superclass to fit the needs of the program.&amp;lt;ref&amp;gt;Skrien 2009&amp;lt;/ref&amp;gt; An good example of this is the inheritance that takes place within Java's AWT graphical components&amp;lt;ref&amp;gt;Budd 2004&amp;lt;/ref&amp;gt;. Each of the components you see within a GUI (Label, Button, Checkbox, etc.) are specialized versions of the Component class.&lt;br /&gt;
&lt;br /&gt;
* '''Generalization''' - Two classes that are very closely related to each other could have their common functionality pulled out into a superclass and then changed to implement that superclass. This provides the programmer with less code duplication and makes it easier if a change is needed to that common functionality later on&amp;lt;ref&amp;gt;Skrien 2009&amp;lt;/ref&amp;gt;. An example of this found on [http://sourcemaking.com/uml/modeling-it-systems/structural-view/generalization-specialization-and-inheritance SourceMaking.com] is the extraction of common information between a piece of luggage and a piece of cargo (identification, weight, ID number) into a superclass called freight and having the luggage and cargo classes extend the freight class&amp;lt;ref&amp;gt;SourceMaking.com&amp;lt;/ref&amp;gt;. This produces the generalized freight class and lets the luggage and cargo classes become specialized.&lt;br /&gt;
&lt;br /&gt;
* '''Polymorphism''' - Polymorphism is basically the utilization of a superclass type for a variable to hold a reference to an object whose class can be the supertype or any of its subtypes.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt; This is a great advantage since storing a subtype into that variable would still allow the program to function correctly. In the below example, a variable that is typed as a &amp;lt;tt&amp;gt;Fruit&amp;lt;/tt&amp;gt; could store the information for a &amp;lt;tt&amp;gt;Fruit&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Apple&amp;lt;/tt&amp;gt; or a &amp;lt;tt&amp;gt;Banana&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Fruit {&lt;br /&gt;
  // . . . . &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Apple extends Fruit {&lt;br /&gt;
  // . . .&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Banana extends Fruit {&lt;br /&gt;
  // . . .&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
var my_fruit:Fruit = new Apple();&lt;br /&gt;
 . . . &lt;br /&gt;
&lt;br /&gt;
// Oh wait, I wanted a banana instead...&lt;br /&gt;
my_fruit = new Banana();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Dynamic Binding''' - This feature of subclassing allows the code executor (ex: JVM for Java) to determine at runtime which version of an overridden method to execute. This is needed because sometimes the method to execute cannot be determined at compile-time.&lt;br /&gt;
&lt;br /&gt;
* '''Code Reuse''' - When a superclass is extended, the subclass inherits all of the methods and properties of the superclass. Code duplication is held to a minimum since the code is reused so effectively.&lt;br /&gt;
&lt;br /&gt;
* '''Overriding and Overloading''' - Overriding and overloading functionality in a subclass is a major draw of subclassing. These abilities allow the programmer to tweak specific methods of the superclass that are close to the desired functionality in order to get the functionality exactly right.&lt;br /&gt;
&lt;br /&gt;
==Reasons Not To Subclass==&lt;br /&gt;
&lt;br /&gt;
* '''Inherits Too Much''' - Sometimes a programmer only needs a subset of the functionality of class. Subclassing requires that all functionality be carried down to the subclass though, often resulting in a class that has a lot of unneeded functionality. If this is done more than once in a hierarchy, then subclasses can become too bulky very quickly.&lt;br /&gt;
&lt;br /&gt;
* '''Superclass Fragility''' - This issue arises because sometimes a small change in a superclass can sometimes have a ripple effect that forces changes to be made elsewhere in the code. This is usually due to poorly designed superclasses where there is not a clean separation between interface and implementation.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Weak Encapsulation''' - This idea crops up when a subclass utilizes functionality of the superclass as it is inherited, essentially creating a case where the code from the superclass is reused. However, if changes are made to that functionality in the superclass, it could break code that directly utilizes an instance of the subclass.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Forces Is-A Relationships''' - There is a time and a place for is-a relationships, but there are some in the field that believe &amp;quot;almost every is-a relationship would be better off re-articulated as a has-a relationship&amp;quot;&amp;lt;ref&amp;gt;Sumption 2011&amp;lt;/ref&amp;gt;. Instances where two subclass functionalities need to be combined make for a hard implementation using is-a relationships. As an example, lets take the classes that follow. If we came across an instance where a TA was also a student, it would be very hard to pull in the functionality of one into the other. Composition (using has-a relationships) is a better fit here so that a Person could have the functionality of a Student, a TA, or both.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Person {&lt;br /&gt;
  var name:String;&lt;br /&gt;
  &lt;br /&gt;
  function sayHello() { . . . }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Student extends Person {&lt;br /&gt;
  var student_id:int;&lt;br /&gt;
&lt;br /&gt;
  function payTuition() { . . . }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class TA extends Person {&lt;br /&gt;
  var class:String;&lt;br /&gt;
&lt;br /&gt;
  function gradeTest() { . . . }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Subclassing Principles==&lt;br /&gt;
&lt;br /&gt;
===Liskov Substitution Principle===&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;ref&amp;gt;Wikipedia - LSP&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, superclasses should be replaceable by their subclasses without altering the system in any way. This principle borrows ideas from the design by contract methodology by imposing restrictions on the conditions for which the methods of a class will function. It also restricts how subclass methods can be designed in terms of their return types (covariance) and method arguments (contravariance). These restrictions provide a very good ruleset to determine whether subclassing should be utilized or not.&lt;br /&gt;
&lt;br /&gt;
===Design by Contract===&lt;br /&gt;
&lt;br /&gt;
The Design by Contract principle has a direct application to subclassing in its definitions of pre- and postconditions that must exist on methods. Its main goal is to provide a method to define &amp;quot;formal, precise and verifiable interface specifications for software components&amp;quot; by utilizing the idea of preconditions, postconditions and invariants&amp;lt;ref&amp;gt;Wikipedia - DbC&amp;lt;/ref&amp;gt;. When used, it helps to guarantee the functionality of any software component.&lt;br /&gt;
&lt;br /&gt;
Following this principle allows a programmer to weaken preconditions and strengthen postconditions and invariants, but not vice versa. Utilizing these rules comes very close to mimicking the rules applied in the Liskov substitution principle.&lt;br /&gt;
&lt;br /&gt;
An example of how Design by Contract is implemented can be seen in a method that raises a number to a power (ex: 2^4 = 16)...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// @param base - float value to be exponentiated&lt;br /&gt;
// @param exponent - float number of times to exponentiate&lt;br /&gt;
// @returns float - value of exponentiation&lt;br /&gt;
function exponentiate (float base, float exponent) {&lt;br /&gt;
  // . . .&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this definition, the preconditions are defined by the arguments that are required by the method (base and exponent). The comments and the typing of the variables requires the values passed in to be floating-point numbers. It is the clients responsibility to ensure that it passes in floats and not a string or an array. The postconditions are defined by the return value for the method. The comments state that it will return an floating-point value representing the end result of the exponentiation.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Generalization, Specialization, and Inheritance&amp;quot; [http://sourcemaking.com/uml/modeling-it-systems/structural-view/generalization-specialization-and-inheritance http://sourcemaking.com/uml/modeling-it-systems/structural-view/generalization-specialization-and-inheritance]&lt;br /&gt;
&lt;br /&gt;
Budd, Timothy. &amp;quot;Introduction to Object Oriented Programming, 3rd Ed Slides&amp;quot;. [http://classes.engr.oregonstate.edu/eecs/winter2004/cs582/slides/chap08/slide16.htm http://classes.engr.oregonstate.edu/eecs/winter2004/cs582/slides/chap08/slide16.htm]. 2004&lt;br /&gt;
&lt;br /&gt;
Sumption, Bernie. &amp;quot;Inheritance is evil, and must be destroyed&amp;quot;. [http://berniesumption.com/software/inheritance-is-evil-and-must-be-destroyed/ http://berniesumption.com/software/inheritance-is-evil-and-must-be-destroyed/]. 2011&lt;br /&gt;
&lt;br /&gt;
Skrien, Dale. &amp;quot;Object-Oriented Design Using Java&amp;quot;. Boston: McGraw-Hill, 2009.&lt;br /&gt;
&lt;br /&gt;
Venners, Bill. &amp;quot;Inheritance versus composition: Which one should you choose?&amp;quot; [http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html]. 1998&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Design by Contract&amp;quot;. [http://en.wikipedia.org/wiki/Design_by_Contract http://en.wikipedia.org/wiki/Design_by_Contract]&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Liskov substitution principle&amp;quot;. [http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=56181</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=56181"/>
		<updated>2011-11-22T15:58:54Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* Reasons For Subclassing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Reasons For Subclassing==&lt;br /&gt;
&lt;br /&gt;
There are many different reasons out there for why subclassing is helpful:&lt;br /&gt;
&lt;br /&gt;
* '''Specialization''' - If an existing class has the basic functionality needed (ex: a circle class) but is missing some small details (say a method to determine the center of the circle), then subclassing is very useful. It allows the programmer to get most of the functionality needed and provides a means to specialize the superclass to fit the needs of the program.&amp;lt;ref&amp;gt;Skrien 2009&amp;lt;/ref&amp;gt; An good example of this is the inheritance that takes place within Java's AWT graphical components&amp;lt;ref&amp;gt;Budd 2004&amp;lt;/ref&amp;gt;. Each of the components you see within a GUI (Label, Button, Checkbox, etc.) are specialized versions of the Component class.&lt;br /&gt;
&lt;br /&gt;
* '''Generalization''' - Two classes that are very closely related to each other could have their common functionality pulled out into a superclass and then changed to implement that superclass. This provides the programmer with less code duplication and makes it easier if a change is needed to that common functionality later on&amp;lt;ref&amp;gt;Skrien 2009&amp;lt;/ref&amp;gt;. An example of this found on [http://sourcemaking.com/uml/modeling-it-systems/structural-view/generalization-specialization-and-inheritance SourceMaking.com] is the extraction of common information between a piece of luggage and a piece of cargo (identification, weight, ID number) into a superclass called freight and having the luggage and cargo classes extend the freight class&amp;lt;ref&amp;gt;SourceMaking.com&amp;lt;/ref&amp;gt;. This produces the generalized freight class and lets the luggage and cargo classes become specialized.&lt;br /&gt;
&lt;br /&gt;
* '''Polymorphism''' - Polymorphism is basically the utilization of a superclass type for a variable to hold a reference to an object whose class can be the supertype or any of its subtypes.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt; This is a great advantage since storing a subtype into that variable would still allow the program to function correctly. In the below example, a variable that is typed as a &amp;lt;tt&amp;gt;Fruit&amp;lt;/tt&amp;gt; could store the information for a &amp;lt;tt&amp;gt;Fruit&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Apple&amp;lt;/tt&amp;gt; or a &amp;lt;tt&amp;gt;Banana&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Fruit {&lt;br /&gt;
  // . . . . &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Apple extends Fruit {&lt;br /&gt;
  // . . .&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Banana extends Fruit {&lt;br /&gt;
  // . . .&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
var my_fruit:Fruit = new Apple();&lt;br /&gt;
 . . . &lt;br /&gt;
&lt;br /&gt;
// Oh wait, I wanted a banana instead...&lt;br /&gt;
my_fruit = new Banana();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Dynamic Binding''' - This feature of subclassing allows the code executor (ex: JVM for Java) to determine at runtime which version of an overridden method to execute. This is needed because sometimes the method to execute cannot be determined at compile-time.&lt;br /&gt;
&lt;br /&gt;
* '''Code Reuse''' - When a superclass is extended, the subclass inherits all of the methods and properties of the superclass. Code duplication is held to a minimum since the code is reused so effectively.&lt;br /&gt;
&lt;br /&gt;
* '''Overriding and Overloading''' - Overriding and overloading functionality in a subclass is a major draw of subclassing. These abilities allow the programmer to tweak specific methods of the superclass that are close to the desired functionality in order to get the functionality exactly right.&lt;br /&gt;
&lt;br /&gt;
==Reasons Not To Subclass==&lt;br /&gt;
&lt;br /&gt;
* '''Inherits Too Much''' - Sometimes a programmer only needs a subset of the functionality of class. Subclassing requires that all functionality be carried down to the subclass though, often resulting in a class that has a lot of unneeded functionality. If this is done more than once in a hierarchy, then subclasses can become too bulky very quickly.&lt;br /&gt;
&lt;br /&gt;
* '''Superclass Fragility''' - This issue arises because sometimes a small change in a superclass can sometimes have a ripple effect that forces changes to be made elsewhere in the code. This is usually due to poorly designed superclasses where there is not a clean separation between interface and implementation.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Weak Encapsulation''' - This idea crops up when a subclass utilizes functionality of the superclass as it is inherited, essentially creating a case where the code from the superclass is reused. However, if changes are made to that functionality in the superclass, it could break code that directly utilizes an instance of the subclass.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Forces Is-A Relationships''' - There is a time and a place for is-a relationships, but there are some in the field that believe &amp;quot;almost every is-a relationship would be better off re-articulated as a has-a relationship&amp;quot;&amp;lt;ref&amp;gt;Sumption 2011&amp;lt;/ref&amp;gt;. Instances where two subclass functionalities need to be combined make for a hard implementation using is-a relationships. As an example, lets take the classes that follow. If we came across an instance where a TA was also a student, it would be very hard to pull in the functionality of one into the other. Composition (using has-a relationships) is a better fit here so that a Person could have the functionality of a Student, a TA, or both.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Person {&lt;br /&gt;
  var name:String;&lt;br /&gt;
  &lt;br /&gt;
  function sayHello() { . . . }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Student extends Person {&lt;br /&gt;
  var student_id:int;&lt;br /&gt;
&lt;br /&gt;
  function payTuition() { . . . }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class TA extends Person {&lt;br /&gt;
  var class:String;&lt;br /&gt;
&lt;br /&gt;
  function gradeTest() { . . . }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Subclassing Principles==&lt;br /&gt;
&lt;br /&gt;
===Liskov Substitution Principle===&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;ref&amp;gt;Wikipedia - LSP&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, superclasses should be replaceable by their subclasses without altering the system in any way. This principle borrows ideas from the design by contract methodology by imposing restrictions on the conditions for which the methods of a class will function. It also restricts how subclass methods can be designed in terms of their return types (covariance) and method arguments (contravariance). These restrictions provide a very good ruleset to determine whether subclassing should be utilized or not.&lt;br /&gt;
&lt;br /&gt;
===Design by Contract===&lt;br /&gt;
&lt;br /&gt;
The Design by Contract principle has a direct application to subclassing in its definitions of pre- and postconditions that must exist on methods. Its main goal is to provide a method to define &amp;quot;formal, precise and verifiable interface specifications for software components&amp;quot; by utilizing the idea of preconditions, postconditions and invariants&amp;lt;ref&amp;gt;Wikipedia - DbC&amp;lt;/ref&amp;gt;. When used, it helps to guarantee the functionality of any software component.&lt;br /&gt;
&lt;br /&gt;
Following this principle allows a programmer to weaken preconditions and strengthen postconditions and invariants, but not vice versa. Utilizing these rules comes very close to mimicking the rules applied in the Liskov substitution principle.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Generalization, Specialization, and Inheritance&amp;quot; [http://sourcemaking.com/uml/modeling-it-systems/structural-view/generalization-specialization-and-inheritance http://sourcemaking.com/uml/modeling-it-systems/structural-view/generalization-specialization-and-inheritance]&lt;br /&gt;
&lt;br /&gt;
Budd, Timothy. &amp;quot;Introduction to Object Oriented Programming, 3rd Ed Slides&amp;quot;. [http://classes.engr.oregonstate.edu/eecs/winter2004/cs582/slides/chap08/slide16.htm http://classes.engr.oregonstate.edu/eecs/winter2004/cs582/slides/chap08/slide16.htm]. 2004&lt;br /&gt;
&lt;br /&gt;
Sumption, Bernie. &amp;quot;Inheritance is evil, and must be destroyed&amp;quot;. [http://berniesumption.com/software/inheritance-is-evil-and-must-be-destroyed/ http://berniesumption.com/software/inheritance-is-evil-and-must-be-destroyed/]. 2011&lt;br /&gt;
&lt;br /&gt;
Skrien, Dale. &amp;quot;Object-Oriented Design Using Java&amp;quot;. Boston: McGraw-Hill, 2009.&lt;br /&gt;
&lt;br /&gt;
Venners, Bill. &amp;quot;Inheritance versus composition: Which one should you choose?&amp;quot; [http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html]. 1998&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Design by Contract&amp;quot;. [http://en.wikipedia.org/wiki/Design_by_Contract http://en.wikipedia.org/wiki/Design_by_Contract]&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Liskov substitution principle&amp;quot;. [http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=56152</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=56152"/>
		<updated>2011-11-22T03:27:12Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Reasons For Subclassing==&lt;br /&gt;
&lt;br /&gt;
There are many different reasons out there for why subclassing is helpful:&lt;br /&gt;
&lt;br /&gt;
* '''Specialization''' - If an existing class has the basic functionality needed (ex: a circle class) but is missing some small details (say a method to determine the center of the circle), then subclassing is very useful. It allows the programmer to get most of the functionality needed and provides a means to specialize the superclass to fit the needs of the program.&amp;lt;ref&amp;gt;Skrien 2009&amp;lt;/ref&amp;gt; An good example of this is the inheritance that takes place within Java's AWT graphical components&amp;lt;ref&amp;gt;Budd 2004&amp;lt;/ref&amp;gt;. Each of the components you see within a GUI (Label, Button, Checkbox, etc.) are specialized versions of the Component class.&lt;br /&gt;
&lt;br /&gt;
* '''Generalization''' - Two classes that are very closely related to each other could have their common functionality pulled out into a superclass and then changed to implement that superclass. This provides the programmer with less code duplication and makes it easier if a change is needed to that common functionality later on.&amp;lt;ref&amp;gt;Skrien 2009&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Polymorphism''' - Polymorphism is basically the utilization of a superclass type for a variable to hold a reference to an object whose class can be the supertype or any of its subtypes.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt; This is a great advantage since storing a subtype into that variable would still allow the program to function correctly. In the below example, a variable that is typed as a &amp;lt;tt&amp;gt;Fruit&amp;lt;/tt&amp;gt; could store the information for a &amp;lt;tt&amp;gt;Fruit&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Apple&amp;lt;/tt&amp;gt; or a &amp;lt;tt&amp;gt;Banana&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Fruit {&lt;br /&gt;
  // . . . . &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Apple extends Fruit {&lt;br /&gt;
  // . . .&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Banana extends Fruit {&lt;br /&gt;
  // . . .&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
var my_fruit:Fruit = new Apple();&lt;br /&gt;
 . . . &lt;br /&gt;
&lt;br /&gt;
// Oh wait, I wanted a banana instead...&lt;br /&gt;
my_fruit = new Banana();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Dynamic Binding''' - This feature of subclassing allows the code executor (ex: JVM for Java) to determine at runtime which version of an overridden method to execute. This is needed because sometimes the method to execute cannot be determined at compile-time.&lt;br /&gt;
&lt;br /&gt;
* '''Code Reuse''' - When a superclass is extended, the subclass inherits all of the methods and properties of the superclass. Code duplication is held to a minimum since the code is reused so effectively.&lt;br /&gt;
&lt;br /&gt;
* '''Overriding and Overloading''' - Overriding and overloading functionality in a subclass is a major draw of subclassing. These abilities allow the programmer to tweak specific methods of the superclass that are close to the desired functionality in order to get the functionality exactly right.&lt;br /&gt;
&lt;br /&gt;
==Reasons Not To Subclass==&lt;br /&gt;
&lt;br /&gt;
* '''Inherits Too Much''' - Sometimes a programmer only needs a subset of the functionality of class. Subclassing requires that all functionality be carried down to the subclass though, often resulting in a class that has a lot of unneeded functionality. If this is done more than once in a hierarchy, then subclasses can become too bulky very quickly.&lt;br /&gt;
&lt;br /&gt;
* '''Superclass Fragility''' - This issue arises because sometimes a small change in a superclass can sometimes have a ripple effect that forces changes to be made elsewhere in the code. This is usually due to poorly designed superclasses where there is not a clean separation between interface and implementation.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Weak Encapsulation''' - This idea crops up when a subclass utilizes functionality of the superclass as it is inherited, essentially creating a case where the code from the superclass is reused. However, if changes are made to that functionality in the superclass, it could break code that directly utilizes an instance of the subclass.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Forces Is-A Relationships''' - There is a time and a place for is-a relationships, but there are some in the field that believe &amp;quot;almost every is-a relationship would be better off re-articulated as a has-a relationship&amp;quot;&amp;lt;ref&amp;gt;Sumption 2011&amp;lt;/ref&amp;gt;. Instances where two subclass functionalities need to be combined make for a hard implementation using is-a relationships. As an example, lets take the classes that follow. If we came across an instance where a TA was also a student, it would be very hard to pull in the functionality of one into the other. Composition (using has-a relationships) is a better fit here so that a Person could have the functionality of a Student, a TA, or both.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Person {&lt;br /&gt;
  var name:String;&lt;br /&gt;
  &lt;br /&gt;
  function sayHello() { . . . }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Student extends Person {&lt;br /&gt;
  var student_id:int;&lt;br /&gt;
&lt;br /&gt;
  function payTuition() { . . . }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class TA extends Person {&lt;br /&gt;
  var class:String;&lt;br /&gt;
&lt;br /&gt;
  function gradeTest() { . . . }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Subclassing Principles==&lt;br /&gt;
&lt;br /&gt;
===Liskov Substitution Principle===&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;ref&amp;gt;Wikipedia - LSP&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, superclasses should be replaceable by their subclasses without altering the system in any way. This principle borrows ideas from the design by contract methodology by imposing restrictions on the conditions for which the methods of a class will function. It also restricts how subclass methods can be designed in terms of their return types (covariance) and method arguments (contravariance). These restrictions provide a very good ruleset to determine whether subclassing should be utilized or not.&lt;br /&gt;
&lt;br /&gt;
===Design by Contract===&lt;br /&gt;
&lt;br /&gt;
The Design by Contract principle has a direct application to subclassing in its definitions of pre- and postconditions that must exist on methods. Its main goal is to provide a method to define &amp;quot;formal, precise and verifiable interface specifications for software components&amp;quot; by utilizing the idea of preconditions, postconditions and invariants&amp;lt;ref&amp;gt;Wikipedia - DbC&amp;lt;/ref&amp;gt;. When used, it helps to guarantee the functionality of any software component.&lt;br /&gt;
&lt;br /&gt;
Following this principle allows a programmer to weaken preconditions and strengthen postconditions and invariants, but not vice versa. Utilizing these rules comes very close to mimicking the rules applied in the Liskov substitution principle.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Generalization, Specialization, and Inheritance&amp;quot; [http://sourcemaking.com/uml/modeling-it-systems/structural-view/generalization-specialization-and-inheritance http://sourcemaking.com/uml/modeling-it-systems/structural-view/generalization-specialization-and-inheritance]&lt;br /&gt;
&lt;br /&gt;
Budd, Timothy. &amp;quot;Introduction to Object Oriented Programming, 3rd Ed Slides&amp;quot;. [http://classes.engr.oregonstate.edu/eecs/winter2004/cs582/slides/chap08/slide16.htm http://classes.engr.oregonstate.edu/eecs/winter2004/cs582/slides/chap08/slide16.htm]. 2004&lt;br /&gt;
&lt;br /&gt;
Sumption, Bernie. &amp;quot;Inheritance is evil, and must be destroyed&amp;quot;. [http://berniesumption.com/software/inheritance-is-evil-and-must-be-destroyed/ http://berniesumption.com/software/inheritance-is-evil-and-must-be-destroyed/]. 2011&lt;br /&gt;
&lt;br /&gt;
Skrien, Dale. &amp;quot;Object-Oriented Design Using Java&amp;quot;. Boston: McGraw-Hill, 2009.&lt;br /&gt;
&lt;br /&gt;
Venners, Bill. &amp;quot;Inheritance versus composition: Which one should you choose?&amp;quot; [http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html]. 1998&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Design by Contract&amp;quot;. [http://en.wikipedia.org/wiki/Design_by_Contract http://en.wikipedia.org/wiki/Design_by_Contract]&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Liskov substitution principle&amp;quot;. [http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=56150</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=56150"/>
		<updated>2011-11-22T03:24:31Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Reasons For Subclassing==&lt;br /&gt;
&lt;br /&gt;
There are many different reasons out there for why subclassing is helpful:&lt;br /&gt;
&lt;br /&gt;
* '''Specialization''' - If an existing class has the basic functionality needed (ex: a circle class) but is missing some small details (say a method to determine the center of the circle), then subclassing is very useful. It allows the programmer to get most of the functionality needed and provides a means to specialize the superclass to fit the needs of the program.&amp;lt;ref&amp;gt;Skrien 2009&amp;lt;/ref&amp;gt; An good example of this is the inheritance that takes place within Java's AWT graphical components&amp;lt;ref&amp;gt;Budd 2004&amp;lt;/ref&amp;gt;. Each of the components you see within a GUI (Label, Button, Checkbox, etc.) are specialized versions of the Component class.&lt;br /&gt;
&lt;br /&gt;
* '''Generalization''' - Two classes that are very closely related to each other could have their common functionality pulled out into a superclass and then changed to implement that superclass. This provides the programmer with less code duplication and makes it easier if a change is needed to that common functionality later on.&amp;lt;ref&amp;gt;Skrien 2009&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Polymorphism''' - Polymorphism is basically the utilization of a superclass type for a variable to hold a reference to an object whose class can be the supertype or any of its subtypes.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt; This is a great advantage since storing a subtype into that variable would still allow the program to function correctly. In the below example, a variable that is typed as a &amp;lt;tt&amp;gt;Fruit&amp;lt;/tt&amp;gt; could store the information for a &amp;lt;tt&amp;gt;Fruit&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Apple&amp;lt;/tt&amp;gt; or a &amp;lt;tt&amp;gt;Banana&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Fruit {&lt;br /&gt;
  // . . . . &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Apple extends Fruit {&lt;br /&gt;
  // . . .&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Banana extends Fruit {&lt;br /&gt;
  // . . .&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
var my_fruit:Fruit = new Apple();&lt;br /&gt;
 . . . &lt;br /&gt;
&lt;br /&gt;
// Oh wait, I wanted a banana instead...&lt;br /&gt;
my_fruit = new Banana();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Dynamic Binding''' - This feature of subclassing allows the code executor (ex: JVM for Java) to determine at runtime which version of an overridden method to execute. This is needed because sometimes the method to execute cannot be determined at compile-time.&lt;br /&gt;
&lt;br /&gt;
* '''Code Reuse''' - When a superclass is extended, the subclass inherits all of the methods and properties of the superclass. Code duplication is held to a minimum since the code is reused so effectively.&lt;br /&gt;
&lt;br /&gt;
* '''Overriding and Overloading''' - Overriding and overloading functionality in a subclass is a major draw of subclassing. These abilities allow the programmer to tweak specific methods of the superclass that are close to the desired functionality in order to get the functionality exactly right.&lt;br /&gt;
&lt;br /&gt;
==Reasons Not To Subclass==&lt;br /&gt;
&lt;br /&gt;
* '''Inherits Too Much''' - Sometimes a programmer only needs a subset of the functionality of class. Subclassing requires that all functionality be carried down to the subclass though, often resulting in a class that has a lot of unneeded functionality. If this is done more than once in a hierarchy, then subclasses can become too bulky very quickly.&lt;br /&gt;
&lt;br /&gt;
* '''Superclass Fragility''' - This issue arises because sometimes a small change in a superclass can sometimes have a ripple effect that forces changes to be made elsewhere in the code. This is usually due to poorly designed superclasses where there is not a clean separation between interface and implementation.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Weak Encapsulation''' - This idea crops up when a subclass utilizes functionality of the superclass as it is inherited, essentially creating a case where the code from the superclass is reused. However, if changes are made to that functionality in the superclass, it could break code that directly utilizes an instance of the subclass.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Forces Is-A Relationships''' - There is a time and a place for is-a relationships, but there are some in the field that believe &amp;quot;almost every is-a relationship would be better off re-articulated as a has-a relationship&amp;quot;&amp;lt;ref&amp;gt;Sumption 2011&amp;lt;/ref&amp;gt;. Instances where two subclass functionalities need to be combined make for a hard implementation using is-a relationships. As an example, lets take the classes that follow. If we came across an instance where a TA was also a student, it would be very hard to pull in the functionality of one into the other. Composition (using has-a relationships) is a better fit here so that a Person could have the functionality of a Student, a TA, or both.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Person {&lt;br /&gt;
  var name:String;&lt;br /&gt;
  &lt;br /&gt;
  function sayHello() { . . . }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Student extends Person {&lt;br /&gt;
  var student_id:int;&lt;br /&gt;
&lt;br /&gt;
  function payTuition() { . . . }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class TA extends Person {&lt;br /&gt;
  var class:String;&lt;br /&gt;
&lt;br /&gt;
  function gradeTest() { . . . }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Subclassing Principles==&lt;br /&gt;
&lt;br /&gt;
===Liskov Substitution Principle===&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;ref&amp;gt;Wikipedia - LSP&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, superclasses should be replaceable by their subclasses without altering the system in any way. This principle borrows ideas from the design by contract methodology by imposing restrictions on the conditions for which the methods of a class will function. It also restricts how subclass methods can be designed in terms of their return types (covariance) and method arguments (contravariance). These restrictions provide a very good ruleset to determine whether subclassing should be utilized or not.&lt;br /&gt;
&lt;br /&gt;
===Design by Contract===&lt;br /&gt;
&lt;br /&gt;
The Design by Contract principle has a direct application to subclassing in its definitions of pre- and postconditions that must exist on methods. Its main goal is to provide a method to define &amp;quot;formal, precise and verifiable interface specifications for software components&amp;quot; by utilizing the idea of preconditions, postconditions and invariants&amp;lt;ref&amp;gt;Wikipedia - DbC&amp;lt;/ref&amp;gt;. When used, it helps to guarantee the functionality of any software component.&lt;br /&gt;
&lt;br /&gt;
Following this principle allows a programmer to weaken preconditions and strengthen postconditions and invariants, but not vice versa. Utilizing these rules comes very close to mimicking the rules applied in the Liskov substitution principle.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
Budd, Timothy. &amp;quot;Introduction to Object Oriented Programming, 3rd Ed Slides&amp;quot;. [http://classes.engr.oregonstate.edu/eecs/winter2004/cs582/slides/chap08/slide16.htm http://classes.engr.oregonstate.edu/eecs/winter2004/cs582/slides/chap08/slide16.htm]. 2004&lt;br /&gt;
&lt;br /&gt;
Sumption, Bernie. &amp;quot;Inheritance is evil, and must be destroyed&amp;quot;. [http://berniesumption.com/software/inheritance-is-evil-and-must-be-destroyed/ http://berniesumption.com/software/inheritance-is-evil-and-must-be-destroyed/]. 2011&lt;br /&gt;
&lt;br /&gt;
Skrien, Dale. &amp;quot;Object-Oriented Design Using Java&amp;quot;. Boston: McGraw-Hill, 2009.&lt;br /&gt;
&lt;br /&gt;
Venners, Bill. &amp;quot;Inheritance versus composition: Which one should you choose?&amp;quot; [http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html]. 1998&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Design by Contract&amp;quot;. [http://en.wikipedia.org/wiki/Design_by_Contract http://en.wikipedia.org/wiki/Design_by_Contract]&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Liskov substitution principle&amp;quot;. [http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=56148</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=56148"/>
		<updated>2011-11-22T03:23:28Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* Reasons For Subclassing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Reasons For Subclassing==&lt;br /&gt;
&lt;br /&gt;
There are many different reasons out there for why subclassing is helpful:&lt;br /&gt;
&lt;br /&gt;
* '''Specialization''' - If an existing class has the basic functionality needed (ex: a circle class) but is missing some small details (say a method to determine the center of the circle), then subclassing is very useful. It allows the programmer to get most of the functionality needed and provides a means to specialize the superclass to fit the needs of the program.&amp;lt;ref&amp;gt;Skrien 2009&amp;lt;/ref&amp;gt; An good example of this is the inheritance that takes place within Java's AWT graphical components&amp;lt;ref&amp;gt;Budd 2004&amp;lt;/ref&amp;gt;. Each of the components you see within a GUI (Label, Button, Checkbox, etc.) are specialized versions of the Component class.&lt;br /&gt;
&lt;br /&gt;
* '''Generalization''' - Two classes that are very closely related to each other could have their common functionality pulled out into a superclass and then changed to implement that superclass. This provides the programmer with less code duplication and makes it easier if a change is needed to that common functionality later on.&amp;lt;ref&amp;gt;Skrien 2009&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Polymorphism''' - Polymorphism is basically the utilization of a superclass type for a variable to hold a reference to an object whose class can be the supertype or any of its subtypes.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt; This is a great advantage since storing a subtype into that variable would still allow the program to function correctly. In the below example, a variable that is typed as a &amp;lt;tt&amp;gt;Fruit&amp;lt;/tt&amp;gt; could store the information for a &amp;lt;tt&amp;gt;Fruit&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Apple&amp;lt;/tt&amp;gt; or a &amp;lt;tt&amp;gt;Banana&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Fruit {&lt;br /&gt;
  // . . . . &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Apple extends Fruit {&lt;br /&gt;
  // . . .&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Banana extends Fruit {&lt;br /&gt;
  // . . .&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
var my_fruit:Fruit = new Apple();&lt;br /&gt;
 . . . &lt;br /&gt;
&lt;br /&gt;
// Oh wait, I wanted a banana instead...&lt;br /&gt;
my_fruit = new Banana();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Dynamic Binding''' - This feature of subclassing allows the code executor (ex: JVM for Java) to determine at runtime which version of an overridden method to execute. This is needed because sometimes the method to execute cannot be determined at compile-time.&lt;br /&gt;
&lt;br /&gt;
* '''Code Reuse''' - When a superclass is extended, the subclass inherits all of the methods and properties of the superclass. Code duplication is held to a minimum since the code is reused so effectively.&lt;br /&gt;
&lt;br /&gt;
* '''Overriding and Overloading''' - Overriding and overloading functionality in a subclass is a major draw of subclassing. These abilities allow the programmer to tweak specific methods of the superclass that are close to the desired functionality in order to get the functionality exactly right.&lt;br /&gt;
&lt;br /&gt;
==Reasons Not To Subclass==&lt;br /&gt;
&lt;br /&gt;
* '''Inherits Too Much''' - Sometimes a programmer only needs a subset of the functionality of class. Subclassing requires that all functionality be carried down to the subclass though, often resulting in a class that has a lot of unneeded functionality. If this is done more than once in a hierarchy, then subclasses can become too bulky very quickly.&lt;br /&gt;
&lt;br /&gt;
* '''Superclass Fragility''' - This issue arises because sometimes a small change in a superclass can sometimes have a ripple effect that forces changes to be made elsewhere in the code. This is usually due to poorly designed superclasses where there is not a clean separation between interface and implementation.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Weak Encapsulation''' - This idea crops up when a subclass utilizes functionality of the superclass as it is inherited, essentially creating a case where the code from the superclass is reused. However, if changes are made to that functionality in the superclass, it could break code that directly utilizes an instance of the subclass.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Forces Is-A Relationships''' - There is a time and a place for is-a relationships, but there are some in the field that believe &amp;quot;almost every is-a relationship would be better off re-articulated as a has-a relationship&amp;quot;&amp;lt;ref&amp;gt;Sumption 2011&amp;lt;/ref&amp;gt;. Instances where two subclass functionalities need to be combined make for a hard implementation using is-a relationships. As an example, lets take the classes that follow. If we came across an instance where a TA was also a student, it would be very hard to pull in the functionality of one into the other. Composition (using has-a relationships) is a better fit here so that a Person could have the functionality of a Student, a TA, or both.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Person {&lt;br /&gt;
  var name:String;&lt;br /&gt;
  &lt;br /&gt;
  function sayHello() { . . . }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Student extends Person {&lt;br /&gt;
  var student_id:int;&lt;br /&gt;
&lt;br /&gt;
  function payTuition() { . . . }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class TA extends Person {&lt;br /&gt;
  var class:String;&lt;br /&gt;
&lt;br /&gt;
  function gradeTest() { . . . }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Subclassing Principles==&lt;br /&gt;
&lt;br /&gt;
===Liskov Substitution Principle===&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;ref&amp;gt;Wikipedia - LSP&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, superclasses should be replaceable by their subclasses without altering the system in any way. This principle borrows ideas from the design by contract methodology by imposing restrictions on the conditions for which the methods of a class will function. It also restricts how subclass methods can be designed in terms of their return types (covariance) and method arguments (contravariance). These restrictions provide a very good ruleset to determine whether subclassing should be utilized or not.&lt;br /&gt;
&lt;br /&gt;
===Design by Contract===&lt;br /&gt;
&lt;br /&gt;
The Design by Contract principle has a direct application to subclassing in its definitions of pre- and postconditions that must exist on methods. Its main goal is to provide a method to define &amp;quot;formal, precise and verifiable interface specifications for software components&amp;quot; by utilizing the idea of preconditions, postconditions and invariants&amp;lt;ref&amp;gt;Wikipedia - DbC&amp;lt;/ref&amp;gt;. When used, it helps to guarantee the functionality of any software component.&lt;br /&gt;
&lt;br /&gt;
Following this principle allows a programmer to weaken preconditions and strengthen postconditions and invariants, but not vice versa. Utilizing these rules comes very close to mimicking the rules applied in the Liskov substitution principle.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
Sumption, Bernie. &amp;quot;Inheritance is evil, and must be destroyed&amp;quot;. [http://berniesumption.com/software/inheritance-is-evil-and-must-be-destroyed/ http://berniesumption.com/software/inheritance-is-evil-and-must-be-destroyed/]. 2011&lt;br /&gt;
&lt;br /&gt;
Skrien, Dale. &amp;quot;Object-Oriented Design Using Java&amp;quot;. Boston: McGraw-Hill, 2009.&lt;br /&gt;
&lt;br /&gt;
Venners, Bill. &amp;quot;Inheritance versus composition: Which one should you choose?&amp;quot; [http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html]. 1998&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Design by Contract&amp;quot;. [http://en.wikipedia.org/wiki/Design_by_Contract http://en.wikipedia.org/wiki/Design_by_Contract]&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Liskov substitution principle&amp;quot;. [http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=56136</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=56136"/>
		<updated>2011-11-22T02:23:52Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* Reasons For Subclassing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Reasons For Subclassing==&lt;br /&gt;
&lt;br /&gt;
There are many different reasons out there for why subclassing is helpful:&lt;br /&gt;
&lt;br /&gt;
* '''Specialization''' - If an existing class has the basic functionality needed (ex: a circle class) but is missing some small details (say a method to determine the center of the circle), then subclassing is very useful. It allows the programmer to get most of the functionality needed and provides a means to specialize the superclass to fit the needs of the program.&amp;lt;ref&amp;gt;Skrien 2009&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Generalization''' - Two classes that are very closely related to each other could have their common functionality pulled out into a superclass and then changed to implement that superclass. This provides the programmer with less code duplication and makes it easier if a change is needed to that common functionality later on.&amp;lt;ref&amp;gt;Skrien 2009&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Polymorphism''' - Polymorphism is basically the utilization of a superclass type for a variable to hold a reference to an object whose class can be the supertype or any of its subtypes.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt; This is a great advantage since storing a subtype into that variable would still allow the program to function correctly. In the below example, a variable that is typed as a &amp;lt;tt&amp;gt;Fruit&amp;lt;/tt&amp;gt; could store the information for a &amp;lt;tt&amp;gt;Fruit&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;Apple&amp;lt;/tt&amp;gt; or a &amp;lt;tt&amp;gt;Banana&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Fruit {&lt;br /&gt;
  // . . . . &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Apple extends Fruit {&lt;br /&gt;
  // . . .&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Banana extends Fruit {&lt;br /&gt;
  // . . .&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
var my_fruit:Fruit = new Apple();&lt;br /&gt;
 . . . &lt;br /&gt;
&lt;br /&gt;
// Oh wait, I wanted a banana instead...&lt;br /&gt;
my_fruit = new Banana();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Dynamic Binding''' - This feature of subclassing allows the code executor (ex: JVM for Java) to determine at runtime which version of an overridden method to execute. This is needed because sometimes the method to execute cannot be determined at compile-time.&lt;br /&gt;
&lt;br /&gt;
* '''Code Reuse''' - When a superclass is extended, the subclass inherits all of the methods and properties of the superclass. Code duplication is held to a minimum since the code is reused so effectively.&lt;br /&gt;
&lt;br /&gt;
* '''Overriding and Overloading''' - Overriding and overloading functionality in a subclass is a major draw of subclassing. These abilities allow the programmer to tweak specific methods of the superclass that are close to the desired functionality in order to get the functionality exactly right.&lt;br /&gt;
&lt;br /&gt;
==Reasons Not To Subclass==&lt;br /&gt;
&lt;br /&gt;
* '''Inherits Too Much''' - Sometimes a programmer only needs a subset of the functionality of class. Subclassing requires that all functionality be carried down to the subclass though, often resulting in a class that has a lot of unneeded functionality. If this is done more than once in a hierarchy, then subclasses can become too bulky very quickly.&lt;br /&gt;
&lt;br /&gt;
* '''Superclass Fragility''' - This issue arises because sometimes a small change in a superclass can sometimes have a ripple effect that forces changes to be made elsewhere in the code. This is usually due to poorly designed superclasses where there is not a clean separation between interface and implementation.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Weak Encapsulation''' - This idea crops up when a subclass utilizes functionality of the superclass as it is inherited, essentially creating a case where the code from the superclass is reused. However, if changes are made to that functionality in the superclass, it could break code that directly utilizes an instance of the subclass.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Forces Is-A Relationships''' - There is a time and a place for is-a relationships, but there are some in the field that believe &amp;quot;almost every is-a relationship would be better off re-articulated as a has-a relationship&amp;quot;&amp;lt;ref&amp;gt;Sumption 2011&amp;lt;/ref&amp;gt;. Instances where two subclass functionalities need to be combined make for a hard implementation using is-a relationships. As an example, lets take the classes that follow. If we came across an instance where a TA was also a student, it would be very hard to pull in the functionality of one into the other. Composition (using has-a relationships) is a better fit here so that a Person could have the functionality of a Student, a TA, or both.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Person {&lt;br /&gt;
  var name:String;&lt;br /&gt;
  &lt;br /&gt;
  function sayHello() { . . . }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Student extends Person {&lt;br /&gt;
  var student_id:int;&lt;br /&gt;
&lt;br /&gt;
  function payTuition() { . . . }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class TA extends Person {&lt;br /&gt;
  var class:String;&lt;br /&gt;
&lt;br /&gt;
  function gradeTest() { . . . }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Subclassing Principles==&lt;br /&gt;
&lt;br /&gt;
===Liskov Substitution Principle===&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;ref&amp;gt;Wikipedia - LSP&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, superclasses should be replaceable by their subclasses without altering the system in any way. This principle borrows ideas from the design by contract methodology by imposing restrictions on the conditions for which the methods of a class will function. It also restricts how subclass methods can be designed in terms of their return types (covariance) and method arguments (contravariance). These restrictions provide a very good ruleset to determine whether subclassing should be utilized or not.&lt;br /&gt;
&lt;br /&gt;
===Design by Contract===&lt;br /&gt;
&lt;br /&gt;
The Design by Contract principle has a direct application to subclassing in its definitions of pre- and postconditions that must exist on methods. Its main goal is to provide a method to define &amp;quot;formal, precise and verifiable interface specifications for software components&amp;quot; by utilizing the idea of preconditions, postconditions and invariants&amp;lt;ref&amp;gt;Wikipedia - DbC&amp;lt;/ref&amp;gt;. When used, it helps to guarantee the functionality of any software component.&lt;br /&gt;
&lt;br /&gt;
Following this principle allows a programmer to weaken preconditions and strengthen postconditions and invariants, but not vice versa. Utilizing these rules comes very close to mimicking the rules applied in the Liskov substitution principle.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
Sumption, Bernie. &amp;quot;Inheritance is evil, and must be destroyed&amp;quot;. [http://berniesumption.com/software/inheritance-is-evil-and-must-be-destroyed/ http://berniesumption.com/software/inheritance-is-evil-and-must-be-destroyed/]. 2011&lt;br /&gt;
&lt;br /&gt;
Skrien, Dale. &amp;quot;Object-Oriented Design Using Java&amp;quot;. Boston: McGraw-Hill, 2009.&lt;br /&gt;
&lt;br /&gt;
Venners, Bill. &amp;quot;Inheritance versus composition: Which one should you choose?&amp;quot; [http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html]. 1998&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Design by Contract&amp;quot;. [http://en.wikipedia.org/wiki/Design_by_Contract http://en.wikipedia.org/wiki/Design_by_Contract]&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Liskov substitution principle&amp;quot;. [http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=56134</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=56134"/>
		<updated>2011-11-22T02:19:20Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* Reasons Not To Subclass */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Reasons For Subclassing==&lt;br /&gt;
&lt;br /&gt;
There are many different reasons out there for why subclassing is helpful:&lt;br /&gt;
&lt;br /&gt;
* '''Specialization''' - If an existing class has the basic functionality needed (ex: a circle class) but is missing some small details (say a method to determine the center of the circle), then subclassing is very useful. It allows the programmer to get most of the functionality needed and provides a means to specialize the superclass to fit the needs of the program.&amp;lt;ref&amp;gt;Skrien 2009&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Generalization''' - Two classes that are very closely related to each other could have their common functionality pulled out into a superclass and then changed to implement that superclass. This provides the programmer with less code duplication and makes it easier if a change is needed to that common functionality later on.&amp;lt;ref&amp;gt;Skrien 2009&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Polymorphism''' - Polymorphism is basically the utilization of a superclass type for a variable to hold a reference to an object whose class can be the supertype or any of its subtypes.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt; This is a great advantage since storing a subtype into that variable would still allow the program to function correctly.&lt;br /&gt;
&lt;br /&gt;
* '''Dynamic Binding''' - This feature of subclassing allows the code executor (ex: JVM for Java) to determine at runtime which version of an overridden method to execute. This is needed because sometimes the method to execute cannot be determined at compile-time.&lt;br /&gt;
&lt;br /&gt;
* '''Code Reuse''' - When a superclass is extended, the subclass inherits all of the methods and properties of the superclass. Code duplication is held to a minimum since the code is reused so effectively.&lt;br /&gt;
&lt;br /&gt;
* '''Overriding and Overloading''' - Overriding and overloading functionality in a subclass is a major draw of subclassing. These abilities allow the programmer to tweak specific methods of the superclass that are close to the desired functionality in order to get the functionality exactly right.&lt;br /&gt;
&lt;br /&gt;
==Reasons Not To Subclass==&lt;br /&gt;
&lt;br /&gt;
* '''Inherits Too Much''' - Sometimes a programmer only needs a subset of the functionality of class. Subclassing requires that all functionality be carried down to the subclass though, often resulting in a class that has a lot of unneeded functionality. If this is done more than once in a hierarchy, then subclasses can become too bulky very quickly.&lt;br /&gt;
&lt;br /&gt;
* '''Superclass Fragility''' - This issue arises because sometimes a small change in a superclass can sometimes have a ripple effect that forces changes to be made elsewhere in the code. This is usually due to poorly designed superclasses where there is not a clean separation between interface and implementation.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Weak Encapsulation''' - This idea crops up when a subclass utilizes functionality of the superclass as it is inherited, essentially creating a case where the code from the superclass is reused. However, if changes are made to that functionality in the superclass, it could break code that directly utilizes an instance of the subclass.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Forces Is-A Relationships''' - There is a time and a place for is-a relationships, but there are some in the field that believe &amp;quot;almost every is-a relationship would be better off re-articulated as a has-a relationship&amp;quot;&amp;lt;ref&amp;gt;Sumption 2011&amp;lt;/ref&amp;gt;. Instances where two subclass functionalities need to be combined make for a hard implementation using is-a relationships. As an example, lets take the classes that follow. If we came across an instance where a TA was also a student, it would be very hard to pull in the functionality of one into the other. Composition (using has-a relationships) is a better fit here so that a Person could have the functionality of a Student, a TA, or both.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Person {&lt;br /&gt;
  var name:String;&lt;br /&gt;
  &lt;br /&gt;
  function sayHello() { . . . }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Student extends Person {&lt;br /&gt;
  var student_id:int;&lt;br /&gt;
&lt;br /&gt;
  function payTuition() { . . . }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class TA extends Person {&lt;br /&gt;
  var class:String;&lt;br /&gt;
&lt;br /&gt;
  function gradeTest() { . . . }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Subclassing Principles==&lt;br /&gt;
&lt;br /&gt;
===Liskov Substitution Principle===&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;ref&amp;gt;Wikipedia - LSP&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, superclasses should be replaceable by their subclasses without altering the system in any way. This principle borrows ideas from the design by contract methodology by imposing restrictions on the conditions for which the methods of a class will function. It also restricts how subclass methods can be designed in terms of their return types (covariance) and method arguments (contravariance). These restrictions provide a very good ruleset to determine whether subclassing should be utilized or not.&lt;br /&gt;
&lt;br /&gt;
===Design by Contract===&lt;br /&gt;
&lt;br /&gt;
The Design by Contract principle has a direct application to subclassing in its definitions of pre- and postconditions that must exist on methods. Its main goal is to provide a method to define &amp;quot;formal, precise and verifiable interface specifications for software components&amp;quot; by utilizing the idea of preconditions, postconditions and invariants&amp;lt;ref&amp;gt;Wikipedia - DbC&amp;lt;/ref&amp;gt;. When used, it helps to guarantee the functionality of any software component.&lt;br /&gt;
&lt;br /&gt;
Following this principle allows a programmer to weaken preconditions and strengthen postconditions and invariants, but not vice versa. Utilizing these rules comes very close to mimicking the rules applied in the Liskov substitution principle.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
Sumption, Bernie. &amp;quot;Inheritance is evil, and must be destroyed&amp;quot;. [http://berniesumption.com/software/inheritance-is-evil-and-must-be-destroyed/ http://berniesumption.com/software/inheritance-is-evil-and-must-be-destroyed/]. 2011&lt;br /&gt;
&lt;br /&gt;
Skrien, Dale. &amp;quot;Object-Oriented Design Using Java&amp;quot;. Boston: McGraw-Hill, 2009.&lt;br /&gt;
&lt;br /&gt;
Venners, Bill. &amp;quot;Inheritance versus composition: Which one should you choose?&amp;quot; [http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html]. 1998&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Design by Contract&amp;quot;. [http://en.wikipedia.org/wiki/Design_by_Contract http://en.wikipedia.org/wiki/Design_by_Contract]&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Liskov substitution principle&amp;quot;. [http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=56132</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=56132"/>
		<updated>2011-11-22T02:05:12Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* Full References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Reasons For Subclassing==&lt;br /&gt;
&lt;br /&gt;
There are many different reasons out there for why subclassing is helpful:&lt;br /&gt;
&lt;br /&gt;
* '''Specialization''' - If an existing class has the basic functionality needed (ex: a circle class) but is missing some small details (say a method to determine the center of the circle), then subclassing is very useful. It allows the programmer to get most of the functionality needed and provides a means to specialize the superclass to fit the needs of the program.&amp;lt;ref&amp;gt;Skrien 2009&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Generalization''' - Two classes that are very closely related to each other could have their common functionality pulled out into a superclass and then changed to implement that superclass. This provides the programmer with less code duplication and makes it easier if a change is needed to that common functionality later on.&amp;lt;ref&amp;gt;Skrien 2009&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Polymorphism''' - Polymorphism is basically the utilization of a superclass type for a variable to hold a reference to an object whose class can be the supertype or any of its subtypes.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt; This is a great advantage since storing a subtype into that variable would still allow the program to function correctly.&lt;br /&gt;
&lt;br /&gt;
* '''Dynamic Binding''' - This feature of subclassing allows the code executor (ex: JVM for Java) to determine at runtime which version of an overridden method to execute. This is needed because sometimes the method to execute cannot be determined at compile-time.&lt;br /&gt;
&lt;br /&gt;
* '''Code Reuse''' - When a superclass is extended, the subclass inherits all of the methods and properties of the superclass. Code duplication is held to a minimum since the code is reused so effectively.&lt;br /&gt;
&lt;br /&gt;
* '''Overriding and Overloading''' - Overriding and overloading functionality in a subclass is a major draw of subclassing. These abilities allow the programmer to tweak specific methods of the superclass that are close to the desired functionality in order to get the functionality exactly right.&lt;br /&gt;
&lt;br /&gt;
==Reasons Not To Subclass==&lt;br /&gt;
&lt;br /&gt;
* '''Inherits Too Much''' - Sometimes a programmer only needs a subset of the functionality of class. Subclassing requires that all functionality be carried down to the subclass though, often resulting in a class that has a lot of unneeded functionality. If this is done more than once in a hierarchy, then subclasses can become too bulky very quickly.&lt;br /&gt;
&lt;br /&gt;
* '''Superclass Fragility''' - This issue arises because sometimes a small change in a superclass can sometimes have a ripple effect that forces changes to be made elsewhere in the code. This is usually due to poorly designed superclasses where there is not a clean separation between interface and implementation.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Weak Encapsulation''' - This idea crops up when a subclass utilizes functionality of the superclass as it is inherited, essentially creating a case where the code from the superclass is reused. However, if changes are made to that functionality in the superclass, it could break code that directly utilizes an instance of the subclass.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Forces Is-A Relationships''' - There is a time and a place for is-a relationships, but there are some in the field that believe &amp;quot;almost every is-a relationship would be better off re-articulated as a has-a relationship&amp;quot;&amp;lt;ref&amp;gt;Sumption 2011&amp;lt;/ref&amp;gt;. Instances where two subclass functionalities need to be combined make for a hard implementation using is-a relationships.&lt;br /&gt;
&lt;br /&gt;
==Subclassing Principles==&lt;br /&gt;
&lt;br /&gt;
===Liskov Substitution Principle===&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;ref&amp;gt;Wikipedia - LSP&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, superclasses should be replaceable by their subclasses without altering the system in any way. This principle borrows ideas from the design by contract methodology by imposing restrictions on the conditions for which the methods of a class will function. It also restricts how subclass methods can be designed in terms of their return types (covariance) and method arguments (contravariance). These restrictions provide a very good ruleset to determine whether subclassing should be utilized or not.&lt;br /&gt;
&lt;br /&gt;
===Design by Contract===&lt;br /&gt;
&lt;br /&gt;
The Design by Contract principle has a direct application to subclassing in its definitions of pre- and postconditions that must exist on methods. Its main goal is to provide a method to define &amp;quot;formal, precise and verifiable interface specifications for software components&amp;quot; by utilizing the idea of preconditions, postconditions and invariants&amp;lt;ref&amp;gt;Wikipedia - DbC&amp;lt;/ref&amp;gt;. When used, it helps to guarantee the functionality of any software component.&lt;br /&gt;
&lt;br /&gt;
Following this principle allows a programmer to weaken preconditions and strengthen postconditions and invariants, but not vice versa. Utilizing these rules comes very close to mimicking the rules applied in the Liskov substitution principle.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
Sumption, Bernie. &amp;quot;Inheritance is evil, and must be destroyed&amp;quot;. [http://berniesumption.com/software/inheritance-is-evil-and-must-be-destroyed/ http://berniesumption.com/software/inheritance-is-evil-and-must-be-destroyed/]. 2011&lt;br /&gt;
&lt;br /&gt;
Skrien, Dale. &amp;quot;Object-Oriented Design Using Java&amp;quot;. Boston: McGraw-Hill, 2009.&lt;br /&gt;
&lt;br /&gt;
Venners, Bill. &amp;quot;Inheritance versus composition: Which one should you choose?&amp;quot; [http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html]. 1998&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Design by Contract&amp;quot;. [http://en.wikipedia.org/wiki/Design_by_Contract http://en.wikipedia.org/wiki/Design_by_Contract]&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Liskov substitution principle&amp;quot;. [http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=56130</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=56130"/>
		<updated>2011-11-22T02:04:31Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* Reasons Not To Subclass */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Reasons For Subclassing==&lt;br /&gt;
&lt;br /&gt;
There are many different reasons out there for why subclassing is helpful:&lt;br /&gt;
&lt;br /&gt;
* '''Specialization''' - If an existing class has the basic functionality needed (ex: a circle class) but is missing some small details (say a method to determine the center of the circle), then subclassing is very useful. It allows the programmer to get most of the functionality needed and provides a means to specialize the superclass to fit the needs of the program.&amp;lt;ref&amp;gt;Skrien 2009&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Generalization''' - Two classes that are very closely related to each other could have their common functionality pulled out into a superclass and then changed to implement that superclass. This provides the programmer with less code duplication and makes it easier if a change is needed to that common functionality later on.&amp;lt;ref&amp;gt;Skrien 2009&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Polymorphism''' - Polymorphism is basically the utilization of a superclass type for a variable to hold a reference to an object whose class can be the supertype or any of its subtypes.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt; This is a great advantage since storing a subtype into that variable would still allow the program to function correctly.&lt;br /&gt;
&lt;br /&gt;
* '''Dynamic Binding''' - This feature of subclassing allows the code executor (ex: JVM for Java) to determine at runtime which version of an overridden method to execute. This is needed because sometimes the method to execute cannot be determined at compile-time.&lt;br /&gt;
&lt;br /&gt;
* '''Code Reuse''' - When a superclass is extended, the subclass inherits all of the methods and properties of the superclass. Code duplication is held to a minimum since the code is reused so effectively.&lt;br /&gt;
&lt;br /&gt;
* '''Overriding and Overloading''' - Overriding and overloading functionality in a subclass is a major draw of subclassing. These abilities allow the programmer to tweak specific methods of the superclass that are close to the desired functionality in order to get the functionality exactly right.&lt;br /&gt;
&lt;br /&gt;
==Reasons Not To Subclass==&lt;br /&gt;
&lt;br /&gt;
* '''Inherits Too Much''' - Sometimes a programmer only needs a subset of the functionality of class. Subclassing requires that all functionality be carried down to the subclass though, often resulting in a class that has a lot of unneeded functionality. If this is done more than once in a hierarchy, then subclasses can become too bulky very quickly.&lt;br /&gt;
&lt;br /&gt;
* '''Superclass Fragility''' - This issue arises because sometimes a small change in a superclass can sometimes have a ripple effect that forces changes to be made elsewhere in the code. This is usually due to poorly designed superclasses where there is not a clean separation between interface and implementation.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Weak Encapsulation''' - This idea crops up when a subclass utilizes functionality of the superclass as it is inherited, essentially creating a case where the code from the superclass is reused. However, if changes are made to that functionality in the superclass, it could break code that directly utilizes an instance of the subclass.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Forces Is-A Relationships''' - There is a time and a place for is-a relationships, but there are some in the field that believe &amp;quot;almost every is-a relationship would be better off re-articulated as a has-a relationship&amp;quot;&amp;lt;ref&amp;gt;Sumption 2011&amp;lt;/ref&amp;gt;. Instances where two subclass functionalities need to be combined make for a hard implementation using is-a relationships.&lt;br /&gt;
&lt;br /&gt;
==Subclassing Principles==&lt;br /&gt;
&lt;br /&gt;
===Liskov Substitution Principle===&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;ref&amp;gt;Wikipedia - LSP&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, superclasses should be replaceable by their subclasses without altering the system in any way. This principle borrows ideas from the design by contract methodology by imposing restrictions on the conditions for which the methods of a class will function. It also restricts how subclass methods can be designed in terms of their return types (covariance) and method arguments (contravariance). These restrictions provide a very good ruleset to determine whether subclassing should be utilized or not.&lt;br /&gt;
&lt;br /&gt;
===Design by Contract===&lt;br /&gt;
&lt;br /&gt;
The Design by Contract principle has a direct application to subclassing in its definitions of pre- and postconditions that must exist on methods. Its main goal is to provide a method to define &amp;quot;formal, precise and verifiable interface specifications for software components&amp;quot; by utilizing the idea of preconditions, postconditions and invariants&amp;lt;ref&amp;gt;Wikipedia - DbC&amp;lt;/ref&amp;gt;. When used, it helps to guarantee the functionality of any software component.&lt;br /&gt;
&lt;br /&gt;
Following this principle allows a programmer to weaken preconditions and strengthen postconditions and invariants, but not vice versa. Utilizing these rules comes very close to mimicking the rules applied in the Liskov substitution principle.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
Skrien, Dale. &amp;quot;Object-Oriented Design Using Java&amp;quot;. Boston: McGraw-Hill, 2009.&lt;br /&gt;
&lt;br /&gt;
Venners, Bill. &amp;quot;Inheritance versus composition: Which one should you choose?&amp;quot; [http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html]. 1998&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Design by Contract&amp;quot;. [http://en.wikipedia.org/wiki/Design_by_Contract http://en.wikipedia.org/wiki/Design_by_Contract]&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Liskov substitution principle&amp;quot;. [http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=55111</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=55111"/>
		<updated>2011-11-16T03:01:31Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* Full References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Reasons For Subclassing==&lt;br /&gt;
&lt;br /&gt;
There are many different reasons out there for why subclassing is helpful:&lt;br /&gt;
&lt;br /&gt;
* '''Specialization''' - If an existing class has the basic functionality needed (ex: a circle class) but is missing some small details (say a method to determine the center of the circle), then subclassing is very useful. It allows the programmer to get most of the functionality needed and provides a means to specialize the superclass to fit the needs of the program.&amp;lt;ref&amp;gt;Skrien 2009&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Generalization''' - Two classes that are very closely related to each other could have their common functionality pulled out into a superclass and then changed to implement that superclass. This provides the programmer with less code duplication and makes it easier if a change is needed to that common functionality later on.&amp;lt;ref&amp;gt;Skrien 2009&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Polymorphism''' - Polymorphism is basically the utilization of a superclass type for a variable to hold a reference to an object whose class can be the supertype or any of its subtypes.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt; This is a great advantage since storing a subtype into that variable would still allow the program to function correctly.&lt;br /&gt;
&lt;br /&gt;
* '''Dynamic Binding''' - This feature of subclassing allows the code executor (ex: JVM for Java) to determine at runtime which version of an overridden method to execute. This is needed because sometimes the method to execute cannot be determined at compile-time.&lt;br /&gt;
&lt;br /&gt;
* '''Code Reuse''' - When a superclass is extended, the subclass inherits all of the methods and properties of the superclass. Code duplication is held to a minimum since the code is reused so effectively.&lt;br /&gt;
&lt;br /&gt;
* '''Overriding and Overloading''' - Overriding and overloading functionality in a subclass is a major draw of subclassing. These abilities allow the programmer to tweak specific methods of the superclass that are close to the desired functionality in order to get the functionality exactly right.&lt;br /&gt;
&lt;br /&gt;
==Reasons Not To Subclass==&lt;br /&gt;
&lt;br /&gt;
* '''Inherits Too Much''' - Sometimes a programmer only needs a subset of the functionality of class. Subclassing requires that all functionality be carried down to the subclass though, often resulting in a class that has a lot of unneeded functionality. If this is done more than once in a hierarchy, then subclasses can become too bulky very quickly.&lt;br /&gt;
&lt;br /&gt;
* '''Superclass Fragility''' - This issue arises because sometimes a small change in a superclass can sometimes have a ripple effect that forces changes to be made elsewhere in the code. This is usually due to poorly designed superclasses where there is not a clean separation between interface and implementation.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Weak Encapsulation''' - This idea crops up when a subclass utilizes functionality of the superclass as it is inherited, essentially creating a case where the code from the superclass is reused. However, if changes are made to that functionality in the superclass, it could break code that directly utilizes an instance of the subclass.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Subclassing Principles==&lt;br /&gt;
&lt;br /&gt;
===Liskov Substitution Principle===&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;ref&amp;gt;Wikipedia - LSP&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, superclasses should be replaceable by their subclasses without altering the system in any way. This principle borrows ideas from the design by contract methodology by imposing restrictions on the conditions for which the methods of a class will function. It also restricts how subclass methods can be designed in terms of their return types (covariance) and method arguments (contravariance). These restrictions provide a very good ruleset to determine whether subclassing should be utilized or not.&lt;br /&gt;
&lt;br /&gt;
===Design by Contract===&lt;br /&gt;
&lt;br /&gt;
The Design by Contract principle has a direct application to subclassing in its definitions of pre- and postconditions that must exist on methods. Its main goal is to provide a method to define &amp;quot;formal, precise and verifiable interface specifications for software components&amp;quot; by utilizing the idea of preconditions, postconditions and invariants&amp;lt;ref&amp;gt;Wikipedia - DbC&amp;lt;/ref&amp;gt;. When used, it helps to guarantee the functionality of any software component.&lt;br /&gt;
&lt;br /&gt;
Following this principle allows a programmer to weaken preconditions and strengthen postconditions and invariants, but not vice versa. Utilizing these rules comes very close to mimicking the rules applied in the Liskov substitution principle.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
Skrien, Dale. &amp;quot;Object-Oriented Design Using Java&amp;quot;. Boston: McGraw-Hill, 2009.&lt;br /&gt;
&lt;br /&gt;
Venners, Bill. &amp;quot;Inheritance versus composition: Which one should you choose?&amp;quot; [http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html]. 1998&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Design by Contract&amp;quot;. [http://en.wikipedia.org/wiki/Design_by_Contract http://en.wikipedia.org/wiki/Design_by_Contract]&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Liskov substitution principle&amp;quot;. [http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=55108</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=55108"/>
		<updated>2011-11-16T02:56:05Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* Reasons For Subclassing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Reasons For Subclassing==&lt;br /&gt;
&lt;br /&gt;
There are many different reasons out there for why subclassing is helpful:&lt;br /&gt;
&lt;br /&gt;
* '''Specialization''' - If an existing class has the basic functionality needed (ex: a circle class) but is missing some small details (say a method to determine the center of the circle), then subclassing is very useful. It allows the programmer to get most of the functionality needed and provides a means to specialize the superclass to fit the needs of the program.&amp;lt;ref&amp;gt;Skrien 2009&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Generalization''' - Two classes that are very closely related to each other could have their common functionality pulled out into a superclass and then changed to implement that superclass. This provides the programmer with less code duplication and makes it easier if a change is needed to that common functionality later on.&amp;lt;ref&amp;gt;Skrien 2009&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Polymorphism''' - Polymorphism is basically the utilization of a superclass type for a variable to hold a reference to an object whose class can be the supertype or any of its subtypes.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt; This is a great advantage since storing a subtype into that variable would still allow the program to function correctly.&lt;br /&gt;
&lt;br /&gt;
* '''Dynamic Binding''' - This feature of subclassing allows the code executor (ex: JVM for Java) to determine at runtime which version of an overridden method to execute. This is needed because sometimes the method to execute cannot be determined at compile-time.&lt;br /&gt;
&lt;br /&gt;
* '''Code Reuse''' - When a superclass is extended, the subclass inherits all of the methods and properties of the superclass. Code duplication is held to a minimum since the code is reused so effectively.&lt;br /&gt;
&lt;br /&gt;
* '''Overriding and Overloading''' - Overriding and overloading functionality in a subclass is a major draw of subclassing. These abilities allow the programmer to tweak specific methods of the superclass that are close to the desired functionality in order to get the functionality exactly right.&lt;br /&gt;
&lt;br /&gt;
==Reasons Not To Subclass==&lt;br /&gt;
&lt;br /&gt;
* '''Inherits Too Much''' - Sometimes a programmer only needs a subset of the functionality of class. Subclassing requires that all functionality be carried down to the subclass though, often resulting in a class that has a lot of unneeded functionality. If this is done more than once in a hierarchy, then subclasses can become too bulky very quickly.&lt;br /&gt;
&lt;br /&gt;
* '''Superclass Fragility''' - This issue arises because sometimes a small change in a superclass can sometimes have a ripple effect that forces changes to be made elsewhere in the code. This is usually due to poorly designed superclasses where there is not a clean separation between interface and implementation.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Weak Encapsulation''' - This idea crops up when a subclass utilizes functionality of the superclass as it is inherited, essentially creating a case where the code from the superclass is reused. However, if changes are made to that functionality in the superclass, it could break code that directly utilizes an instance of the subclass.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Subclassing Principles==&lt;br /&gt;
&lt;br /&gt;
===Liskov Substitution Principle===&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;ref&amp;gt;Wikipedia - LSP&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, superclasses should be replaceable by their subclasses without altering the system in any way. This principle borrows ideas from the design by contract methodology by imposing restrictions on the conditions for which the methods of a class will function. It also restricts how subclass methods can be designed in terms of their return types (covariance) and method arguments (contravariance). These restrictions provide a very good ruleset to determine whether subclassing should be utilized or not.&lt;br /&gt;
&lt;br /&gt;
===Design by Contract===&lt;br /&gt;
&lt;br /&gt;
The Design by Contract principle has a direct application to subclassing in its definitions of pre- and postconditions that must exist on methods. Its main goal is to provide a method to define &amp;quot;formal, precise and verifiable interface specifications for software components&amp;quot; by utilizing the idea of preconditions, postconditions and invariants&amp;lt;ref&amp;gt;Wikipedia - DbC&amp;lt;/ref&amp;gt;. When used, it helps to guarantee the functionality of any software component.&lt;br /&gt;
&lt;br /&gt;
Following this principle allows a programmer to weaken preconditions and strengthen postconditions and invariants, but not vice versa. Utilizing these rules comes very close to mimicking the rules applied in the Liskov substitution principle.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
Venners, Bill. &amp;quot;Inheritance versus composition: Which one should you choose?&amp;quot; [http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html]. 1998&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Design by Contract&amp;quot;. [http://en.wikipedia.org/wiki/Design_by_Contract http://en.wikipedia.org/wiki/Design_by_Contract]&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Liskov substitution principle&amp;quot;. [http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=55106</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=55106"/>
		<updated>2011-11-16T02:54:38Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* Reasons For Subclassing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Reasons For Subclassing==&lt;br /&gt;
&lt;br /&gt;
There are many different reasons out there for why subclassing is helpful:&lt;br /&gt;
&lt;br /&gt;
* '''Specialization''' - If an existing class has the basic functionality needed (ex: a circle class) but is missing some small details (say a method to determine the center of the circle), then subclassing is very useful. It allows the programmer to get most of the functionality needed and provides a means to specialize the superclass to fit the needs of the program.&lt;br /&gt;
&lt;br /&gt;
* '''Generalization''' - Two classes that are very closely related to each other could have their common functionality pulled out into a superclass and then changed to implement that superclass. This provides the programmer with less code duplication and makes it easier if a change is needed to that common functionality later on.&lt;br /&gt;
&lt;br /&gt;
* '''Polymorphism''' - Polymorphism is basically the utilization of a superclass type for a variable to hold a reference to an object whose class can be the supertype or any of its subtypes.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt; This is a great advantage since storing a subtype into that variable would still allow the program to function correctly.&lt;br /&gt;
&lt;br /&gt;
* '''Dynamic Binding''' - This feature of subclassing allows the code executor (ex: JVM for Java) to determine at runtime which version of an overridden method to execute. This is needed because sometimes the method to execute cannot be determined at compile-time.&lt;br /&gt;
&lt;br /&gt;
* '''Code Reuse''' - When a superclass is extended, the subclass inherits all of the methods and properties of the superclass. Code duplication is held to a minimum since the code is reused so effectively.&lt;br /&gt;
&lt;br /&gt;
* '''Overriding and Overloading''' - Overriding and overloading functionality in a subclass is a major draw of subclassing. These abilities allow the programmer to tweak specific methods of the superclass that are close to the desired functionality in order to get the functionality exactly right.&lt;br /&gt;
&lt;br /&gt;
==Reasons Not To Subclass==&lt;br /&gt;
&lt;br /&gt;
* '''Inherits Too Much''' - Sometimes a programmer only needs a subset of the functionality of class. Subclassing requires that all functionality be carried down to the subclass though, often resulting in a class that has a lot of unneeded functionality. If this is done more than once in a hierarchy, then subclasses can become too bulky very quickly.&lt;br /&gt;
&lt;br /&gt;
* '''Superclass Fragility''' - This issue arises because sometimes a small change in a superclass can sometimes have a ripple effect that forces changes to be made elsewhere in the code. This is usually due to poorly designed superclasses where there is not a clean separation between interface and implementation.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Weak Encapsulation''' - This idea crops up when a subclass utilizes functionality of the superclass as it is inherited, essentially creating a case where the code from the superclass is reused. However, if changes are made to that functionality in the superclass, it could break code that directly utilizes an instance of the subclass.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Subclassing Principles==&lt;br /&gt;
&lt;br /&gt;
===Liskov Substitution Principle===&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;ref&amp;gt;Wikipedia - LSP&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, superclasses should be replaceable by their subclasses without altering the system in any way. This principle borrows ideas from the design by contract methodology by imposing restrictions on the conditions for which the methods of a class will function. It also restricts how subclass methods can be designed in terms of their return types (covariance) and method arguments (contravariance). These restrictions provide a very good ruleset to determine whether subclassing should be utilized or not.&lt;br /&gt;
&lt;br /&gt;
===Design by Contract===&lt;br /&gt;
&lt;br /&gt;
The Design by Contract principle has a direct application to subclassing in its definitions of pre- and postconditions that must exist on methods. Its main goal is to provide a method to define &amp;quot;formal, precise and verifiable interface specifications for software components&amp;quot; by utilizing the idea of preconditions, postconditions and invariants&amp;lt;ref&amp;gt;Wikipedia - DbC&amp;lt;/ref&amp;gt;. When used, it helps to guarantee the functionality of any software component.&lt;br /&gt;
&lt;br /&gt;
Following this principle allows a programmer to weaken preconditions and strengthen postconditions and invariants, but not vice versa. Utilizing these rules comes very close to mimicking the rules applied in the Liskov substitution principle.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
Venners, Bill. &amp;quot;Inheritance versus composition: Which one should you choose?&amp;quot; [http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html]. 1998&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Design by Contract&amp;quot;. [http://en.wikipedia.org/wiki/Design_by_Contract http://en.wikipedia.org/wiki/Design_by_Contract]&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Liskov substitution principle&amp;quot;. [http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=55105</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=55105"/>
		<updated>2011-11-16T02:51:59Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* Reasons For Subclassing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Reasons For Subclassing==&lt;br /&gt;
&lt;br /&gt;
There are many different reasons out there for why subclassing is helpful:&lt;br /&gt;
&lt;br /&gt;
* '''Specialization''' - If an existing class has the basic functionality needed (ex: a circle class) but is missing some small details (say a method to determine the center of the circle), then subclassing is very useful. It allows the programmer to get most of the functionality needed and provides a means to specialize the superclass to fit the needs of the program.&lt;br /&gt;
&lt;br /&gt;
* '''Polymorphism''' - Polymorphism is basically the utilization of a superclass type for a variable to hold a reference to an object whose class can be the supertype or any of its subtypes.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt; This is a great advantage since storing a subtype into that variable would still allow the program to function correctly.&lt;br /&gt;
&lt;br /&gt;
* '''Dynamic Binding''' - This feature of subclassing allows the code executor (ex: JVM for Java) to determine at runtime which version of an overridden method to execute. This is needed because sometimes the method to execute cannot be determined at compile-time.&lt;br /&gt;
&lt;br /&gt;
* '''Code Reuse''' - When a superclass is extended, the subclass inherits all of the methods and properties of the superclass. Code duplication is held to a minimum since the code is reused so effectively.&lt;br /&gt;
&lt;br /&gt;
* '''Overriding and Overloading''' - Overriding and overloading functionality in a subclass is a major draw of subclassing. These abilities allow the programmer to tweak specific methods of the superclass that are close to the desired functionality in order to get the functionality exactly right.&lt;br /&gt;
&lt;br /&gt;
==Reasons Not To Subclass==&lt;br /&gt;
&lt;br /&gt;
* '''Inherits Too Much''' - Sometimes a programmer only needs a subset of the functionality of class. Subclassing requires that all functionality be carried down to the subclass though, often resulting in a class that has a lot of unneeded functionality. If this is done more than once in a hierarchy, then subclasses can become too bulky very quickly.&lt;br /&gt;
&lt;br /&gt;
* '''Superclass Fragility''' - This issue arises because sometimes a small change in a superclass can sometimes have a ripple effect that forces changes to be made elsewhere in the code. This is usually due to poorly designed superclasses where there is not a clean separation between interface and implementation.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Weak Encapsulation''' - This idea crops up when a subclass utilizes functionality of the superclass as it is inherited, essentially creating a case where the code from the superclass is reused. However, if changes are made to that functionality in the superclass, it could break code that directly utilizes an instance of the subclass.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Subclassing Principles==&lt;br /&gt;
&lt;br /&gt;
===Liskov Substitution Principle===&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;ref&amp;gt;Wikipedia - LSP&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, superclasses should be replaceable by their subclasses without altering the system in any way. This principle borrows ideas from the design by contract methodology by imposing restrictions on the conditions for which the methods of a class will function. It also restricts how subclass methods can be designed in terms of their return types (covariance) and method arguments (contravariance). These restrictions provide a very good ruleset to determine whether subclassing should be utilized or not.&lt;br /&gt;
&lt;br /&gt;
===Design by Contract===&lt;br /&gt;
&lt;br /&gt;
The Design by Contract principle has a direct application to subclassing in its definitions of pre- and postconditions that must exist on methods. Its main goal is to provide a method to define &amp;quot;formal, precise and verifiable interface specifications for software components&amp;quot; by utilizing the idea of preconditions, postconditions and invariants&amp;lt;ref&amp;gt;Wikipedia - DbC&amp;lt;/ref&amp;gt;. When used, it helps to guarantee the functionality of any software component.&lt;br /&gt;
&lt;br /&gt;
Following this principle allows a programmer to weaken preconditions and strengthen postconditions and invariants, but not vice versa. Utilizing these rules comes very close to mimicking the rules applied in the Liskov substitution principle.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
Venners, Bill. &amp;quot;Inheritance versus composition: Which one should you choose?&amp;quot; [http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html]. 1998&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Design by Contract&amp;quot;. [http://en.wikipedia.org/wiki/Design_by_Contract http://en.wikipedia.org/wiki/Design_by_Contract]&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Liskov substitution principle&amp;quot;. [http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=55082</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=55082"/>
		<updated>2011-11-15T21:27:11Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* Full References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Reasons For Subclassing==&lt;br /&gt;
&lt;br /&gt;
There are many different reasons out there for why subclassing is helpful:&lt;br /&gt;
&lt;br /&gt;
* '''Polymorphism''' - Polymorphism is basically the utilization of a superclass type for a variable to hold a reference to an object whose class can be the supertype or any of its subtypes.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt; This is a great advantage since storing a subtype into that variable would still allow the program to function correctly.&lt;br /&gt;
&lt;br /&gt;
* '''Dynamic Binding''' - This feature of subclassing allows the code executor (ex: JVM for Java) to determine at runtime which version of an overridden method to execute. This is needed because sometimes the method to execute cannot be determined at compile-time.&lt;br /&gt;
&lt;br /&gt;
* '''Code Reuse''' - When a superclass is extended, the subclass inherits all of the methods and properties of the superclass. Code duplication is held to a minimum since the code is reused so effectively.&lt;br /&gt;
&lt;br /&gt;
* '''Overriding and Overloading''' - Overriding and overloading functionality in a subclass is a major draw of subclassing. These abilities allow the programmer to tweak specific methods of the superclass that are close to the desired functionality in order to get the functionality exactly right.&lt;br /&gt;
&lt;br /&gt;
==Reasons Not To Subclass==&lt;br /&gt;
&lt;br /&gt;
* '''Inherits Too Much''' - Sometimes a programmer only needs a subset of the functionality of class. Subclassing requires that all functionality be carried down to the subclass though, often resulting in a class that has a lot of unneeded functionality. If this is done more than once in a hierarchy, then subclasses can become too bulky very quickly.&lt;br /&gt;
&lt;br /&gt;
* '''Superclass Fragility''' - This issue arises because sometimes a small change in a superclass can sometimes have a ripple effect that forces changes to be made elsewhere in the code. This is usually due to poorly designed superclasses where there is not a clean separation between interface and implementation.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Weak Encapsulation''' - This idea crops up when a subclass utilizes functionality of the superclass as it is inherited, essentially creating a case where the code from the superclass is reused. However, if changes are made to that functionality in the superclass, it could break code that directly utilizes an instance of the subclass.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Subclassing Principles==&lt;br /&gt;
&lt;br /&gt;
===Liskov Substitution Principle===&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;ref&amp;gt;Wikipedia - LSP&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, superclasses should be replaceable by their subclasses without altering the system in any way. This principle borrows ideas from the design by contract methodology by imposing restrictions on the conditions for which the methods of a class will function. It also restricts how subclass methods can be designed in terms of their return types (covariance) and method arguments (contravariance). These restrictions provide a very good ruleset to determine whether subclassing should be utilized or not.&lt;br /&gt;
&lt;br /&gt;
===Design by Contract===&lt;br /&gt;
&lt;br /&gt;
The Design by Contract principle has a direct application to subclassing in its definitions of pre- and postconditions that must exist on methods. Its main goal is to provide a method to define &amp;quot;formal, precise and verifiable interface specifications for software components&amp;quot; by utilizing the idea of preconditions, postconditions and invariants&amp;lt;ref&amp;gt;Wikipedia - DbC&amp;lt;/ref&amp;gt;. When used, it helps to guarantee the functionality of any software component.&lt;br /&gt;
&lt;br /&gt;
Following this principle allows a programmer to weaken preconditions and strengthen postconditions and invariants, but not vice versa. Utilizing these rules comes very close to mimicking the rules applied in the Liskov substitution principle.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
Venners, Bill. &amp;quot;Inheritance versus composition: Which one should you choose?&amp;quot; [http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html]. 1998&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Design by Contract&amp;quot;. [http://en.wikipedia.org/wiki/Design_by_Contract http://en.wikipedia.org/wiki/Design_by_Contract]&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Liskov substitution principle&amp;quot;. [http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=55081</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=55081"/>
		<updated>2011-11-15T21:26:41Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* Subclassing Principles */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Reasons For Subclassing==&lt;br /&gt;
&lt;br /&gt;
There are many different reasons out there for why subclassing is helpful:&lt;br /&gt;
&lt;br /&gt;
* '''Polymorphism''' - Polymorphism is basically the utilization of a superclass type for a variable to hold a reference to an object whose class can be the supertype or any of its subtypes.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt; This is a great advantage since storing a subtype into that variable would still allow the program to function correctly.&lt;br /&gt;
&lt;br /&gt;
* '''Dynamic Binding''' - This feature of subclassing allows the code executor (ex: JVM for Java) to determine at runtime which version of an overridden method to execute. This is needed because sometimes the method to execute cannot be determined at compile-time.&lt;br /&gt;
&lt;br /&gt;
* '''Code Reuse''' - When a superclass is extended, the subclass inherits all of the methods and properties of the superclass. Code duplication is held to a minimum since the code is reused so effectively.&lt;br /&gt;
&lt;br /&gt;
* '''Overriding and Overloading''' - Overriding and overloading functionality in a subclass is a major draw of subclassing. These abilities allow the programmer to tweak specific methods of the superclass that are close to the desired functionality in order to get the functionality exactly right.&lt;br /&gt;
&lt;br /&gt;
==Reasons Not To Subclass==&lt;br /&gt;
&lt;br /&gt;
* '''Inherits Too Much''' - Sometimes a programmer only needs a subset of the functionality of class. Subclassing requires that all functionality be carried down to the subclass though, often resulting in a class that has a lot of unneeded functionality. If this is done more than once in a hierarchy, then subclasses can become too bulky very quickly.&lt;br /&gt;
&lt;br /&gt;
* '''Superclass Fragility''' - This issue arises because sometimes a small change in a superclass can sometimes have a ripple effect that forces changes to be made elsewhere in the code. This is usually due to poorly designed superclasses where there is not a clean separation between interface and implementation.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Weak Encapsulation''' - This idea crops up when a subclass utilizes functionality of the superclass as it is inherited, essentially creating a case where the code from the superclass is reused. However, if changes are made to that functionality in the superclass, it could break code that directly utilizes an instance of the subclass.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Subclassing Principles==&lt;br /&gt;
&lt;br /&gt;
===Liskov Substitution Principle===&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;ref&amp;gt;Wikipedia - LSP&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, superclasses should be replaceable by their subclasses without altering the system in any way. This principle borrows ideas from the design by contract methodology by imposing restrictions on the conditions for which the methods of a class will function. It also restricts how subclass methods can be designed in terms of their return types (covariance) and method arguments (contravariance). These restrictions provide a very good ruleset to determine whether subclassing should be utilized or not.&lt;br /&gt;
&lt;br /&gt;
===Design by Contract===&lt;br /&gt;
&lt;br /&gt;
The Design by Contract principle has a direct application to subclassing in its definitions of pre- and postconditions that must exist on methods. Its main goal is to provide a method to define &amp;quot;formal, precise and verifiable interface specifications for software components&amp;quot; by utilizing the idea of preconditions, postconditions and invariants&amp;lt;ref&amp;gt;Wikipedia - DbC&amp;lt;/ref&amp;gt;. When used, it helps to guarantee the functionality of any software component.&lt;br /&gt;
&lt;br /&gt;
Following this principle allows a programmer to weaken preconditions and strengthen postconditions and invariants, but not vice versa. Utilizing these rules comes very close to mimicking the rules applied in the Liskov substitution principle.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
Venners, Bill. &amp;quot;Inheritance versus composition: Which one should you choose?&amp;quot; [http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html]. 1998&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Liskov substitution principle&amp;quot;. [http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=55074</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=55074"/>
		<updated>2011-11-15T21:18:34Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Reasons For Subclassing==&lt;br /&gt;
&lt;br /&gt;
There are many different reasons out there for why subclassing is helpful:&lt;br /&gt;
&lt;br /&gt;
* '''Polymorphism''' - Polymorphism is basically the utilization of a superclass type for a variable to hold a reference to an object whose class can be the supertype or any of its subtypes.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt; This is a great advantage since storing a subtype into that variable would still allow the program to function correctly.&lt;br /&gt;
&lt;br /&gt;
* '''Dynamic Binding''' - This feature of subclassing allows the code executor (ex: JVM for Java) to determine at runtime which version of an overridden method to execute. This is needed because sometimes the method to execute cannot be determined at compile-time.&lt;br /&gt;
&lt;br /&gt;
* '''Code Reuse''' - When a superclass is extended, the subclass inherits all of the methods and properties of the superclass. Code duplication is held to a minimum since the code is reused so effectively.&lt;br /&gt;
&lt;br /&gt;
* '''Overriding and Overloading''' - Overriding and overloading functionality in a subclass is a major draw of subclassing. These abilities allow the programmer to tweak specific methods of the superclass that are close to the desired functionality in order to get the functionality exactly right.&lt;br /&gt;
&lt;br /&gt;
==Reasons Not To Subclass==&lt;br /&gt;
&lt;br /&gt;
* '''Inherits Too Much''' - Sometimes a programmer only needs a subset of the functionality of class. Subclassing requires that all functionality be carried down to the subclass though, often resulting in a class that has a lot of unneeded functionality. If this is done more than once in a hierarchy, then subclasses can become too bulky very quickly.&lt;br /&gt;
&lt;br /&gt;
* '''Superclass Fragility''' - This issue arises because sometimes a small change in a superclass can sometimes have a ripple effect that forces changes to be made elsewhere in the code. This is usually due to poorly designed superclasses where there is not a clean separation between interface and implementation.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Weak Encapsulation''' - This idea crops up when a subclass utilizes functionality of the superclass as it is inherited, essentially creating a case where the code from the superclass is reused. However, if changes are made to that functionality in the superclass, it could break code that directly utilizes an instance of the subclass.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Subclassing Principles==&lt;br /&gt;
&lt;br /&gt;
===Liskov Substitution Principle===&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;ref&amp;gt;Wikipedia - LSP&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, superclasses should be replaceable by their subclasses without altering the system in any way. This principle borrows ideas from the design by contract methodology by imposing restrictions on the conditions for which the methods of a class will function. It also restricts how subclass methods can be designed in terms of their return types (covariance) and method arguments (contravariance). These restrictions provide a very good ruleset to determine whether subclassing should be utilized or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
Venners, Bill. &amp;quot;Inheritance versus composition: Which one should you choose?&amp;quot; [http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html]. 1998&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Liskov substitution principle&amp;quot;. [http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=55072</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=55072"/>
		<updated>2011-11-15T21:16:14Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* Full References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Reasons For Subclassing==&lt;br /&gt;
&lt;br /&gt;
There are many different reasons out there for why subclassing is helpful:&lt;br /&gt;
&lt;br /&gt;
* '''Polymorphism''' - Polymorphism is basically the utilization of a superclass type for a variable to hold a reference to an object whose class can be the supertype or any of its subtypes.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt; This is a great advantage since storing a subtype into that variable would still allow the program to function correctly.&lt;br /&gt;
&lt;br /&gt;
* '''Dynamic Binding''' - This feature of subclassing allows the code executor (ex: JVM for Java) to determine at runtime which version of an overridden method to execute. This is needed because sometimes the method to execute cannot be determined at compile-time.&lt;br /&gt;
&lt;br /&gt;
* '''Code Reuse''' - When a superclass is extended, the subclass inherits all of the methods and properties of the superclass. Code duplication is held to a minimum since the code is reused so effectively.&lt;br /&gt;
&lt;br /&gt;
* '''Overriding and Overloading''' - Overriding and overloading functionality in a subclass is a major draw of subclassing. These abilities allow the programmer to tweak specific methods of the superclass that are close to the desired functionality in order to get the functionality exactly right.&lt;br /&gt;
&lt;br /&gt;
==Reasons Not To Subclass==&lt;br /&gt;
&lt;br /&gt;
* '''Inherits Too Much''' - Sometimes a programmer only needs a subset of the functionality of class. Subclassing requires that all functionality be carried down to the subclass though, often resulting in a class that has a lot of unneeded functionality. If this is done more than once in a hierarchy, then subclasses can become too bulky very quickly.&lt;br /&gt;
&lt;br /&gt;
* '''Superclass Fragility''' - This issue arises because sometimes a small change in a superclass can sometimes have a ripple effect that forces changes to be made elsewhere in the code. This is usually due to poorly designed superclasses where there is not a clean separation between interface and implementation.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Weak Encapsulation''' - This idea crops up when a subclass utilizes functionality of the superclass as it is inherited, essentially creating a case where the code from the superclass is reused. However, if changes are made to that functionality in the superclass, it could break code that directly utilizes an instance of the subclass.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Subclassing Principles==&lt;br /&gt;
&lt;br /&gt;
===Liskov Substitution Principle===&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;ref&amp;gt;Wikipedia - LSP&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, superclasses should be replaceable by their subclasses without altering the system in any way. This principle borrows ideas from the design by contract methodology by imposing restrictions on the conditions for which the methods of a class will function. It also restricts how subclass methods can be designed in terms of their return types (covariance) and method arguments (contravariance). These restrictions provide a very good ruleset to determine whether subclassing should be utilized or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle Liskov Substitution Principle]. Wikipedia&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
Venners, Bill. &amp;quot;Inheritance versus composition: Which one should you choose?&amp;quot; [http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html]. 1998&lt;br /&gt;
&lt;br /&gt;
Wikipedia. &amp;quot;Liskov Substitution Principle&amp;quot;. [http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=55071</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=55071"/>
		<updated>2011-11-15T21:13:53Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Reasons For Subclassing==&lt;br /&gt;
&lt;br /&gt;
There are many different reasons out there for why subclassing is helpful:&lt;br /&gt;
&lt;br /&gt;
* '''Polymorphism''' - Polymorphism is basically the utilization of a superclass type for a variable to hold a reference to an object whose class can be the supertype or any of its subtypes.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt; This is a great advantage since storing a subtype into that variable would still allow the program to function correctly.&lt;br /&gt;
&lt;br /&gt;
* '''Dynamic Binding''' - This feature of subclassing allows the code executor (ex: JVM for Java) to determine at runtime which version of an overridden method to execute. This is needed because sometimes the method to execute cannot be determined at compile-time.&lt;br /&gt;
&lt;br /&gt;
* '''Code Reuse''' - When a superclass is extended, the subclass inherits all of the methods and properties of the superclass. Code duplication is held to a minimum since the code is reused so effectively.&lt;br /&gt;
&lt;br /&gt;
* '''Overriding and Overloading''' - Overriding and overloading functionality in a subclass is a major draw of subclassing. These abilities allow the programmer to tweak specific methods of the superclass that are close to the desired functionality in order to get the functionality exactly right.&lt;br /&gt;
&lt;br /&gt;
==Reasons Not To Subclass==&lt;br /&gt;
&lt;br /&gt;
* '''Inherits Too Much''' - Sometimes a programmer only needs a subset of the functionality of class. Subclassing requires that all functionality be carried down to the subclass though, often resulting in a class that has a lot of unneeded functionality. If this is done more than once in a hierarchy, then subclasses can become too bulky very quickly.&lt;br /&gt;
&lt;br /&gt;
* '''Superclass Fragility''' - This issue arises because sometimes a small change in a superclass can sometimes have a ripple effect that forces changes to be made elsewhere in the code. This is usually due to poorly designed superclasses where there is not a clean separation between interface and implementation.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Weak Encapsulation''' - This idea crops up when a subclass utilizes functionality of the superclass as it is inherited, essentially creating a case where the code from the superclass is reused. However, if changes are made to that functionality in the superclass, it could break code that directly utilizes an instance of the subclass.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Subclassing Principles==&lt;br /&gt;
&lt;br /&gt;
===Liskov Substitution Principle===&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;ref&amp;gt;Wikipedia - LSP&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, superclasses should be replaceable by their subclasses without altering the system in any way. This principle borrows ideas from the design by contract methodology by imposing restrictions on the conditions for which the methods of a class will function. It also restricts how subclass methods can be designed in terms of their return types (covariance) and method arguments (contravariance). These restrictions provide a very good ruleset to determine whether subclassing should be utilized or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle Liskov Substitution Principle]. Wikipedia&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
Venners, Bill. &amp;quot;Inheritance versus composition: Which one should you choose?&amp;quot; [http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html]. 1998&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=55008</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=55008"/>
		<updated>2011-11-15T06:51:14Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Reasons For Subclassing==&lt;br /&gt;
&lt;br /&gt;
There are many different reasons out there for why subclassing is helpful:&lt;br /&gt;
&lt;br /&gt;
* '''Polymorphism''' - Polymorphism is basically the utilization of a superclass type for a variable to hold a reference to an object whose class can be the supertype or any of its subtypes.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt; This is a great advantage since storing a subtype into that variable would still allow the program to function correctly.&lt;br /&gt;
&lt;br /&gt;
* '''Dynamic Binding''' - This feature of subclassing allows the code executor (ex: JVM for Java) to determine at runtime which version of an overridden method to execute. This is needed because sometimes the method to execute cannot be determined at compile-time.&lt;br /&gt;
&lt;br /&gt;
* '''Code Reuse''' - When a superclass is extended, the subclass inherits all of the methods and properties of the superclass. Code duplication is held to a minimum since the code is reused so effectively.&lt;br /&gt;
&lt;br /&gt;
==Reasons Not To Subclass==&lt;br /&gt;
&lt;br /&gt;
* '''Inherits Too Much''' - Sometimes a programmer only needs a subset of the functionality of class. Subclassing requires that all functionality be carried down to the subclass though, often resulting in a class that has a lot of unneeded functionality. If this is done more than once in a hierarchy, then subclasses can become too bulky very quickly.&lt;br /&gt;
&lt;br /&gt;
* '''Superclass Fragility''' - This issue arises because sometimes a small change in a superclass can sometimes have a ripple effect that forces changes to be made elsewhere in the code. This is usually due to poorly designed superclasses where there is not a clean separation between interface and implementation.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Subclassing Principles==&lt;br /&gt;
&lt;br /&gt;
===Liskov Substitution Principle===&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;ref&amp;gt;Wikipedia - LSP&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, superclasses should be replaceable by their subclasses without altering the system in any way. This principle borrows ideas from the design by contract methodology by imposing restrictions on the conditions for which the methods of a class will function. It also restricts how subclass methods can be designed in terms of their return types (covariance) and method arguments (contravariance). These restrictions provide a very good ruleset to determine whether subclassing should be utilized or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle Liskov Substitution Principle]. Wikipedia&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
Venners, Bill. &amp;quot;Inheritance versus composition: Which one should you choose?&amp;quot; [http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html]. 1998&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=55001</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=55001"/>
		<updated>2011-11-15T06:35:05Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Reasons For Subclassing==&lt;br /&gt;
&lt;br /&gt;
There are many different reasons out there for why subclassing is helpful:&lt;br /&gt;
&lt;br /&gt;
* '''Polymorphism''' - Polymorphism is basically the utilization of a superclass type for a variable to hold a reference to an object whose class can be the supertype or any of its subtypes.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt; This is a great advantage since storing a subtype into that variable would still allow the program to function correctly.&lt;br /&gt;
&lt;br /&gt;
* '''Dynamic Binding''' - This feature of subclassing allows the code executor (ex: JVM for Java) to determine at runtime which version of an overridden method to execute. This is needed because sometimes the method to execute cannot be determined at compile-time.&lt;br /&gt;
&lt;br /&gt;
* '''Code Reuse''' - When a superclass is extended, the subclass inherits all of the methods and properties of the superclass. Code duplication is held to a minimum since the code is reused so effectively.&lt;br /&gt;
&lt;br /&gt;
==Reasons Not To Subclass==&lt;br /&gt;
&lt;br /&gt;
* '''Inherits Too Much''' - Sometimes a programmer only needs a subset of the functionality of class. Subclassing requires that all functionality be carried down to the subclass though, often resulting in a class that has a lot of unneeded functionality. If this is done more than once in a hierarchy, then subclasses can become too bulky very quickly.&lt;br /&gt;
&lt;br /&gt;
==Subclassing Principles==&lt;br /&gt;
&lt;br /&gt;
===Liskov Substitution Principle===&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;ref&amp;gt;Wikipedia - LSP&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, superclasses should be replaceable by their subclasses without altering the system in any way. This principle borrows ideas from the design by contract methodology by imposing restrictions on the conditions for which the methods of a class will function. It also restricts how subclass methods can be designed in terms of their return types (covariance) and method arguments (contravariance). These restrictions provide a very good ruleset to determine whether subclassing should be utilized or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle Liskov Substitution Principle]. Wikipedia&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
Venners, Bill. &amp;quot;Inheritance versus composition: Which one should you choose?&amp;quot; [http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html]. 1998&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=54991</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=54991"/>
		<updated>2011-11-15T06:23:34Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Reasons For Subclassing==&lt;br /&gt;
&lt;br /&gt;
There are many different reasons out there for why subclassing is helpful:&lt;br /&gt;
&lt;br /&gt;
* ''Polymorphism'' - Polymorphism is basically the utilization of a superclass type for a variable to hold a reference to an object whose class can be the supertype or any of its subtypes.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt; This is a great advantage since storing a subtype into that variable would still allow the program to function correctly.&lt;br /&gt;
&lt;br /&gt;
===Code Reuse===&lt;br /&gt;
&lt;br /&gt;
A great reason for subclassing is code reuse. When a superclass is extended, the subclass inherits all of the methods and properties of the superclass. This can be very useful to keep code duplication to a minimum.&lt;br /&gt;
&lt;br /&gt;
There can be a drawback to this however. If only a portion of the code in a class is needed, then extending it could grant the subclass a lot of functionality that is not needed. This causes subclasses to be bulkier than they need to be.&lt;br /&gt;
&lt;br /&gt;
==Reasons Not To Subclass==&lt;br /&gt;
&lt;br /&gt;
==Subclassing Principles==&lt;br /&gt;
&lt;br /&gt;
===Liskov Substitution Principle===&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;ref&amp;gt;Wikipedia - LSP&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, superclasses should be replaceable by their subclasses without altering the system in any way. This principle borrows ideas from the design by contract methodology by imposing restrictions on the conditions for which the methods of a class will function. It also restricts how subclass methods can be designed in terms of their return types (covariance) and method arguments (contravariance). These restrictions provide a very good ruleset to determine whether subclassing should be utilized or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle Liskov Substitution Principle]. Wikipedia&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
Venners, Bill. &amp;quot;Inheritance versus composition: Which one should you choose?&amp;quot; [http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html]. 1998&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=54990</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=54990"/>
		<updated>2011-11-15T06:19:33Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Reasons for Subclassing==&lt;br /&gt;
&lt;br /&gt;
===Polymorphism===&lt;br /&gt;
&lt;br /&gt;
Polymorphism is basically the utilization of a superclass type for a variable to hold a reference to an object whose class can be the supertype or any of its subtypes.&amp;lt;ref&amp;gt;Venners 1998&amp;lt;/ref&amp;gt; This is a great advantage since storing a subtype into that variable would &lt;br /&gt;
&lt;br /&gt;
===Code Reuse===&lt;br /&gt;
&lt;br /&gt;
A great reason for subclassing is code reuse. When a superclass is extended, the subclass inherits all of the methods and properties of the superclass. This can be very useful to keep code duplication to a minimum.&lt;br /&gt;
&lt;br /&gt;
There can be a drawback to this however. If only a portion of the code in a class is needed, then extending it could grant the subclass a lot of functionality that is not needed. This causes subclasses to be bulkier than they need to be.&lt;br /&gt;
&lt;br /&gt;
==Subclassing Principles==&lt;br /&gt;
&lt;br /&gt;
===Liskov Substitution Principle===&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;ref&amp;gt;Wikipedia - LSP&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, superclasses should be replaceable by their subclasses without altering the system in any way. This principle borrows ideas from the design by contract methodology by imposing restrictions on the conditions for which the methods of a class will function. It also restricts how subclass methods can be designed in terms of their return types (covariance) and method arguments (contravariance). These restrictions provide a very good ruleset to determine whether subclassing should be utilized or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle Liskov Substitution Principle]. Wikipedia&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
Venners, Bill. &amp;quot;Inheritance versus composition: Which one should you choose?&amp;quot; [http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html]. 1998&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=54989</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=54989"/>
		<updated>2011-11-15T06:18:36Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Reasons for Subclassing==&lt;br /&gt;
&lt;br /&gt;
===Polymorphism===&lt;br /&gt;
&lt;br /&gt;
Polymorphism is basically the utilization of a superclass type for a variable to hold a reference to an object whose class can be the supertype or any of its subtypes.&amp;lt;ref&amp;gt; This is a great advantage since storing a subtype into that variable would &lt;br /&gt;
&lt;br /&gt;
===Code Reuse===&lt;br /&gt;
&lt;br /&gt;
A great reason for subclassing is code reuse. When a superclass is extended, the subclass inherits all of the methods and properties of the superclass. This can be very useful to keep code duplication to a minimum.&lt;br /&gt;
&lt;br /&gt;
There can be a drawback to this however. If only a portion of the code in a class is needed, then extending it could grant the subclass a lot of functionality that is not needed. This causes subclasses to be bulkier than they need to be.&lt;br /&gt;
&lt;br /&gt;
==Subclassing Principles==&lt;br /&gt;
&lt;br /&gt;
===Liskov Substitution Principle===&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;ref&amp;gt;Wikipedia - LSP&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, superclasses should be replaceable by their subclasses without altering the system in any way. This principle borrows ideas from the design by contract methodology by imposing restrictions on the conditions for which the methods of a class will function. It also restricts how subclass methods can be designed in terms of their return types (covariance) and method arguments (contravariance). These restrictions provide a very good ruleset to determine whether subclassing should be utilized or not.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle Liskov Substitution Principle]. Wikipedia&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
Venners, Bill. &amp;quot;Inheritance versus composition: Which one should you choose?&amp;quot; [http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html http://www.javaworld.com/javaworld/jw-11-1998/jw-11-techniques.html]. 1998&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=54988</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=54988"/>
		<updated>2011-11-15T05:46:08Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Liskov Substitution Principle==&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;ref&amp;gt;Wikipedia - LSP&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle Liskov Substitution Principle]. Wikipedia&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=54987</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=54987"/>
		<updated>2011-11-15T05:45:18Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* Liskov Substitution Principle */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Liskov Substitution Principle==&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;ref&amp;gt;Wikipedia&amp;lt;/ref&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle Liskov Substitution Principle]. Wikipedia&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=54986</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=54986"/>
		<updated>2011-11-15T05:44:17Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Liskov Substitution Principle==&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle Liskov Substitution Principle]. Wikipedia&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle http://en.wikipedia.org/wiki/Liskov_substitution_principle]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=54985</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=54985"/>
		<updated>2011-11-15T05:42:39Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Subclassing, or inheritance, in object-oriented programming grants the programmer the ability to extend and refine the functionality of existing classes. This principle has many advantages that can make the programmers life much more simple. Principles and techniques have been defined that support and oppose the use of subclassing, making for a great debate. Here, some of these principles will be discussed to help determine when it is a good idea to utilize subclassing in a program. &lt;br /&gt;
&lt;br /&gt;
==Liskov Substitution Principle==&lt;br /&gt;
&lt;br /&gt;
Probably the most well-known subclassing principle is the Liskov Substitution Principle (LSP). It states:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If S is a subtype of T, then objects of type T may be replaced with objects of type S (i.e., objects of type S may be substitutes for objects of type T) without altering any of the desirable properties of that program (correctness, task performed, etc.).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Liskov_substitution_principle Liskov Substitution Principle] Wikipedia&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Liskov_substitution_principle&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011&amp;diff=54783</id>
		<title>CSC/ECE 517 Fall 2011</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011&amp;diff=54783"/>
		<updated>2011-11-09T03:56:36Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Link title]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1a ms]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1a cs]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1a ri]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1a lj]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1b sa]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1b ds]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1b tj]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1c cm]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1c sj]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1c ka]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1d sr]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1e vs]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1e aa]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1a sc]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1e dm]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1e an]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1e sa]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1e lm]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1g vn]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1f rs]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1f sv]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1g jn]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1h ps]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1e sm]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1i zf]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1g rn]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1i cl]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1d ss]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1i lj]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1h hs]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1d gs]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 2b ns]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 2b jp]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 2a av]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch2 2f jm]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch2 2e ad]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch2 2e kt]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch2 2e gp]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 2b qu]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch2 2c bs]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 2c rs]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 2a ca]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 2b rv]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch2 2c ds]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch2 2b sa]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch2 2f mm]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch2 2f vh]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch2 2e ps]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch3 3a oe]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch3 3h rr]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch3 3h ss]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch3 4b js]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch3 4b ms]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4b ds]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4i aa]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4i sd]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4d mt]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4d ls]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4d ch]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4c ap]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4h sv]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4e cl]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4e gs]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4a ga]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4f sl]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4i js]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4f ss]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4c dm]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4g as]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4g nv]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4g ms]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4h kp]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4h as]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4j fw]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4f rs]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4i lc]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch17 5b uo]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch17 5b br]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch5 5d he]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch5 6d ny]]&lt;br /&gt;
&lt;br /&gt;
*[[trial]]&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=54782</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=54782"/>
		<updated>2011-11-09T03:52:28Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Subclassing'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Definition==&lt;br /&gt;
&lt;br /&gt;
==When To Use It==&lt;br /&gt;
&lt;br /&gt;
===Code Reuse===&lt;br /&gt;
&lt;br /&gt;
===Is-A Relationships===&lt;br /&gt;
&lt;br /&gt;
===Public Interfaces===&lt;br /&gt;
&lt;br /&gt;
===Polymorphism===&lt;br /&gt;
&lt;br /&gt;
==Drawbacks==&lt;br /&gt;
&lt;br /&gt;
===Yo-Yo Effect===&lt;br /&gt;
&lt;br /&gt;
===Tight Coupling===&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=54781</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6b mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6b_mm&amp;diff=54781"/>
		<updated>2011-11-09T03:49:12Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: Created page with &amp;quot;=Subclassing=  ==Definition==  ==When To Use It==  ==Examples==  ==References==  ===Citation Notes===  ===Full References===  ===External Links===&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Subclassing=&lt;br /&gt;
&lt;br /&gt;
==Definition==&lt;br /&gt;
&lt;br /&gt;
==When To Use It==&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
===Citation Notes===&lt;br /&gt;
&lt;br /&gt;
===Full References===&lt;br /&gt;
&lt;br /&gt;
===External Links===&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=50335</id>
		<title>CSC/ECE 517 Fall 2011/ch2 2f mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=50335"/>
		<updated>2011-09-22T19:30:40Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* Rails 2 vs. Rails 3 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
The original Ruby on Rails platform was extracted from the web-based project-management tool called Basecamp developed by 37signals. Ruby on Rails’ creator, David Heinemeier Hansson, began work on the Rails in early 2003 and released it as open source code in 2004, but it wasn’t until 2005 that Hansson shared commit rights to the project. [REFERENCE] Hansson designed Ruby on Rails to be an out of the box development framework that includes everything a programmer needs to create database-driven web applications according to the Model-View-Control pattern of separation. Ruby on Rails is based on the two key paradigms of Convention over Configuration [WIKI LINK] and Don’t Repeat Yourself (DRY) [WIKI LINK].&lt;br /&gt;
&lt;br /&gt;
=History of Rails Development=&lt;br /&gt;
Throughout the development of the Rails framework there have been four significant releases alongside of the usual patches, fixes, and upgrades. &lt;br /&gt;
&lt;br /&gt;
===Rails 1.0===&lt;br /&gt;
Initially, Rails 1.0 was released 15 months after the original source was made available. [REFERENCE] This version contained the structural foundation of what would become a powerful open source motivator for the Ruby platform.  Though there were patches and code adjustments in Rails 1.2 the next major release was Rails 2.0. &lt;br /&gt;
&lt;br /&gt;
===Rails 2.0 ===&lt;br /&gt;
Rails 2.0 was a major facelift for the framework and much of the effort went into improving the resources and polishing the overall package by making it more lean. Among some of these improvements was a focus on increasing security by adding a new module to work with HTTP Basic Authentication and providing a built-in mechanism for dealing with CRSF attacks. Other improvements were in the areas of changing certain syntactical nomenclature as well as simplifying the format for a few templates. &lt;br /&gt;
&lt;br /&gt;
===Rails 2.3===&lt;br /&gt;
The next major update was Rails 2.3 at it was the most structural update prior to Rails 3.0 being released. The two primary changes in the architecture of the Rails application was the complete integration of the Rack modular web server interface and a renewed support for Rails Engines. {link 2} Alongside of these changes were updates to templates, the addition of built-in support for HTTP Digest Authentication, nested forms models, Metal, and improved caching performance among other things.&lt;br /&gt;
&lt;br /&gt;
===Rails 3.0===&lt;br /&gt;
Between Rails 2.3 and the release of Rails 3.0, Rails announced that it would merge with Merb and that Rails 3.0 would be the successor to both Rails 2 and Merb. Merb which is short for Mongrel+Erb, key feature that prompted the join Rails was its component modularity, extensible API design, and vertical scalability.&lt;br /&gt;
&lt;br /&gt;
=Rails 2 vs. Rails 3=&lt;br /&gt;
&lt;br /&gt;
As you can see a lot changed since the first release of Rails. We will explore a few of the key areas that changed between Rails 2 and Rails 3 that will affect a developer's everyday coding.&lt;br /&gt;
&lt;br /&gt;
==Rails Application Scripts==&lt;br /&gt;
&lt;br /&gt;
When you create a new Rails application, a directory named &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; is generated. In Rails 2, this directory is populated with a set of scripts that can be executed by the programmer. A few of the more important ones are as follows&amp;lt;ref&amp;gt;Ruby 2009, pp 257-258 &amp;lt;/ref&amp;gt;:&lt;br /&gt;
*&amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt;: Used to generate code for controllers, mailers, models, scaffolds and other sets of code.&lt;br /&gt;
*&amp;lt;tt&amp;gt;destroy&amp;lt;/tt&amp;gt;: Used to destroy code created by the &amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
*&amp;lt;tt&amp;gt;server&amp;lt;/tt&amp;gt;: Starts up the Rails application in a self-contained web server.&lt;br /&gt;
*&amp;lt;tt&amp;gt;plugin&amp;lt;/tt&amp;gt;: Helps with the installation and administration of plug-ins to the Rails framework.&lt;br /&gt;
*&amp;lt;tt&amp;gt;performance&amp;lt;/tt&amp;gt; directory: Contains scripts used by the programmer to help understand the performance characteristics of the application being built.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with all of these scripts and compiles them all into a single script named &amp;lt;tt&amp;gt;rails&amp;lt;/tt&amp;gt;. With this script, the programmer can access all of the functionality that was available with the separate scripts. To make things even easier, the necessity to call this script outright is even unnecessary. By using the operating systems installed &amp;lt;tt&amp;gt;'''rails'''&amp;lt;/tt&amp;gt; command (ex, &amp;lt;tt&amp;gt;/usr/bin/rails&amp;lt;/tt&amp;gt; on Linux systems) in the root of any Rails 3 application, it will know to call this script.&lt;br /&gt;
&lt;br /&gt;
==Gem Dependencies==&lt;br /&gt;
&lt;br /&gt;
The ability to extend the Rails framework using a Gem is a very powerful feature. In Rails 2, the &amp;lt;tt&amp;gt;config/environment.rb&amp;lt;/tt&amp;gt; file had to be edited in order to tell the Rails application to require specific Gems using the &amp;lt;tt&amp;gt;'''config.gem'''&amp;lt;/tt&amp;gt; method. To ensure that the Gems were actually installed on the system running the Rails application, the programmer had to execute the &amp;lt;tt&amp;gt;rake gem:install&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with the need to have that manual process of installing Gems by utilizing a file named &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; in the root of the application as well as the Bundler. The Bundler looks at the contents &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; and automatically installs any Gems that are missing from the system. This allows the programmer to focus on more important issues.&lt;br /&gt;
&lt;br /&gt;
==Routing DSL==&lt;br /&gt;
&lt;br /&gt;
The routing DSL for Rails went through a major reconditioning and has actually been renamed to Action Dispatch. This rewrite took the logic out of the Action Controller and is now a standalone piece of software resulting in a much cleaner implementation. As well, the definition of routes for each application are now named within your Application module instead of the Action Controller. The difference can be seen in the beginning line of the &amp;lt;tt&amp;gt;config/routes.rb&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
ActionController::Routing::Routes.draw do |map|&lt;br /&gt;
  map.resources :posts&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
AppName::Application.routes do&lt;br /&gt;
  resources :posts&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With all these changes, the &amp;lt;tt&amp;gt;config/routes.rb&amp;lt;/tt&amp;gt; file now has a new syntax. Here are some of the major differences&amp;lt;ref&amp;gt;Reza 2010&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Default Route===&lt;br /&gt;
&lt;br /&gt;
The differences between the default route are minor between the two versions, but the Rails 3 version is much more explicit, as the parentheses indicate parameters that are optional. Also worth noting is that this route is commented out in Rails 3 by default. The reasoning behind this is that there is a big push for a RESTful architecture with the Rails application and this type of route isn't really recommended for that kind of application. It can be uncommented but be warned that doing so will make all actions in every controller accessible via GET requests.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.connect ':controller/:action/:id'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match '/:controller(/:action(/:id))'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Regular Routes===&lt;br /&gt;
The way in which a regular route is defined is much more streamlined and readable. In Rails 2, you had to define a key for the controller and action. With Rails 3, this definition is streamlined with a &amp;lt;tt&amp;gt;:to&amp;lt;/tt&amp;gt; key where you define in a specific format the controller and action responsible for the request. Here is an example to illustrate this point:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.connect 'products/:id', :controller =&amp;gt; 'products', :action =&amp;gt; 'view'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match 'products/:id', :to =&amp;gt; 'catalog#view'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Named Routes===&lt;br /&gt;
Setting up named routes has changed a little bit as well. The rules for the regular routes apply here but the way that you define the name of the route has changed. Now, you utilize the &amp;lt;tt&amp;gt;:as&amp;lt;/tt&amp;gt; key to define the name of the route as shown here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.logout '/logout', :controller =&amp;gt; 'sessions', :action =&amp;gt; 'destroy'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match 'logout', :to =&amp;gt; 'sessions#destroy', :as =&amp;gt; &amp;quot;logout&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Empty Route===&lt;br /&gt;
The empty route defines where to route the application when a user navigates to the root of the website (for normal HTML sites, this is the same as the index page). Rails 2 had a quick way of defining it but in true Ruby fashion, Rails 3 makes it even simpler to define this route as you can see here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.root :controller =&amp;gt; &amp;quot;welcome&amp;quot;, :action =&amp;gt; 'show'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
root :to =&amp;gt; 'welcome#show'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===RESTful Resources===&lt;br /&gt;
RESTful resources are very important and have been a part of Rails since version 1.2. Utilizing the &amp;lt;tt&amp;gt;rails generate scaffold&amp;lt;/tt&amp;gt; command, Rails will generate the route, controller, views and model necessary to have the basic REST functionality for a model. As you can see from the following example, defining a RESTful route is simple in either version. Rails 3 grants you the ability to use this line for multiple resources as well, saving lines of code and making it more readable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.resources :products&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
# Single resource definition&lt;br /&gt;
resources :products&lt;br /&gt;
# Multiple resource definitions&lt;br /&gt;
resources :products, :categories, :comments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, Rails 3 provides you with the ability to extend the routing beyond the seven basic RESTful actions.  There are multiple ways in which you can extend this functionality:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Defining extra collection RESTful actions within a block.&lt;br /&gt;
resources :products do&lt;br /&gt;
  collection do&lt;br /&gt;
    get  :sold&lt;br /&gt;
    post :on_offer&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# An inline extension.&lt;br /&gt;
resources :products do&lt;br /&gt;
  get :sold, :on =&amp;gt; :member&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Active Record==&lt;br /&gt;
Active Record, like all of the core Rails components, got a major overhaul. &lt;br /&gt;
&lt;br /&gt;
===Arel and the Query Interface===&lt;br /&gt;
The most prominent changes made that will be apparent to developers will be the integration with [https://github.com/nkallen/arel Arel]. With this integration, all of the core methods for Active Record return relations, allowing them to be chained together to develop complex queries. A full list and their functionality can be found in the [http://guides.rubyonrails.org/active_record_querying.html Rails Guide]. This will take the place of the options hash that would normally get passed in to one of the Active Record methods. To illustrate this, say we wanted to get a list of the first 10 products ordered alphabetically:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
Product.find(:order =&amp;gt; &amp;quot;name DESC&amp;quot;, :limit =&amp;gt; 10)&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
Product.order(&amp;quot;name DESC&amp;quot;).limit(10)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, there are a lot of methods that are losing the options parameter in their definitions&amp;lt;ref&amp;gt;Naik 2010&amp;lt;/ref&amp;gt;, including query methods find and all as well as calculation methods count and average. Also, the &amp;lt;tt&amp;gt;:all&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;:first&amp;lt;/tt&amp;gt; parameters for the find method are being deprecated in favor of the &amp;lt;tt&amp;gt;all&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;first&amp;lt;/tt&amp;gt; methods. Here are some examples of how things are changing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Changes to the find method.&lt;br /&gt;
# Rails 2&lt;br /&gt;
Product.find(:all)&lt;br /&gt;
Product.find(:first)&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
Product.all&lt;br /&gt;
Product.first&lt;br /&gt;
&lt;br /&gt;
# Examples of method options being removed.&lt;br /&gt;
# Rails 2&lt;br /&gt;
Product.all(:joins =&amp;gt; :categories)&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
Product.joins(&amp;quot;categories&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Named Scopes===&lt;br /&gt;
The &amp;lt;tt&amp;gt;named_scope&amp;lt;/tt&amp;gt; definition has been changed to just &amp;lt;tt&amp;gt;scope&amp;lt;/tt&amp;gt;. The options hash is also being deprecated and should be replaced with the new methods provided by the Arel integration. Translating existing Rails 2 named scopes is easy enough:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
class Product&lt;br /&gt;
  named_scope :food, :conditions =&amp;gt; { :type =&amp;gt; &amp;quot;food&amp;quot; }&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
class Product&lt;br /&gt;
  scope :food, where(:type =&amp;gt; &amp;quot;food&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==JavaScript Support&amp;lt;ref&amp;gt;Gadbois 2010&amp;lt;/ref&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
There are many JavaScript libraries available to programmers to make their web applications more dynamic and smooth looking. Whenever you created a Rails 2 application, it would automatically install the Prototype and Script.aculo.us frameworks. Rails also provided helpers for these two JavaScript frameworks so that a few method calls were all that you needed to make your application more fluid.&lt;br /&gt;
&lt;br /&gt;
Rails 3 introduces the idea of Unobtrusive JavaScript (UJS). The JavaScript becomes unobtrusive by not being written in with the HTML objects producing cleaner code that is easier to debug. This is mostly done with the utilization of HTML 5 custom attributes such as data-method, data-confirm, data-remote and data-disable-with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;http://host.com&amp;quot; id=&amp;quot;create-post&amp;quot; method=&amp;quot;post&amp;quot; data-remote=&amp;quot;true&amp;quot; data-confirm=&amp;quot;Are you sure you want to submit?&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By doing this, it also frees Rails from being dependent on the Prototype framework, allowing it to become ''JavaScript framework agnostic''. With its current implementation, the framework can support Prototype, jQuery and MooTools.&lt;br /&gt;
&lt;br /&gt;
It might also be helpful to point out that as of Rails 3.1, the jQuery framework has replaced Prototype as the default JavaScript framework. Programmers that wish to still use Prototype must remember to specify this when they create the Rails application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rails new myapp -j prototype&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
==Citation Notes==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Full Reference Information==&lt;br /&gt;
&lt;br /&gt;
Gadbois, John. ''Using Unobtrusive JavaScript and AJAX with Rails 3'' http://net.tutsplus.com/tutorials/javascript-ajax/using-unobtrusive-javascript-and-ajax-with-rails-3/ , 2010.&lt;br /&gt;
&lt;br /&gt;
Lindsaar, Mikel. &amp;quot;Ruby on Rails 3.0 Release Notes&amp;quot; http://edgeguides.rubyonrails.org/3_0_release_notes.html&lt;br /&gt;
&lt;br /&gt;
Naik, Pratik. &amp;quot;Active Record Query Interface 3.0&amp;quot; http://m.onkey.org/active-record-query-interface , 2010.&lt;br /&gt;
&lt;br /&gt;
Reza, Rizwan. &amp;quot;The Lowdown on Routes in Rails 3&amp;quot; http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/ , 2010.&lt;br /&gt;
&lt;br /&gt;
Ruby, Sam, Dave Thomas and David Hansson. ''Agile Web Development with Rails: Third Edition'': The Pragmatic Programmers LLC, 2009.&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=50334</id>
		<title>CSC/ECE 517 Fall 2011/ch2 2f mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=50334"/>
		<updated>2011-09-22T19:27:37Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
The original Ruby on Rails platform was extracted from the web-based project-management tool called Basecamp developed by 37signals. Ruby on Rails’ creator, David Heinemeier Hansson, began work on the Rails in early 2003 and released it as open source code in 2004, but it wasn’t until 2005 that Hansson shared commit rights to the project. [REFERENCE] Hansson designed Ruby on Rails to be an out of the box development framework that includes everything a programmer needs to create database-driven web applications according to the Model-View-Control pattern of separation. Ruby on Rails is based on the two key paradigms of Convention over Configuration [WIKI LINK] and Don’t Repeat Yourself (DRY) [WIKI LINK].&lt;br /&gt;
&lt;br /&gt;
=History of Rails Development=&lt;br /&gt;
Throughout the development of the Rails framework there have been four significant releases alongside of the usual patches, fixes, and upgrades. &lt;br /&gt;
&lt;br /&gt;
===Rails 1.0===&lt;br /&gt;
Initially, Rails 1.0 was released 15 months after the original source was made available. [REFERENCE] This version contained the structural foundation of what would become a powerful open source motivator for the Ruby platform.  Though there were patches and code adjustments in Rails 1.2 the next major release was Rails 2.0. &lt;br /&gt;
&lt;br /&gt;
===Rails 2.0 ===&lt;br /&gt;
Rails 2.0 was a major facelift for the framework and much of the effort went into improving the resources and polishing the overall package by making it more lean. Among some of these improvements was a focus on increasing security by adding a new module to work with HTTP Basic Authentication and providing a built-in mechanism for dealing with CRSF attacks. Other improvements were in the areas of changing certain syntactical nomenclature as well as simplifying the format for a few templates. &lt;br /&gt;
&lt;br /&gt;
===Rails 2.3===&lt;br /&gt;
The next major update was Rails 2.3 at it was the most structural update prior to Rails 3.0 being released. The two primary changes in the architecture of the Rails application was the complete integration of the Rack modular web server interface and a renewed support for Rails Engines. {link 2} Alongside of these changes were updates to templates, the addition of built-in support for HTTP Digest Authentication, nested forms models, Metal, and improved caching performance among other things.&lt;br /&gt;
&lt;br /&gt;
===Rails 3.0===&lt;br /&gt;
Between Rails 2.3 and the release of Rails 3.0, Rails announced that it would merge with Merb and that Rails 3.0 would be the successor to both Rails 2 and Merb. Merb which is short for Mongrel+Erb, key feature that prompted the join Rails was its component modularity, extensible API design, and vertical scalability.&lt;br /&gt;
&lt;br /&gt;
=Rails 2 vs. Rails 3=&lt;br /&gt;
&lt;br /&gt;
A lot changed in the update from Rails 2 to Rails 3. We will explore a few of the key areas that will affect a developer's everyday coding.&lt;br /&gt;
&lt;br /&gt;
==Rails Application Scripts==&lt;br /&gt;
&lt;br /&gt;
When you create a new Rails application, a directory named &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; is generated. In Rails 2, this directory is populated with a set of scripts that can be executed by the programmer. A few of the more important ones are as follows&amp;lt;ref&amp;gt;Ruby 2009, pp 257-258 &amp;lt;/ref&amp;gt;:&lt;br /&gt;
*&amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt;: Used to generate code for controllers, mailers, models, scaffolds and other sets of code.&lt;br /&gt;
*&amp;lt;tt&amp;gt;destroy&amp;lt;/tt&amp;gt;: Used to destroy code created by the &amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
*&amp;lt;tt&amp;gt;server&amp;lt;/tt&amp;gt;: Starts up the Rails application in a self-contained web server.&lt;br /&gt;
*&amp;lt;tt&amp;gt;plugin&amp;lt;/tt&amp;gt;: Helps with the installation and administration of plug-ins to the Rails framework.&lt;br /&gt;
*&amp;lt;tt&amp;gt;performance&amp;lt;/tt&amp;gt; directory: Contains scripts used by the programmer to help understand the performance characteristics of the application being built.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with all of these scripts and compiles them all into a single script named &amp;lt;tt&amp;gt;rails&amp;lt;/tt&amp;gt;. With this script, the programmer can access all of the functionality that was available with the separate scripts. To make things even easier, the necessity to call this script outright is even unnecessary. By using the operating systems installed &amp;lt;tt&amp;gt;'''rails'''&amp;lt;/tt&amp;gt; command (ex, &amp;lt;tt&amp;gt;/usr/bin/rails&amp;lt;/tt&amp;gt; on Linux systems) in the root of any Rails 3 application, it will know to call this script.&lt;br /&gt;
&lt;br /&gt;
==Gem Dependencies==&lt;br /&gt;
&lt;br /&gt;
The ability to extend the Rails framework using a Gem is a very powerful feature. In Rails 2, the &amp;lt;tt&amp;gt;config/environment.rb&amp;lt;/tt&amp;gt; file had to be edited in order to tell the Rails application to require specific Gems using the &amp;lt;tt&amp;gt;'''config.gem'''&amp;lt;/tt&amp;gt; method. To ensure that the Gems were actually installed on the system running the Rails application, the programmer had to execute the &amp;lt;tt&amp;gt;rake gem:install&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with the need to have that manual process of installing Gems by utilizing a file named &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; in the root of the application as well as the Bundler. The Bundler looks at the contents &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; and automatically installs any Gems that are missing from the system. This allows the programmer to focus on more important issues.&lt;br /&gt;
&lt;br /&gt;
==Routing DSL==&lt;br /&gt;
&lt;br /&gt;
The routing DSL for Rails went through a major reconditioning and has actually been renamed to Action Dispatch. This rewrite took the logic out of the Action Controller and is now a standalone piece of software resulting in a much cleaner implementation. As well, the definition of routes for each application are now named within your Application module instead of the Action Controller. The difference can be seen in the beginning line of the &amp;lt;tt&amp;gt;config/routes.rb&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
ActionController::Routing::Routes.draw do |map|&lt;br /&gt;
  map.resources :posts&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
AppName::Application.routes do&lt;br /&gt;
  resources :posts&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With all these changes, the &amp;lt;tt&amp;gt;config/routes.rb&amp;lt;/tt&amp;gt; file now has a new syntax. Here are some of the major differences&amp;lt;ref&amp;gt;Reza 2010&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Default Route===&lt;br /&gt;
&lt;br /&gt;
The differences between the default route are minor between the two versions, but the Rails 3 version is much more explicit, as the parentheses indicate parameters that are optional. Also worth noting is that this route is commented out in Rails 3 by default. The reasoning behind this is that there is a big push for a RESTful architecture with the Rails application and this type of route isn't really recommended for that kind of application. It can be uncommented but be warned that doing so will make all actions in every controller accessible via GET requests.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.connect ':controller/:action/:id'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match '/:controller(/:action(/:id))'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Regular Routes===&lt;br /&gt;
The way in which a regular route is defined is much more streamlined and readable. In Rails 2, you had to define a key for the controller and action. With Rails 3, this definition is streamlined with a &amp;lt;tt&amp;gt;:to&amp;lt;/tt&amp;gt; key where you define in a specific format the controller and action responsible for the request. Here is an example to illustrate this point:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.connect 'products/:id', :controller =&amp;gt; 'products', :action =&amp;gt; 'view'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match 'products/:id', :to =&amp;gt; 'catalog#view'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Named Routes===&lt;br /&gt;
Setting up named routes has changed a little bit as well. The rules for the regular routes apply here but the way that you define the name of the route has changed. Now, you utilize the &amp;lt;tt&amp;gt;:as&amp;lt;/tt&amp;gt; key to define the name of the route as shown here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.logout '/logout', :controller =&amp;gt; 'sessions', :action =&amp;gt; 'destroy'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match 'logout', :to =&amp;gt; 'sessions#destroy', :as =&amp;gt; &amp;quot;logout&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Empty Route===&lt;br /&gt;
The empty route defines where to route the application when a user navigates to the root of the website (for normal HTML sites, this is the same as the index page). Rails 2 had a quick way of defining it but in true Ruby fashion, Rails 3 makes it even simpler to define this route as you can see here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.root :controller =&amp;gt; &amp;quot;welcome&amp;quot;, :action =&amp;gt; 'show'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
root :to =&amp;gt; 'welcome#show'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===RESTful Resources===&lt;br /&gt;
RESTful resources are very important and have been a part of Rails since version 1.2. Utilizing the &amp;lt;tt&amp;gt;rails generate scaffold&amp;lt;/tt&amp;gt; command, Rails will generate the route, controller, views and model necessary to have the basic REST functionality for a model. As you can see from the following example, defining a RESTful route is simple in either version. Rails 3 grants you the ability to use this line for multiple resources as well, saving lines of code and making it more readable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.resources :products&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
# Single resource definition&lt;br /&gt;
resources :products&lt;br /&gt;
# Multiple resource definitions&lt;br /&gt;
resources :products, :categories, :comments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, Rails 3 provides you with the ability to extend the routing beyond the seven basic RESTful actions.  There are multiple ways in which you can extend this functionality:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Defining extra collection RESTful actions within a block.&lt;br /&gt;
resources :products do&lt;br /&gt;
  collection do&lt;br /&gt;
    get  :sold&lt;br /&gt;
    post :on_offer&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# An inline extension.&lt;br /&gt;
resources :products do&lt;br /&gt;
  get :sold, :on =&amp;gt; :member&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Active Record==&lt;br /&gt;
Active Record, like all of the core Rails components, got a major overhaul. &lt;br /&gt;
&lt;br /&gt;
===Arel and the Query Interface===&lt;br /&gt;
The most prominent changes made that will be apparent to developers will be the integration with [https://github.com/nkallen/arel Arel]. With this integration, all of the core methods for Active Record return relations, allowing them to be chained together to develop complex queries. A full list and their functionality can be found in the [http://guides.rubyonrails.org/active_record_querying.html Rails Guide]. This will take the place of the options hash that would normally get passed in to one of the Active Record methods. To illustrate this, say we wanted to get a list of the first 10 products ordered alphabetically:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
Product.find(:order =&amp;gt; &amp;quot;name DESC&amp;quot;, :limit =&amp;gt; 10)&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
Product.order(&amp;quot;name DESC&amp;quot;).limit(10)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, there are a lot of methods that are losing the options parameter in their definitions&amp;lt;ref&amp;gt;Naik 2010&amp;lt;/ref&amp;gt;, including query methods find and all as well as calculation methods count and average. Also, the &amp;lt;tt&amp;gt;:all&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;:first&amp;lt;/tt&amp;gt; parameters for the find method are being deprecated in favor of the &amp;lt;tt&amp;gt;all&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;first&amp;lt;/tt&amp;gt; methods. Here are some examples of how things are changing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Changes to the find method.&lt;br /&gt;
# Rails 2&lt;br /&gt;
Product.find(:all)&lt;br /&gt;
Product.find(:first)&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
Product.all&lt;br /&gt;
Product.first&lt;br /&gt;
&lt;br /&gt;
# Examples of method options being removed.&lt;br /&gt;
# Rails 2&lt;br /&gt;
Product.all(:joins =&amp;gt; :categories)&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
Product.joins(&amp;quot;categories&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Named Scopes===&lt;br /&gt;
The &amp;lt;tt&amp;gt;named_scope&amp;lt;/tt&amp;gt; definition has been changed to just &amp;lt;tt&amp;gt;scope&amp;lt;/tt&amp;gt;. The options hash is also being deprecated and should be replaced with the new methods provided by the Arel integration. Translating existing Rails 2 named scopes is easy enough:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
class Product&lt;br /&gt;
  named_scope :food, :conditions =&amp;gt; { :type =&amp;gt; &amp;quot;food&amp;quot; }&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
class Product&lt;br /&gt;
  scope :food, where(:type =&amp;gt; &amp;quot;food&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==JavaScript Support&amp;lt;ref&amp;gt;Gadbois 2010&amp;lt;/ref&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
There are many JavaScript libraries available to programmers to make their web applications more dynamic and smooth looking. Whenever you created a Rails 2 application, it would automatically install the Prototype and Script.aculo.us frameworks. Rails also provided helpers for these two JavaScript frameworks so that a few method calls were all that you needed to make your application more fluid.&lt;br /&gt;
&lt;br /&gt;
Rails 3 introduces the idea of Unobtrusive JavaScript (UJS). The JavaScript becomes unobtrusive by not being written in with the HTML objects producing cleaner code that is easier to debug. This is mostly done with the utilization of HTML 5 custom attributes such as data-method, data-confirm, data-remote and data-disable-with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;http://host.com&amp;quot; id=&amp;quot;create-post&amp;quot; method=&amp;quot;post&amp;quot; data-remote=&amp;quot;true&amp;quot; data-confirm=&amp;quot;Are you sure you want to submit?&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By doing this, it also frees Rails from being dependent on the Prototype framework, allowing it to become ''JavaScript framework agnostic''. With its current implementation, the framework can support Prototype, jQuery and MooTools.&lt;br /&gt;
&lt;br /&gt;
It might also be helpful to point out that as of Rails 3.1, the jQuery framework has replaced Prototype as the default JavaScript framework. Programmers that wish to still use Prototype must remember to specify this when they create the Rails application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rails new myapp -j prototype&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
==Citation Notes==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Full Reference Information==&lt;br /&gt;
&lt;br /&gt;
Gadbois, John. ''Using Unobtrusive JavaScript and AJAX with Rails 3'' http://net.tutsplus.com/tutorials/javascript-ajax/using-unobtrusive-javascript-and-ajax-with-rails-3/ , 2010.&lt;br /&gt;
&lt;br /&gt;
Lindsaar, Mikel. &amp;quot;Ruby on Rails 3.0 Release Notes&amp;quot; http://edgeguides.rubyonrails.org/3_0_release_notes.html&lt;br /&gt;
&lt;br /&gt;
Naik, Pratik. &amp;quot;Active Record Query Interface 3.0&amp;quot; http://m.onkey.org/active-record-query-interface , 2010.&lt;br /&gt;
&lt;br /&gt;
Reza, Rizwan. &amp;quot;The Lowdown on Routes in Rails 3&amp;quot; http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/ , 2010.&lt;br /&gt;
&lt;br /&gt;
Ruby, Sam, Dave Thomas and David Hansson. ''Agile Web Development with Rails: Third Edition'': The Pragmatic Programmers LLC, 2009.&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=50230</id>
		<title>CSC/ECE 517 Fall 2011/ch2 2f mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=50230"/>
		<updated>2011-09-22T04:20:36Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* Rails 2 vs. Rails 3 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
The original Ruby on Rail platform was extracted from the web-based project-management tool called Basecamp developed by 37signals. Ruby on Rails’ creator, David Heinemeier Hansson, began work on the Rails in early 2003 and released it as open source code in 2004, but it wasn’t until 2005 that Hansson shared commit rights to the project. [REFERENCE] Hansson designed Ruby on Rails to be an out of the box development framework that includes everything a programmer needs to create database-driven web applications according to the Model-View-Control pattern of separation. Ruby on Rails is based on the two key paradigms of Convention over Configuration [WIKI LINK] and Don’t Repeat Yourself (DRY) [WIKI LINK].&lt;br /&gt;
&lt;br /&gt;
=History of Rails Development=&lt;br /&gt;
Throughout the development of the Rails framework there have been four significant releases alongside of the usual patches, fixes, and upgrades. Initially, Rails 1.0 was released 15 months after the original source was made available. [REFERENCE] This version contained the structural foundation of what would become a powerful open source motivator for the Ruby platform.  Though there were patches and code adjustments in Rails 1.2 the next major release was Rails 2.0. &lt;br /&gt;
&lt;br /&gt;
Rails 2.0 was a major facelift for the framework and much of the effort went into improving the resources and polishing the overall package by making it more lean. Among some of these improvements was a focus on increasing security by adding a new module to work with HTTP Basic Authentication and providing a built-in mechanism for dealing with CRSF attacks. Other improvements were in the areas of changing certain syntactical nomenclature as well as simplifying the format for a few templates. &lt;br /&gt;
&lt;br /&gt;
The next major update before Rails 3.0 was Rails 2.3 at it was the most substantial update thus far…. not finished..&lt;br /&gt;
&lt;br /&gt;
=Rails 2 vs. Rails 3=&lt;br /&gt;
&lt;br /&gt;
A lot changed in the update from Rails 2 to Rails 3. We will explore a few of the key areas that will affect a developer's everyday coding.&lt;br /&gt;
&lt;br /&gt;
==Rails Application Scripts==&lt;br /&gt;
&lt;br /&gt;
When you create a new Rails application, a directory named &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; is generated. In Rails 2, this directory is populated with a set of scripts that can be executed by the programmer. A few of the more important ones are as follows&amp;lt;ref&amp;gt;Ruby 2009, pp 257-258 &amp;lt;/ref&amp;gt;:&lt;br /&gt;
*&amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt;: Used to generate code for controllers, mailers, models, scaffolds and other sets of code.&lt;br /&gt;
*&amp;lt;tt&amp;gt;destroy&amp;lt;/tt&amp;gt;: Used to destroy code created by the &amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
*&amp;lt;tt&amp;gt;server&amp;lt;/tt&amp;gt;: Starts up the Rails application in a self-contained web server.&lt;br /&gt;
*&amp;lt;tt&amp;gt;plugin&amp;lt;/tt&amp;gt;: Helps with the installation and administration of plug-ins to the Rails framework.&lt;br /&gt;
*&amp;lt;tt&amp;gt;performance&amp;lt;/tt&amp;gt; directory: Contains scripts used by the programmer to help understand the performance characteristics of the application being built.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with all of these scripts and compiles them all into a single script named &amp;lt;tt&amp;gt;rails&amp;lt;/tt&amp;gt;. With this script, the programmer can access all of the functionality that was available with the separate scripts. To make things even easier, the necessity to call this script outright is even unnecessary. By using the operating systems installed &amp;lt;tt&amp;gt;'''rails'''&amp;lt;/tt&amp;gt; command (ex, &amp;lt;tt&amp;gt;/usr/bin/rails&amp;lt;/tt&amp;gt; on Linux systems) in the root of any Rails 3 application, it will know to call this script.&lt;br /&gt;
&lt;br /&gt;
==Gem Dependencies==&lt;br /&gt;
&lt;br /&gt;
The ability to extend the Rails framework using a Gem is a very powerful feature. In Rails 2, the &amp;lt;tt&amp;gt;config/environment.rb&amp;lt;/tt&amp;gt; file had to be edited in order to tell the Rails application to require specific Gems using the &amp;lt;tt&amp;gt;'''config.gem'''&amp;lt;/tt&amp;gt; method. To ensure that the Gems were actually installed on the system running the Rails application, the programmer had to execute the &amp;lt;tt&amp;gt;rake gem:install&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with the need to have that manual process of installing Gems by utilizing a file named &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; in the root of the application as well as the Bundler. The Bundler looks at the contents &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; and automatically installs any Gems that are missing from the system. This allows the programmer to focus on more important issues.&lt;br /&gt;
&lt;br /&gt;
==Routing DSL==&lt;br /&gt;
&lt;br /&gt;
The routing DSL for Rails went through a major reconditioning and has actually been renamed to Action Dispatch. This rewrite took the logic out of the Action Controller and is now a standalone piece of software resulting in a much cleaner implementation. As well, the definition of routes for each application are now named within your Application module instead of the Action Controller. The difference can be seen in the beginning line of the &amp;lt;tt&amp;gt;config/routes.rb&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
ActionController::Routing::Routes.draw do |map|&lt;br /&gt;
  map.resources :posts&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
AppName::Application.routes do&lt;br /&gt;
  resources :posts&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With all these changes, the &amp;lt;tt&amp;gt;config/routes.rb&amp;lt;/tt&amp;gt; file now has a new syntax. Here are some of the major differences&amp;lt;ref&amp;gt;Reza 2010&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Default Route===&lt;br /&gt;
&lt;br /&gt;
The differences between the default route are minor between the two versions, but the Rails 3 version is much more explicit, as the parentheses indicate parameters that are optional. Also worth noting is that this route is commented out in Rails 3 by default. The reasoning behind this is that there is a big push for a RESTful architecture with the Rails application and this type of route isn't really recommended for that kind of application. It can be uncommented but be warned that doing so will make all actions in every controller accessible via GET requests.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.connect ':controller/:action/:id'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match '/:controller(/:action(/:id))'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Regular Routes===&lt;br /&gt;
The way in which a regular route is defined is much more streamlined and readable. In Rails 2, you had to define a key for the controller and action. With Rails 3, this definition is streamlined with a &amp;lt;tt&amp;gt;:to&amp;lt;/tt&amp;gt; key where you define in a specific format the controller and action responsible for the request. Here is an example to illustrate this point:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.connect 'products/:id', :controller =&amp;gt; 'products', :action =&amp;gt; 'view'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match 'products/:id', :to =&amp;gt; 'catalog#view'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Named Routes===&lt;br /&gt;
Setting up named routes has changed a little bit as well. The rules for the regular routes apply here but the way that you define the name of the route has changed. Now, you utilize the &amp;lt;tt&amp;gt;:as&amp;lt;/tt&amp;gt; key to define the name of the route as shown here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.logout '/logout', :controller =&amp;gt; 'sessions', :action =&amp;gt; 'destroy'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match 'logout', :to =&amp;gt; 'sessions#destroy', :as =&amp;gt; &amp;quot;logout&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Empty Route===&lt;br /&gt;
The empty route defines where to route the application when a user navigates to the root of the website (for normal HTML sites, this is the same as the index page). Rails 2 had a quick way of defining it but in true Ruby fashion, Rails 3 makes it even simpler to define this route as you can see here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.root :controller =&amp;gt; &amp;quot;welcome&amp;quot;, :action =&amp;gt; 'show'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
root :to =&amp;gt; 'welcome#show'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===RESTful Resources===&lt;br /&gt;
RESTful resources are very important and have been a part of Rails since version 1.2. Utilizing the &amp;lt;tt&amp;gt;rails generate scaffold&amp;lt;/tt&amp;gt; command, Rails will generate the route, controller, views and model necessary to have the basic REST functionality for a model. As you can see from the following example, defining a RESTful route is simple in either version. Rails 3 grants you the ability to use this line for multiple resources as well, saving lines of code and making it more readable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.resources :products&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
# Single resource definition&lt;br /&gt;
resources :products&lt;br /&gt;
# Multiple resource definitions&lt;br /&gt;
resources :products, :categories, :comments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, Rails 3 provides you with the ability to extend the routing beyond the seven basic RESTful actions.  There are multiple ways in which you can extend this functionality:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Defining extra collection RESTful actions within a block.&lt;br /&gt;
resources :products do&lt;br /&gt;
  collection do&lt;br /&gt;
    get  :sold&lt;br /&gt;
    post :on_offer&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# An inline extension.&lt;br /&gt;
resources :products do&lt;br /&gt;
  get :sold, :on =&amp;gt; :member&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Active Record==&lt;br /&gt;
Active Record, like all of the core Rails components, got a major overhaul. &lt;br /&gt;
&lt;br /&gt;
===Arel and the Query Interface===&lt;br /&gt;
The most prominent changes made that will be apparent to developers will be the integration with [https://github.com/nkallen/arel Arel]. With this integration, all of the core methods for Active Record return relations, allowing them to be chained together to develop complex queries. A full list and their functionality can be found in the [http://guides.rubyonrails.org/active_record_querying.html Rails Guide]. This will take the place of the options hash that would normally get passed in to one of the Active Record methods. To illustrate this, say we wanted to get a list of the first 10 products ordered alphabetically:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
Product.find(:order =&amp;gt; &amp;quot;name DESC&amp;quot;, :limit =&amp;gt; 10)&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
Product.order(&amp;quot;name DESC&amp;quot;).limit(10)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, there are a lot of methods that are losing the options parameter in their definitions&amp;lt;ref&amp;gt;Naik 2010&amp;lt;/ref&amp;gt;, including query methods find and all as well as calculation methods count and average. Also, the &amp;lt;tt&amp;gt;:all&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;:first&amp;lt;/tt&amp;gt; parameters for the find method are being deprecated in favor of the &amp;lt;tt&amp;gt;all&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;first&amp;lt;/tt&amp;gt; methods. Here are some examples of how things are changing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Changes to the find method.&lt;br /&gt;
# Rails 2&lt;br /&gt;
Product.find(:all)&lt;br /&gt;
Product.find(:first)&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
Product.all&lt;br /&gt;
Product.first&lt;br /&gt;
&lt;br /&gt;
# Examples of method options being removed.&lt;br /&gt;
# Rails 2&lt;br /&gt;
Product.all(:joins =&amp;gt; :categories)&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
Product.joins(&amp;quot;categories&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Named Scopes===&lt;br /&gt;
The &amp;lt;tt&amp;gt;named_scope&amp;lt;/tt&amp;gt; definition has been changed to just &amp;lt;tt&amp;gt;scope&amp;lt;/tt&amp;gt;. The options hash is also being deprecated and should be replaced with the new methods provided by the Arel integration. Translating existing Rails 2 named scopes is easy enough:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
class Product&lt;br /&gt;
  named_scope :food, :conditions =&amp;gt; { :type =&amp;gt; &amp;quot;food&amp;quot; }&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
class Product&lt;br /&gt;
  scope :food, where(:type =&amp;gt; &amp;quot;food&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==JavaScript Support&amp;lt;ref&amp;gt;Gadbois 2010&amp;lt;/ref&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
There are many JavaScript libraries available to programmers to make their web applications more dynamic and smooth looking. Whenever you created a Rails 2 application, it would automatically install the Prototype and Script.aculo.us frameworks. Rails also provided helpers for these two JavaScript frameworks so that a few method calls were all that you needed to make your application more fluid.&lt;br /&gt;
&lt;br /&gt;
Rails 3 introduces the idea of Unobtrusive JavaScript (UJS). The JavaScript becomes unobtrusive by not being written in with the HTML objects producing cleaner code that is easier to debug. This is mostly done with the utilization of HTML 5 custom attributes such as data-method, data-confirm, data-remote and data-disable-with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;http://host.com&amp;quot; id=&amp;quot;create-post&amp;quot; method=&amp;quot;post&amp;quot; data-remote=&amp;quot;true&amp;quot; data-confirm=&amp;quot;Are you sure you want to submit?&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By doing this, it also frees Rails from being dependent on the Prototype framework, allowing it to become ''JavaScript framework agnostic''. With its current implementation, the framework can support Prototype, jQuery and MooTools.&lt;br /&gt;
&lt;br /&gt;
It might also be helpful to point out that as of Rails 3.1, the jQuery framework has replaced Prototype as the default JavaScript framework. Programmers that wish to still use Prototype must remember to specify this when they create the Rails application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rails new myapp -j prototype&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
==Citation Notes==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Full Reference Information==&lt;br /&gt;
&lt;br /&gt;
Gadbois, John. ''Using Unobtrusive JavaScript and AJAX with Rails 3'' http://net.tutsplus.com/tutorials/javascript-ajax/using-unobtrusive-javascript-and-ajax-with-rails-3/ , 2010.&lt;br /&gt;
&lt;br /&gt;
Lindsaar, Mikel. &amp;quot;Ruby on Rails 3.0 Release Notes&amp;quot; http://edgeguides.rubyonrails.org/3_0_release_notes.html&lt;br /&gt;
&lt;br /&gt;
Naik, Pratik. &amp;quot;Active Record Query Interface 3.0&amp;quot; http://m.onkey.org/active-record-query-interface , 2010.&lt;br /&gt;
&lt;br /&gt;
Reza, Rizwan. &amp;quot;The Lowdown on Routes in Rails 3&amp;quot; http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/ , 2010.&lt;br /&gt;
&lt;br /&gt;
Ruby, Sam, Dave Thomas and David Hansson. ''Agile Web Development with Rails: Third Edition'': The Pragmatic Programmers LLC, 2009.&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=50228</id>
		<title>CSC/ECE 517 Fall 2011/ch2 2f mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=50228"/>
		<updated>2011-09-22T04:19:47Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* Full Reference Information */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
The original Ruby on Rail platform was extracted from the web-based project-management tool called Basecamp developed by 37signals. Ruby on Rails’ creator, David Heinemeier Hansson, began work on the Rails in early 2003 and released it as open source code in 2004, but it wasn’t until 2005 that Hansson shared commit rights to the project. [REFERENCE] Hansson designed Ruby on Rails to be an out of the box development framework that includes everything a programmer needs to create database-driven web applications according to the Model-View-Control pattern of separation. Ruby on Rails is based on the two key paradigms of Convention over Configuration [WIKI LINK] and Don’t Repeat Yourself (DRY) [WIKI LINK].&lt;br /&gt;
&lt;br /&gt;
=History of Rails Development=&lt;br /&gt;
Throughout the development of the Rails framework there have been four significant releases alongside of the usual patches, fixes, and upgrades. Initially, Rails 1.0 was released 15 months after the original source was made available. [REFERENCE] This version contained the structural foundation of what would become a powerful open source motivator for the Ruby platform.  Though there were patches and code adjustments in Rails 1.2 the next major release was Rails 2.0. &lt;br /&gt;
&lt;br /&gt;
Rails 2.0 was a major facelift for the framework and much of the effort went into improving the resources and polishing the overall package by making it more lean. Among some of these improvements was a focus on increasing security by adding a new module to work with HTTP Basic Authentication and providing a built-in mechanism for dealing with CRSF attacks. Other improvements were in the areas of changing certain syntactical nomenclature as well as simplifying the format for a few templates. &lt;br /&gt;
&lt;br /&gt;
The next major update before Rails 3.0 was Rails 2.3 at it was the most substantial update thus far…. not finished..&lt;br /&gt;
&lt;br /&gt;
=Rails 2 vs. Rails 3=&lt;br /&gt;
&lt;br /&gt;
A lot changed in the update from Rails 2 to Rails 3. We will explore a few of the key areas that will affect a programmer's everyday coding.&lt;br /&gt;
&lt;br /&gt;
==Rails Application Scripts==&lt;br /&gt;
&lt;br /&gt;
When you create a new Rails application, a directory named &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; is generated. In Rails 2, this directory is populated with a set of scripts that can be executed by the programmer. A few of the more important ones are as follows&amp;lt;ref&amp;gt;Ruby 2009, pp 257-258 &amp;lt;/ref&amp;gt;:&lt;br /&gt;
*&amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt;: Used to generate code for controllers, mailers, models, scaffolds and other sets of code.&lt;br /&gt;
*&amp;lt;tt&amp;gt;destroy&amp;lt;/tt&amp;gt;: Used to destroy code created by the &amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
*&amp;lt;tt&amp;gt;server&amp;lt;/tt&amp;gt;: Starts up the Rails application in a self-contained web server.&lt;br /&gt;
*&amp;lt;tt&amp;gt;plugin&amp;lt;/tt&amp;gt;: Helps with the installation and administration of plug-ins to the Rails framework.&lt;br /&gt;
*&amp;lt;tt&amp;gt;performance&amp;lt;/tt&amp;gt; directory: Contains scripts used by the programmer to help understand the performance characteristics of the application being built.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with all of these scripts and compiles them all into a single script named &amp;lt;tt&amp;gt;rails&amp;lt;/tt&amp;gt;. With this script, the programmer can access all of the functionality that was available with the separate scripts. To make things even easier, the necessity to call this script outright is even unnecessary. By using the operating systems installed &amp;lt;tt&amp;gt;'''rails'''&amp;lt;/tt&amp;gt; command (ex, &amp;lt;tt&amp;gt;/usr/bin/rails&amp;lt;/tt&amp;gt; on Linux systems) in the root of any Rails 3 application, it will know to call this script.&lt;br /&gt;
&lt;br /&gt;
==Gem Dependencies==&lt;br /&gt;
&lt;br /&gt;
The ability to extend the Rails framework using a Gem is a very powerful feature. In Rails 2, the &amp;lt;tt&amp;gt;config/environment.rb&amp;lt;/tt&amp;gt; file had to be edited in order to tell the Rails application to require specific Gems using the &amp;lt;tt&amp;gt;'''config.gem'''&amp;lt;/tt&amp;gt; method. To ensure that the Gems were actually installed on the system running the Rails application, the programmer had to execute the &amp;lt;tt&amp;gt;rake gem:install&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with the need to have that manual process of installing Gems by utilizing a file named &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; in the root of the application as well as the Bundler. The Bundler looks at the contents &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; and automatically installs any Gems that are missing from the system. This allows the programmer to focus on more important issues.&lt;br /&gt;
&lt;br /&gt;
==Routing DSL==&lt;br /&gt;
&lt;br /&gt;
The routing DSL for Rails went through a major reconditioning and has actually been renamed to Action Dispatch. This rewrite took the logic out of the Action Controller and is now a standalone piece of software resulting in a much cleaner implementation. As well, the definition of routes for each application are now named within your Application module instead of the Action Controller. The difference can be seen in the beginning line of the &amp;lt;tt&amp;gt;config/routes.rb&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
ActionController::Routing::Routes.draw do |map|&lt;br /&gt;
  map.resources :posts&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
AppName::Application.routes do&lt;br /&gt;
  resources :posts&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With all these changes, the &amp;lt;tt&amp;gt;config/routes.rb&amp;lt;/tt&amp;gt; file now has a new syntax. Here are some of the major differences&amp;lt;ref&amp;gt;Reza 2010&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Default Route===&lt;br /&gt;
&lt;br /&gt;
The differences between the default route are minor between the two versions, but the Rails 3 version is much more explicit, as the parentheses indicate parameters that are optional. Also worth noting is that this route is commented out in Rails 3 by default. The reasoning behind this is that there is a big push for a RESTful architecture with the Rails application and this type of route isn't really recommended for that kind of application. It can be uncommented but be warned that doing so will make all actions in every controller accessible via GET requests.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.connect ':controller/:action/:id'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match '/:controller(/:action(/:id))'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Regular Routes===&lt;br /&gt;
The way in which a regular route is defined is much more streamlined and readable. In Rails 2, you had to define a key for the controller and action. With Rails 3, this definition is streamlined with a &amp;lt;tt&amp;gt;:to&amp;lt;/tt&amp;gt; key where you define in a specific format the controller and action responsible for the request. Here is an example to illustrate this point:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.connect 'products/:id', :controller =&amp;gt; 'products', :action =&amp;gt; 'view'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match 'products/:id', :to =&amp;gt; 'catalog#view'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Named Routes===&lt;br /&gt;
Setting up named routes has changed a little bit as well. The rules for the regular routes apply here but the way that you define the name of the route has changed. Now, you utilize the &amp;lt;tt&amp;gt;:as&amp;lt;/tt&amp;gt; key to define the name of the route as shown here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.logout '/logout', :controller =&amp;gt; 'sessions', :action =&amp;gt; 'destroy'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match 'logout', :to =&amp;gt; 'sessions#destroy', :as =&amp;gt; &amp;quot;logout&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Empty Route===&lt;br /&gt;
The empty route defines where to route the application when a user navigates to the root of the website (for normal HTML sites, this is the same as the index page). Rails 2 had a quick way of defining it but in true Ruby fashion, Rails 3 makes it even simpler to define this route as you can see here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.root :controller =&amp;gt; &amp;quot;welcome&amp;quot;, :action =&amp;gt; 'show'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
root :to =&amp;gt; 'welcome#show'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===RESTful Resources===&lt;br /&gt;
RESTful resources are very important and have been a part of Rails since version 1.2. Utilizing the &amp;lt;tt&amp;gt;rails generate scaffold&amp;lt;/tt&amp;gt; command, Rails will generate the route, controller, views and model necessary to have the basic REST functionality for a model. As you can see from the following example, defining a RESTful route is simple in either version. Rails 3 grants you the ability to use this line for multiple resources as well, saving lines of code and making it more readable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.resources :products&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
# Single resource definition&lt;br /&gt;
resources :products&lt;br /&gt;
# Multiple resource definitions&lt;br /&gt;
resources :products, :categories, :comments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, Rails 3 provides you with the ability to extend the routing beyond the seven basic RESTful actions.  There are multiple ways in which you can extend this functionality:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Defining extra collection RESTful actions within a block.&lt;br /&gt;
resources :products do&lt;br /&gt;
  collection do&lt;br /&gt;
    get  :sold&lt;br /&gt;
    post :on_offer&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# An inline extension.&lt;br /&gt;
resources :products do&lt;br /&gt;
  get :sold, :on =&amp;gt; :member&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Active Record==&lt;br /&gt;
Active Record, like all of the core Rails components, got a major overhaul. &lt;br /&gt;
&lt;br /&gt;
===Arel and the Query Interface===&lt;br /&gt;
The most prominent changes made that will be apparent to developers will be the integration with [https://github.com/nkallen/arel Arel]. With this integration, all of the core methods for Active Record return relations, allowing them to be chained together to develop complex queries. A full list and their functionality can be found in the [http://guides.rubyonrails.org/active_record_querying.html Rails Guide]. This will take the place of the options hash that would normally get passed in to one of the Active Record methods. To illustrate this, say we wanted to get a list of the first 10 products ordered alphabetically:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
Product.find(:order =&amp;gt; &amp;quot;name DESC&amp;quot;, :limit =&amp;gt; 10)&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
Product.order(&amp;quot;name DESC&amp;quot;).limit(10)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, there are a lot of methods that are losing the options parameter in their definitions&amp;lt;ref&amp;gt;Naik 2010&amp;lt;/ref&amp;gt;, including query methods find and all as well as calculation methods count and average. Also, the &amp;lt;tt&amp;gt;:all&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;:first&amp;lt;/tt&amp;gt; parameters for the find method are being deprecated in favor of the &amp;lt;tt&amp;gt;all&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;first&amp;lt;/tt&amp;gt; methods. Here are some examples of how things are changing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Changes to the find method.&lt;br /&gt;
# Rails 2&lt;br /&gt;
Product.find(:all)&lt;br /&gt;
Product.find(:first)&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
Product.all&lt;br /&gt;
Product.first&lt;br /&gt;
&lt;br /&gt;
# Examples of method options being removed.&lt;br /&gt;
# Rails 2&lt;br /&gt;
Product.all(:joins =&amp;gt; :categories)&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
Product.joins(&amp;quot;categories&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Named Scopes===&lt;br /&gt;
The &amp;lt;tt&amp;gt;named_scope&amp;lt;/tt&amp;gt; definition has been changed to just &amp;lt;tt&amp;gt;scope&amp;lt;/tt&amp;gt;. The options hash is also being deprecated and should be replaced with the new methods provided by the Arel integration. Translating existing Rails 2 named scopes is easy enough:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
class Product&lt;br /&gt;
  named_scope :food, :conditions =&amp;gt; { :type =&amp;gt; &amp;quot;food&amp;quot; }&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
class Product&lt;br /&gt;
  scope :food, where(:type =&amp;gt; &amp;quot;food&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==JavaScript Support&amp;lt;ref&amp;gt;Gadbois 2010&amp;lt;/ref&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
There are many JavaScript libraries available to programmers to make their web applications more dynamic and smooth looking. Whenever you created a Rails 2 application, it would automatically install the Prototype and Script.aculo.us frameworks. Rails also provided helpers for these two JavaScript frameworks so that a few method calls were all that you needed to make your application more fluid.&lt;br /&gt;
&lt;br /&gt;
Rails 3 introduces the idea of Unobtrusive JavaScript (UJS). The JavaScript becomes unobtrusive by not being written in with the HTML objects producing cleaner code that is easier to debug. This is mostly done with the utilization of HTML 5 custom attributes such as data-method, data-confirm, data-remote and data-disable-with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;http://host.com&amp;quot; id=&amp;quot;create-post&amp;quot; method=&amp;quot;post&amp;quot; data-remote=&amp;quot;true&amp;quot; data-confirm=&amp;quot;Are you sure you want to submit?&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By doing this, it also frees Rails from being dependent on the Prototype framework, allowing it to become ''JavaScript framework agnostic''. With its current implementation, the framework can support Prototype, jQuery and MooTools.&lt;br /&gt;
&lt;br /&gt;
It might also be helpful to point out that as of Rails 3.1, the jQuery framework has replaced Prototype as the default JavaScript framework. Programmers that wish to still use Prototype must remember to specify this when they create the Rails application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rails new myapp -j prototype&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
==Citation Notes==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Full Reference Information==&lt;br /&gt;
&lt;br /&gt;
Gadbois, John. ''Using Unobtrusive JavaScript and AJAX with Rails 3'' http://net.tutsplus.com/tutorials/javascript-ajax/using-unobtrusive-javascript-and-ajax-with-rails-3/ , 2010.&lt;br /&gt;
&lt;br /&gt;
Lindsaar, Mikel. &amp;quot;Ruby on Rails 3.0 Release Notes&amp;quot; http://edgeguides.rubyonrails.org/3_0_release_notes.html&lt;br /&gt;
&lt;br /&gt;
Naik, Pratik. &amp;quot;Active Record Query Interface 3.0&amp;quot; http://m.onkey.org/active-record-query-interface , 2010.&lt;br /&gt;
&lt;br /&gt;
Reza, Rizwan. &amp;quot;The Lowdown on Routes in Rails 3&amp;quot; http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/ , 2010.&lt;br /&gt;
&lt;br /&gt;
Ruby, Sam, Dave Thomas and David Hansson. ''Agile Web Development with Rails: Third Edition'': The Pragmatic Programmers LLC, 2009.&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=50227</id>
		<title>CSC/ECE 517 Fall 2011/ch2 2f mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=50227"/>
		<updated>2011-09-22T04:18:46Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* Arel and the Query Interface */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
The original Ruby on Rail platform was extracted from the web-based project-management tool called Basecamp developed by 37signals. Ruby on Rails’ creator, David Heinemeier Hansson, began work on the Rails in early 2003 and released it as open source code in 2004, but it wasn’t until 2005 that Hansson shared commit rights to the project. [REFERENCE] Hansson designed Ruby on Rails to be an out of the box development framework that includes everything a programmer needs to create database-driven web applications according to the Model-View-Control pattern of separation. Ruby on Rails is based on the two key paradigms of Convention over Configuration [WIKI LINK] and Don’t Repeat Yourself (DRY) [WIKI LINK].&lt;br /&gt;
&lt;br /&gt;
=History of Rails Development=&lt;br /&gt;
Throughout the development of the Rails framework there have been four significant releases alongside of the usual patches, fixes, and upgrades. Initially, Rails 1.0 was released 15 months after the original source was made available. [REFERENCE] This version contained the structural foundation of what would become a powerful open source motivator for the Ruby platform.  Though there were patches and code adjustments in Rails 1.2 the next major release was Rails 2.0. &lt;br /&gt;
&lt;br /&gt;
Rails 2.0 was a major facelift for the framework and much of the effort went into improving the resources and polishing the overall package by making it more lean. Among some of these improvements was a focus on increasing security by adding a new module to work with HTTP Basic Authentication and providing a built-in mechanism for dealing with CRSF attacks. Other improvements were in the areas of changing certain syntactical nomenclature as well as simplifying the format for a few templates. &lt;br /&gt;
&lt;br /&gt;
The next major update before Rails 3.0 was Rails 2.3 at it was the most substantial update thus far…. not finished..&lt;br /&gt;
&lt;br /&gt;
=Rails 2 vs. Rails 3=&lt;br /&gt;
&lt;br /&gt;
A lot changed in the update from Rails 2 to Rails 3. We will explore a few of the key areas that will affect a programmer's everyday coding.&lt;br /&gt;
&lt;br /&gt;
==Rails Application Scripts==&lt;br /&gt;
&lt;br /&gt;
When you create a new Rails application, a directory named &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; is generated. In Rails 2, this directory is populated with a set of scripts that can be executed by the programmer. A few of the more important ones are as follows&amp;lt;ref&amp;gt;Ruby 2009, pp 257-258 &amp;lt;/ref&amp;gt;:&lt;br /&gt;
*&amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt;: Used to generate code for controllers, mailers, models, scaffolds and other sets of code.&lt;br /&gt;
*&amp;lt;tt&amp;gt;destroy&amp;lt;/tt&amp;gt;: Used to destroy code created by the &amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
*&amp;lt;tt&amp;gt;server&amp;lt;/tt&amp;gt;: Starts up the Rails application in a self-contained web server.&lt;br /&gt;
*&amp;lt;tt&amp;gt;plugin&amp;lt;/tt&amp;gt;: Helps with the installation and administration of plug-ins to the Rails framework.&lt;br /&gt;
*&amp;lt;tt&amp;gt;performance&amp;lt;/tt&amp;gt; directory: Contains scripts used by the programmer to help understand the performance characteristics of the application being built.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with all of these scripts and compiles them all into a single script named &amp;lt;tt&amp;gt;rails&amp;lt;/tt&amp;gt;. With this script, the programmer can access all of the functionality that was available with the separate scripts. To make things even easier, the necessity to call this script outright is even unnecessary. By using the operating systems installed &amp;lt;tt&amp;gt;'''rails'''&amp;lt;/tt&amp;gt; command (ex, &amp;lt;tt&amp;gt;/usr/bin/rails&amp;lt;/tt&amp;gt; on Linux systems) in the root of any Rails 3 application, it will know to call this script.&lt;br /&gt;
&lt;br /&gt;
==Gem Dependencies==&lt;br /&gt;
&lt;br /&gt;
The ability to extend the Rails framework using a Gem is a very powerful feature. In Rails 2, the &amp;lt;tt&amp;gt;config/environment.rb&amp;lt;/tt&amp;gt; file had to be edited in order to tell the Rails application to require specific Gems using the &amp;lt;tt&amp;gt;'''config.gem'''&amp;lt;/tt&amp;gt; method. To ensure that the Gems were actually installed on the system running the Rails application, the programmer had to execute the &amp;lt;tt&amp;gt;rake gem:install&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with the need to have that manual process of installing Gems by utilizing a file named &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; in the root of the application as well as the Bundler. The Bundler looks at the contents &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; and automatically installs any Gems that are missing from the system. This allows the programmer to focus on more important issues.&lt;br /&gt;
&lt;br /&gt;
==Routing DSL==&lt;br /&gt;
&lt;br /&gt;
The routing DSL for Rails went through a major reconditioning and has actually been renamed to Action Dispatch. This rewrite took the logic out of the Action Controller and is now a standalone piece of software resulting in a much cleaner implementation. As well, the definition of routes for each application are now named within your Application module instead of the Action Controller. The difference can be seen in the beginning line of the &amp;lt;tt&amp;gt;config/routes.rb&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
ActionController::Routing::Routes.draw do |map|&lt;br /&gt;
  map.resources :posts&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
AppName::Application.routes do&lt;br /&gt;
  resources :posts&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With all these changes, the &amp;lt;tt&amp;gt;config/routes.rb&amp;lt;/tt&amp;gt; file now has a new syntax. Here are some of the major differences&amp;lt;ref&amp;gt;Reza 2010&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Default Route===&lt;br /&gt;
&lt;br /&gt;
The differences between the default route are minor between the two versions, but the Rails 3 version is much more explicit, as the parentheses indicate parameters that are optional. Also worth noting is that this route is commented out in Rails 3 by default. The reasoning behind this is that there is a big push for a RESTful architecture with the Rails application and this type of route isn't really recommended for that kind of application. It can be uncommented but be warned that doing so will make all actions in every controller accessible via GET requests.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.connect ':controller/:action/:id'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match '/:controller(/:action(/:id))'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Regular Routes===&lt;br /&gt;
The way in which a regular route is defined is much more streamlined and readable. In Rails 2, you had to define a key for the controller and action. With Rails 3, this definition is streamlined with a &amp;lt;tt&amp;gt;:to&amp;lt;/tt&amp;gt; key where you define in a specific format the controller and action responsible for the request. Here is an example to illustrate this point:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.connect 'products/:id', :controller =&amp;gt; 'products', :action =&amp;gt; 'view'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match 'products/:id', :to =&amp;gt; 'catalog#view'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Named Routes===&lt;br /&gt;
Setting up named routes has changed a little bit as well. The rules for the regular routes apply here but the way that you define the name of the route has changed. Now, you utilize the &amp;lt;tt&amp;gt;:as&amp;lt;/tt&amp;gt; key to define the name of the route as shown here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.logout '/logout', :controller =&amp;gt; 'sessions', :action =&amp;gt; 'destroy'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match 'logout', :to =&amp;gt; 'sessions#destroy', :as =&amp;gt; &amp;quot;logout&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Empty Route===&lt;br /&gt;
The empty route defines where to route the application when a user navigates to the root of the website (for normal HTML sites, this is the same as the index page). Rails 2 had a quick way of defining it but in true Ruby fashion, Rails 3 makes it even simpler to define this route as you can see here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.root :controller =&amp;gt; &amp;quot;welcome&amp;quot;, :action =&amp;gt; 'show'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
root :to =&amp;gt; 'welcome#show'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===RESTful Resources===&lt;br /&gt;
RESTful resources are very important and have been a part of Rails since version 1.2. Utilizing the &amp;lt;tt&amp;gt;rails generate scaffold&amp;lt;/tt&amp;gt; command, Rails will generate the route, controller, views and model necessary to have the basic REST functionality for a model. As you can see from the following example, defining a RESTful route is simple in either version. Rails 3 grants you the ability to use this line for multiple resources as well, saving lines of code and making it more readable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.resources :products&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
# Single resource definition&lt;br /&gt;
resources :products&lt;br /&gt;
# Multiple resource definitions&lt;br /&gt;
resources :products, :categories, :comments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, Rails 3 provides you with the ability to extend the routing beyond the seven basic RESTful actions.  There are multiple ways in which you can extend this functionality:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Defining extra collection RESTful actions within a block.&lt;br /&gt;
resources :products do&lt;br /&gt;
  collection do&lt;br /&gt;
    get  :sold&lt;br /&gt;
    post :on_offer&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# An inline extension.&lt;br /&gt;
resources :products do&lt;br /&gt;
  get :sold, :on =&amp;gt; :member&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Active Record==&lt;br /&gt;
Active Record, like all of the core Rails components, got a major overhaul. &lt;br /&gt;
&lt;br /&gt;
===Arel and the Query Interface===&lt;br /&gt;
The most prominent changes made that will be apparent to developers will be the integration with [https://github.com/nkallen/arel Arel]. With this integration, all of the core methods for Active Record return relations, allowing them to be chained together to develop complex queries. A full list and their functionality can be found in the [http://guides.rubyonrails.org/active_record_querying.html Rails Guide]. This will take the place of the options hash that would normally get passed in to one of the Active Record methods. To illustrate this, say we wanted to get a list of the first 10 products ordered alphabetically:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
Product.find(:order =&amp;gt; &amp;quot;name DESC&amp;quot;, :limit =&amp;gt; 10)&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
Product.order(&amp;quot;name DESC&amp;quot;).limit(10)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, there are a lot of methods that are losing the options parameter in their definitions&amp;lt;ref&amp;gt;Naik 2010&amp;lt;/ref&amp;gt;, including query methods find and all as well as calculation methods count and average. Also, the &amp;lt;tt&amp;gt;:all&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;:first&amp;lt;/tt&amp;gt; parameters for the find method are being deprecated in favor of the &amp;lt;tt&amp;gt;all&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;first&amp;lt;/tt&amp;gt; methods. Here are some examples of how things are changing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Changes to the find method.&lt;br /&gt;
# Rails 2&lt;br /&gt;
Product.find(:all)&lt;br /&gt;
Product.find(:first)&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
Product.all&lt;br /&gt;
Product.first&lt;br /&gt;
&lt;br /&gt;
# Examples of method options being removed.&lt;br /&gt;
# Rails 2&lt;br /&gt;
Product.all(:joins =&amp;gt; :categories)&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
Product.joins(&amp;quot;categories&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Named Scopes===&lt;br /&gt;
The &amp;lt;tt&amp;gt;named_scope&amp;lt;/tt&amp;gt; definition has been changed to just &amp;lt;tt&amp;gt;scope&amp;lt;/tt&amp;gt;. The options hash is also being deprecated and should be replaced with the new methods provided by the Arel integration. Translating existing Rails 2 named scopes is easy enough:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
class Product&lt;br /&gt;
  named_scope :food, :conditions =&amp;gt; { :type =&amp;gt; &amp;quot;food&amp;quot; }&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
class Product&lt;br /&gt;
  scope :food, where(:type =&amp;gt; &amp;quot;food&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==JavaScript Support&amp;lt;ref&amp;gt;Gadbois 2010&amp;lt;/ref&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
There are many JavaScript libraries available to programmers to make their web applications more dynamic and smooth looking. Whenever you created a Rails 2 application, it would automatically install the Prototype and Script.aculo.us frameworks. Rails also provided helpers for these two JavaScript frameworks so that a few method calls were all that you needed to make your application more fluid.&lt;br /&gt;
&lt;br /&gt;
Rails 3 introduces the idea of Unobtrusive JavaScript (UJS). The JavaScript becomes unobtrusive by not being written in with the HTML objects producing cleaner code that is easier to debug. This is mostly done with the utilization of HTML 5 custom attributes such as data-method, data-confirm, data-remote and data-disable-with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;http://host.com&amp;quot; id=&amp;quot;create-post&amp;quot; method=&amp;quot;post&amp;quot; data-remote=&amp;quot;true&amp;quot; data-confirm=&amp;quot;Are you sure you want to submit?&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By doing this, it also frees Rails from being dependent on the Prototype framework, allowing it to become ''JavaScript framework agnostic''. With its current implementation, the framework can support Prototype, jQuery and MooTools.&lt;br /&gt;
&lt;br /&gt;
It might also be helpful to point out that as of Rails 3.1, the jQuery framework has replaced Prototype as the default JavaScript framework. Programmers that wish to still use Prototype must remember to specify this when they create the Rails application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rails new myapp -j prototype&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
==Citation Notes==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Full Reference Information==&lt;br /&gt;
&lt;br /&gt;
Gadbois, John. ''Using Unobtrusive JavaScript and AJAX with Rails 3'' http://net.tutsplus.com/tutorials/javascript-ajax/using-unobtrusive-javascript-and-ajax-with-rails-3/ , 2010.&lt;br /&gt;
&lt;br /&gt;
Lindsaar, Mikel. &amp;quot;Ruby on Rails 3.0 Release Notes&amp;quot; http://edgeguides.rubyonrails.org/3_0_release_notes.html&lt;br /&gt;
&lt;br /&gt;
Reza, Rizwan. &amp;quot;The Lowdown on Routes in Rails 3&amp;quot; http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/ , 2010.&lt;br /&gt;
&lt;br /&gt;
Ruby, Sam, Dave Thomas and David Hansson. ''Agile Web Development with Rails: Third Edition'': The Pragmatic Programmers LLC, 2009.&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=50226</id>
		<title>CSC/ECE 517 Fall 2011/ch2 2f mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=50226"/>
		<updated>2011-09-22T04:16:56Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* Active Record */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
The original Ruby on Rail platform was extracted from the web-based project-management tool called Basecamp developed by 37signals. Ruby on Rails’ creator, David Heinemeier Hansson, began work on the Rails in early 2003 and released it as open source code in 2004, but it wasn’t until 2005 that Hansson shared commit rights to the project. [REFERENCE] Hansson designed Ruby on Rails to be an out of the box development framework that includes everything a programmer needs to create database-driven web applications according to the Model-View-Control pattern of separation. Ruby on Rails is based on the two key paradigms of Convention over Configuration [WIKI LINK] and Don’t Repeat Yourself (DRY) [WIKI LINK].&lt;br /&gt;
&lt;br /&gt;
=History of Rails Development=&lt;br /&gt;
Throughout the development of the Rails framework there have been four significant releases alongside of the usual patches, fixes, and upgrades. Initially, Rails 1.0 was released 15 months after the original source was made available. [REFERENCE] This version contained the structural foundation of what would become a powerful open source motivator for the Ruby platform.  Though there were patches and code adjustments in Rails 1.2 the next major release was Rails 2.0. &lt;br /&gt;
&lt;br /&gt;
Rails 2.0 was a major facelift for the framework and much of the effort went into improving the resources and polishing the overall package by making it more lean. Among some of these improvements was a focus on increasing security by adding a new module to work with HTTP Basic Authentication and providing a built-in mechanism for dealing with CRSF attacks. Other improvements were in the areas of changing certain syntactical nomenclature as well as simplifying the format for a few templates. &lt;br /&gt;
&lt;br /&gt;
The next major update before Rails 3.0 was Rails 2.3 at it was the most substantial update thus far…. not finished..&lt;br /&gt;
&lt;br /&gt;
=Rails 2 vs. Rails 3=&lt;br /&gt;
&lt;br /&gt;
A lot changed in the update from Rails 2 to Rails 3. We will explore a few of the key areas that will affect a programmer's everyday coding.&lt;br /&gt;
&lt;br /&gt;
==Rails Application Scripts==&lt;br /&gt;
&lt;br /&gt;
When you create a new Rails application, a directory named &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; is generated. In Rails 2, this directory is populated with a set of scripts that can be executed by the programmer. A few of the more important ones are as follows&amp;lt;ref&amp;gt;Ruby 2009, pp 257-258 &amp;lt;/ref&amp;gt;:&lt;br /&gt;
*&amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt;: Used to generate code for controllers, mailers, models, scaffolds and other sets of code.&lt;br /&gt;
*&amp;lt;tt&amp;gt;destroy&amp;lt;/tt&amp;gt;: Used to destroy code created by the &amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
*&amp;lt;tt&amp;gt;server&amp;lt;/tt&amp;gt;: Starts up the Rails application in a self-contained web server.&lt;br /&gt;
*&amp;lt;tt&amp;gt;plugin&amp;lt;/tt&amp;gt;: Helps with the installation and administration of plug-ins to the Rails framework.&lt;br /&gt;
*&amp;lt;tt&amp;gt;performance&amp;lt;/tt&amp;gt; directory: Contains scripts used by the programmer to help understand the performance characteristics of the application being built.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with all of these scripts and compiles them all into a single script named &amp;lt;tt&amp;gt;rails&amp;lt;/tt&amp;gt;. With this script, the programmer can access all of the functionality that was available with the separate scripts. To make things even easier, the necessity to call this script outright is even unnecessary. By using the operating systems installed &amp;lt;tt&amp;gt;'''rails'''&amp;lt;/tt&amp;gt; command (ex, &amp;lt;tt&amp;gt;/usr/bin/rails&amp;lt;/tt&amp;gt; on Linux systems) in the root of any Rails 3 application, it will know to call this script.&lt;br /&gt;
&lt;br /&gt;
==Gem Dependencies==&lt;br /&gt;
&lt;br /&gt;
The ability to extend the Rails framework using a Gem is a very powerful feature. In Rails 2, the &amp;lt;tt&amp;gt;config/environment.rb&amp;lt;/tt&amp;gt; file had to be edited in order to tell the Rails application to require specific Gems using the &amp;lt;tt&amp;gt;'''config.gem'''&amp;lt;/tt&amp;gt; method. To ensure that the Gems were actually installed on the system running the Rails application, the programmer had to execute the &amp;lt;tt&amp;gt;rake gem:install&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with the need to have that manual process of installing Gems by utilizing a file named &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; in the root of the application as well as the Bundler. The Bundler looks at the contents &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; and automatically installs any Gems that are missing from the system. This allows the programmer to focus on more important issues.&lt;br /&gt;
&lt;br /&gt;
==Routing DSL==&lt;br /&gt;
&lt;br /&gt;
The routing DSL for Rails went through a major reconditioning and has actually been renamed to Action Dispatch. This rewrite took the logic out of the Action Controller and is now a standalone piece of software resulting in a much cleaner implementation. As well, the definition of routes for each application are now named within your Application module instead of the Action Controller. The difference can be seen in the beginning line of the &amp;lt;tt&amp;gt;config/routes.rb&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
ActionController::Routing::Routes.draw do |map|&lt;br /&gt;
  map.resources :posts&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
AppName::Application.routes do&lt;br /&gt;
  resources :posts&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With all these changes, the &amp;lt;tt&amp;gt;config/routes.rb&amp;lt;/tt&amp;gt; file now has a new syntax. Here are some of the major differences&amp;lt;ref&amp;gt;Reza 2010&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Default Route===&lt;br /&gt;
&lt;br /&gt;
The differences between the default route are minor between the two versions, but the Rails 3 version is much more explicit, as the parentheses indicate parameters that are optional. Also worth noting is that this route is commented out in Rails 3 by default. The reasoning behind this is that there is a big push for a RESTful architecture with the Rails application and this type of route isn't really recommended for that kind of application. It can be uncommented but be warned that doing so will make all actions in every controller accessible via GET requests.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.connect ':controller/:action/:id'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match '/:controller(/:action(/:id))'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Regular Routes===&lt;br /&gt;
The way in which a regular route is defined is much more streamlined and readable. In Rails 2, you had to define a key for the controller and action. With Rails 3, this definition is streamlined with a &amp;lt;tt&amp;gt;:to&amp;lt;/tt&amp;gt; key where you define in a specific format the controller and action responsible for the request. Here is an example to illustrate this point:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.connect 'products/:id', :controller =&amp;gt; 'products', :action =&amp;gt; 'view'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match 'products/:id', :to =&amp;gt; 'catalog#view'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Named Routes===&lt;br /&gt;
Setting up named routes has changed a little bit as well. The rules for the regular routes apply here but the way that you define the name of the route has changed. Now, you utilize the &amp;lt;tt&amp;gt;:as&amp;lt;/tt&amp;gt; key to define the name of the route as shown here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.logout '/logout', :controller =&amp;gt; 'sessions', :action =&amp;gt; 'destroy'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match 'logout', :to =&amp;gt; 'sessions#destroy', :as =&amp;gt; &amp;quot;logout&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Empty Route===&lt;br /&gt;
The empty route defines where to route the application when a user navigates to the root of the website (for normal HTML sites, this is the same as the index page). Rails 2 had a quick way of defining it but in true Ruby fashion, Rails 3 makes it even simpler to define this route as you can see here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.root :controller =&amp;gt; &amp;quot;welcome&amp;quot;, :action =&amp;gt; 'show'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
root :to =&amp;gt; 'welcome#show'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===RESTful Resources===&lt;br /&gt;
RESTful resources are very important and have been a part of Rails since version 1.2. Utilizing the &amp;lt;tt&amp;gt;rails generate scaffold&amp;lt;/tt&amp;gt; command, Rails will generate the route, controller, views and model necessary to have the basic REST functionality for a model. As you can see from the following example, defining a RESTful route is simple in either version. Rails 3 grants you the ability to use this line for multiple resources as well, saving lines of code and making it more readable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.resources :products&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
# Single resource definition&lt;br /&gt;
resources :products&lt;br /&gt;
# Multiple resource definitions&lt;br /&gt;
resources :products, :categories, :comments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, Rails 3 provides you with the ability to extend the routing beyond the seven basic RESTful actions.  There are multiple ways in which you can extend this functionality:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Defining extra collection RESTful actions within a block.&lt;br /&gt;
resources :products do&lt;br /&gt;
  collection do&lt;br /&gt;
    get  :sold&lt;br /&gt;
    post :on_offer&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# An inline extension.&lt;br /&gt;
resources :products do&lt;br /&gt;
  get :sold, :on =&amp;gt; :member&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Active Record==&lt;br /&gt;
Active Record, like all of the core Rails components, got a major overhaul. &lt;br /&gt;
&lt;br /&gt;
===Arel and the Query Interface===&lt;br /&gt;
The most prominent changes made that will be apparent to developers will be the integration with Arel. With this integration, all of the core methods for Active Record return relations, allowing them to be chained together to develop complex queries. A full list and their functionality can be found in the [http://guides.rubyonrails.org/active_record_querying.html Rails Guide]. This will take the place of the options hash that would normally get passed in to one of the Active Record methods. To illustrate this, say we wanted to get a list of the first 10 products ordered alphabetically:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
Product.find(:order =&amp;gt; &amp;quot;name DESC&amp;quot;, :limit =&amp;gt; 10)&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
Product.order(&amp;quot;name DESC&amp;quot;).limit(10)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, there are a lot of methods that are losing the options parameter in their definitions&amp;lt;ref&amp;gt;Naik 2010&amp;lt;/ref&amp;gt;, including query methods find and all as well as calculation methods count and average. Also, the &amp;lt;tt&amp;gt;:all&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;:first&amp;lt;/tt&amp;gt; parameters for the find method are being deprecated in favor of the &amp;lt;tt&amp;gt;all&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;first&amp;lt;/tt&amp;gt; methods. Here are some examples of how things are changing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Changes to the find method.&lt;br /&gt;
# Rails 2&lt;br /&gt;
Product.find(:all)&lt;br /&gt;
Product.find(:first)&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
Product.all&lt;br /&gt;
Product.first&lt;br /&gt;
&lt;br /&gt;
# Examples of method options being removed.&lt;br /&gt;
# Rails 2&lt;br /&gt;
Product.all(:joins =&amp;gt; :categories)&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
Product.joins(&amp;quot;categories&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Named Scopes===&lt;br /&gt;
The &amp;lt;tt&amp;gt;named_scope&amp;lt;/tt&amp;gt; definition has been changed to just &amp;lt;tt&amp;gt;scope&amp;lt;/tt&amp;gt;. The options hash is also being deprecated and should be replaced with the new methods provided by the Arel integration. Translating existing Rails 2 named scopes is easy enough:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
class Product&lt;br /&gt;
  named_scope :food, :conditions =&amp;gt; { :type =&amp;gt; &amp;quot;food&amp;quot; }&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
class Product&lt;br /&gt;
  scope :food, where(:type =&amp;gt; &amp;quot;food&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==JavaScript Support&amp;lt;ref&amp;gt;Gadbois 2010&amp;lt;/ref&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
There are many JavaScript libraries available to programmers to make their web applications more dynamic and smooth looking. Whenever you created a Rails 2 application, it would automatically install the Prototype and Script.aculo.us frameworks. Rails also provided helpers for these two JavaScript frameworks so that a few method calls were all that you needed to make your application more fluid.&lt;br /&gt;
&lt;br /&gt;
Rails 3 introduces the idea of Unobtrusive JavaScript (UJS). The JavaScript becomes unobtrusive by not being written in with the HTML objects producing cleaner code that is easier to debug. This is mostly done with the utilization of HTML 5 custom attributes such as data-method, data-confirm, data-remote and data-disable-with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;http://host.com&amp;quot; id=&amp;quot;create-post&amp;quot; method=&amp;quot;post&amp;quot; data-remote=&amp;quot;true&amp;quot; data-confirm=&amp;quot;Are you sure you want to submit?&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By doing this, it also frees Rails from being dependent on the Prototype framework, allowing it to become ''JavaScript framework agnostic''. With its current implementation, the framework can support Prototype, jQuery and MooTools.&lt;br /&gt;
&lt;br /&gt;
It might also be helpful to point out that as of Rails 3.1, the jQuery framework has replaced Prototype as the default JavaScript framework. Programmers that wish to still use Prototype must remember to specify this when they create the Rails application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rails new myapp -j prototype&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
==Citation Notes==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Full Reference Information==&lt;br /&gt;
&lt;br /&gt;
Gadbois, John. ''Using Unobtrusive JavaScript and AJAX with Rails 3'' http://net.tutsplus.com/tutorials/javascript-ajax/using-unobtrusive-javascript-and-ajax-with-rails-3/ , 2010.&lt;br /&gt;
&lt;br /&gt;
Lindsaar, Mikel. &amp;quot;Ruby on Rails 3.0 Release Notes&amp;quot; http://edgeguides.rubyonrails.org/3_0_release_notes.html&lt;br /&gt;
&lt;br /&gt;
Reza, Rizwan. &amp;quot;The Lowdown on Routes in Rails 3&amp;quot; http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/ , 2010.&lt;br /&gt;
&lt;br /&gt;
Ruby, Sam, Dave Thomas and David Hansson. ''Agile Web Development with Rails: Third Edition'': The Pragmatic Programmers LLC, 2009.&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=50194</id>
		<title>CSC/ECE 517 Fall 2011/ch2 2f mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=50194"/>
		<updated>2011-09-22T03:28:56Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
The original Ruby on Rail platform was extracted from the web-based project-management tool called Basecamp developed by 37signals. Ruby on Rails’ creator, David Heinemeier Hansson, began work on the Rails in early 2003 and released it as open source code in 2004, but it wasn’t until 2005 that Hansson shared commit rights to the project. [REFERENCE] Hansson designed Ruby on Rails to be an out of the box development framework that includes everything a programmer needs to create database-driven web applications according to the Model-View-Control pattern of separation. Ruby on Rails is based on the two key paradigms of Convention over Configuration [WIKI LINK] and Don’t Repeat Yourself (DRY) [WIKI LINK].&lt;br /&gt;
&lt;br /&gt;
=History of Rails Development=&lt;br /&gt;
Throughout the development of the Rails framework there have been four significant releases alongside of the usual patches, fixes, and upgrades. Initially, Rails 1.0 was released 15 months after the original source was made available. [REFERENCE] This version contained the structural foundation of what would become a powerful open source motivator for the Ruby platform.  Though there were patches and code adjustments in Rails 1.2 the next major release was Rails 2.0. &lt;br /&gt;
&lt;br /&gt;
Rails 2.0 was a major facelift for the framework and much of the effort went into improving the resources and polishing the overall package by making it more lean. Among some of these improvements was a focus on increasing security by adding a new module to work with HTTP Basic Authentication and providing a built-in mechanism for dealing with CRSF attacks. Other improvements were in the areas of changing certain syntactical nomenclature as well as simplifying the format for a few templates. &lt;br /&gt;
&lt;br /&gt;
The next major update before Rails 3.0 was Rails 2.3 at it was the most substantial update thus far…. not finished..&lt;br /&gt;
&lt;br /&gt;
=Rails 2 vs. Rails 3=&lt;br /&gt;
&lt;br /&gt;
A lot changed in the update from Rails 2 to Rails 3. We will explore a few of the key areas that will affect a programmer's everyday coding.&lt;br /&gt;
&lt;br /&gt;
==Rails Application Scripts==&lt;br /&gt;
&lt;br /&gt;
When you create a new Rails application, a directory named &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; is generated. In Rails 2, this directory is populated with a set of scripts that can be executed by the programmer. A few of the more important ones are as follows&amp;lt;ref&amp;gt;Ruby 2009, pp 257-258 &amp;lt;/ref&amp;gt;:&lt;br /&gt;
*&amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt;: Used to generate code for controllers, mailers, models, scaffolds and other sets of code.&lt;br /&gt;
*&amp;lt;tt&amp;gt;destroy&amp;lt;/tt&amp;gt;: Used to destroy code created by the &amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
*&amp;lt;tt&amp;gt;server&amp;lt;/tt&amp;gt;: Starts up the Rails application in a self-contained web server.&lt;br /&gt;
*&amp;lt;tt&amp;gt;plugin&amp;lt;/tt&amp;gt;: Helps with the installation and administration of plug-ins to the Rails framework.&lt;br /&gt;
*&amp;lt;tt&amp;gt;performance&amp;lt;/tt&amp;gt; directory: Contains scripts used by the programmer to help understand the performance characteristics of the application being built.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with all of these scripts and compiles them all into a single script named &amp;lt;tt&amp;gt;rails&amp;lt;/tt&amp;gt;. With this script, the programmer can access all of the functionality that was available with the separate scripts. To make things even easier, the necessity to call this script outright is even unnecessary. By using the operating systems installed &amp;lt;tt&amp;gt;'''rails'''&amp;lt;/tt&amp;gt; command (ex, &amp;lt;tt&amp;gt;/usr/bin/rails&amp;lt;/tt&amp;gt; on Linux systems) in the root of any Rails 3 application, it will know to call this script.&lt;br /&gt;
&lt;br /&gt;
==Gem Dependencies==&lt;br /&gt;
&lt;br /&gt;
The ability to extend the Rails framework using a Gem is a very powerful feature. In Rails 2, the &amp;lt;tt&amp;gt;config/environment.rb&amp;lt;/tt&amp;gt; file had to be edited in order to tell the Rails application to require specific Gems using the &amp;lt;tt&amp;gt;'''config.gem'''&amp;lt;/tt&amp;gt; method. To ensure that the Gems were actually installed on the system running the Rails application, the programmer had to execute the &amp;lt;tt&amp;gt;rake gem:install&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with the need to have that manual process of installing Gems by utilizing a file named &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; in the root of the application as well as the Bundler. The Bundler looks at the contents &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; and automatically installs any Gems that are missing from the system. This allows the programmer to focus on more important issues.&lt;br /&gt;
&lt;br /&gt;
==Routing DSL==&lt;br /&gt;
&lt;br /&gt;
The routing DSL for Rails went through a major reconditioning and has actually been renamed to Action Dispatch. This rewrite took the logic out of the Action Controller and is now a standalone piece of software resulting in a much cleaner implementation. As well, the definition of routes for each application are now named within your Application module instead of the Action Controller. The difference can be seen in the beginning line of the &amp;lt;tt&amp;gt;config/routes.rb&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
ActionController::Routing::Routes.draw do |map|&lt;br /&gt;
  map.resources :posts&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
AppName::Application.routes do&lt;br /&gt;
  resources :posts&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With all these changes, the &amp;lt;tt&amp;gt;config/routes.rb&amp;lt;/tt&amp;gt; file now has a new syntax. Here are some of the major differences&amp;lt;ref&amp;gt;Reza 2010&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Default Route===&lt;br /&gt;
&lt;br /&gt;
The differences between the default route are minor between the two versions, but the Rails 3 version is much more explicit, as the parentheses indicate parameters that are optional. Also worth noting is that this route is commented out in Rails 3 by default. The reasoning behind this is that there is a big push for a RESTful architecture with the Rails application and this type of route isn't really recommended for that kind of application. It can be uncommented but be warned that doing so will make all actions in every controller accessible via GET requests.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.connect ':controller/:action/:id'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match '/:controller(/:action(/:id))'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Regular Routes===&lt;br /&gt;
The way in which a regular route is defined is much more streamlined and readable. In Rails 2, you had to define a key for the controller and action. With Rails 3, this definition is streamlined with a &amp;lt;tt&amp;gt;:to&amp;lt;/tt&amp;gt; key where you define in a specific format the controller and action responsible for the request. Here is an example to illustrate this point:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.connect 'products/:id', :controller =&amp;gt; 'products', :action =&amp;gt; 'view'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match 'products/:id', :to =&amp;gt; 'catalog#view'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Named Routes===&lt;br /&gt;
Setting up named routes has changed a little bit as well. The rules for the regular routes apply here but the way that you define the name of the route has changed. Now, you utilize the &amp;lt;tt&amp;gt;:as&amp;lt;/tt&amp;gt; key to define the name of the route as shown here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.logout '/logout', :controller =&amp;gt; 'sessions', :action =&amp;gt; 'destroy'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match 'logout', :to =&amp;gt; 'sessions#destroy', :as =&amp;gt; &amp;quot;logout&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Empty Route===&lt;br /&gt;
The empty route defines where to route the application when a user navigates to the root of the website (for normal HTML sites, this is the same as the index page). Rails 2 had a quick way of defining it but in true Ruby fashion, Rails 3 makes it even simpler to define this route as you can see here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.root :controller =&amp;gt; &amp;quot;welcome&amp;quot;, :action =&amp;gt; 'show'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
root :to =&amp;gt; 'welcome#show'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===RESTful Resources===&lt;br /&gt;
RESTful resources are very important and have been a part of Rails since version 1.2. Utilizing the &amp;lt;tt&amp;gt;rails generate scaffold&amp;lt;/tt&amp;gt; command, Rails will generate the route, controller, views and model necessary to have the basic REST functionality for a model. As you can see from the following example, defining a RESTful route is simple in either version. Rails 3 grants you the ability to use this line for multiple resources as well, saving lines of code and making it more readable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.resources :products&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
# Single resource definition&lt;br /&gt;
resources :products&lt;br /&gt;
# Multiple resource definitions&lt;br /&gt;
resources :products, :categories, :comments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, Rails 3 provides you with the ability to extend the routing beyond the seven basic RESTful actions.  There are multiple ways in which you can extend this functionality:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Defining extra collection RESTful actions within a block.&lt;br /&gt;
resources :products do&lt;br /&gt;
  collection do&lt;br /&gt;
    get  :sold&lt;br /&gt;
    post :on_offer&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# An inline extension.&lt;br /&gt;
resources :products do&lt;br /&gt;
  get :sold, :on =&amp;gt; :member&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Active Record==&lt;br /&gt;
&lt;br /&gt;
===Active Model===&lt;br /&gt;
&lt;br /&gt;
==JavaScript Support&amp;lt;ref&amp;gt;Gadbois 2010&amp;lt;/ref&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
There are many JavaScript libraries available to programmers to make their web applications more dynamic and smooth looking. Whenever you created a Rails 2 application, it would automatically install the Prototype and Script.aculo.us frameworks. Rails also provided helpers for these two JavaScript frameworks so that a few method calls were all that you needed to make your application more fluid.&lt;br /&gt;
&lt;br /&gt;
Rails 3 introduces the idea of Unobtrusive JavaScript (UJS). The JavaScript becomes unobtrusive by not being written in with the HTML objects producing cleaner code that is easier to debug. This is mostly done with the utilization of HTML 5 custom attributes such as data-method, data-confirm, data-remote and data-disable-with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;http://host.com&amp;quot; id=&amp;quot;create-post&amp;quot; method=&amp;quot;post&amp;quot; data-remote=&amp;quot;true&amp;quot; data-confirm=&amp;quot;Are you sure you want to submit?&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By doing this, it also frees Rails from being dependent on the Prototype framework, allowing it to become ''JavaScript framework agnostic''. With its current implementation, the framework can support Prototype, jQuery and MooTools.&lt;br /&gt;
&lt;br /&gt;
It might also be helpful to point out that as of Rails 3.1, the jQuery framework has replaced Prototype as the default JavaScript framework. Programmers that wish to still use Prototype must remember to specify this when they create the Rails application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rails new myapp -j prototype&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
==Citation Notes==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Full Reference Information==&lt;br /&gt;
&lt;br /&gt;
Gadbois, John. ''Using Unobtrusive JavaScript and AJAX with Rails 3'' http://net.tutsplus.com/tutorials/javascript-ajax/using-unobtrusive-javascript-and-ajax-with-rails-3/ , 2010.&lt;br /&gt;
&lt;br /&gt;
Lindsaar, Mikel. &amp;quot;Ruby on Rails 3.0 Release Notes&amp;quot; http://edgeguides.rubyonrails.org/3_0_release_notes.html&lt;br /&gt;
&lt;br /&gt;
Reza, Rizwan. &amp;quot;The Lowdown on Routes in Rails 3&amp;quot; http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/ , 2010.&lt;br /&gt;
&lt;br /&gt;
Ruby, Sam, Dave Thomas and David Hansson. ''Agile Web Development with Rails: Third Edition'': The Pragmatic Programmers LLC, 2009.&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=50193</id>
		<title>CSC/ECE 517 Fall 2011/ch2 2f mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=50193"/>
		<updated>2011-09-22T03:28:05Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* Full Reference Information */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
The original Ruby on Rail platform was extracted from the web-based project-management tool called Basecamp developed by 37signals. Ruby on Rails’ creator, David Heinemeier Hansson, began work on the Rails in early 2003 and released it as open source code in 2004, but it wasn’t until 2005 that Hansson shared commit rights to the project. [REFERENCE] Hansson designed Ruby on Rails to be an out of the box development framework that includes everything a programmer needs to create database-driven web applications according to the Model-View-Control pattern of separation. Ruby on Rails is based on the two key paradigms of Convention over Configuration [WIKI LINK] and Don’t Repeat Yourself (DRY) [WIKI LINK].&lt;br /&gt;
&lt;br /&gt;
=History of Rails Development=&lt;br /&gt;
Throughout the development of the Rails framework there have been four significant releases alongside of the usual patches, fixes, and upgrades. Initially, Rails 1.0 was released 15 months after the original source was made available. [REFERENCE] This version contained the structural foundation of what would become a powerful open source motivator for the Ruby platform.  Though there were patches and code adjustments in Rails 1.2 the next major release was Rails 2.0. &lt;br /&gt;
&lt;br /&gt;
Rails 2.0 was a major facelift for the framework and much of the effort went into improving the resources and polishing the overall package by making it more lean. Among some of these improvements was a focus on increasing security by adding a new module to work with HTTP Basic Authentication and providing a built-in mechanism for dealing with CRSF attacks. Other improvements were in the areas of changing certain syntactical nomenclature as well as simplifying the format for a few templates. &lt;br /&gt;
&lt;br /&gt;
The next major update before Rails 3.0 was Rails 2.3 at it was the most substantial update thus far…. not finished..&lt;br /&gt;
&lt;br /&gt;
=Rails 2 vs. Rails 3=&lt;br /&gt;
&lt;br /&gt;
A lot changed in the update from Rails 2 to Rails 3. We will explore a few of the key areas that will affect a programmer's everyday coding.&lt;br /&gt;
&lt;br /&gt;
==Rails Application Scripts==&lt;br /&gt;
&lt;br /&gt;
When you create a new Rails application, a directory named &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; is generated. In Rails 2, this directory is populated with a set of scripts that can be executed by the programmer. A few of the more important ones are as follows&amp;lt;ref&amp;gt;Ruby 2009, pp 257-258 &amp;lt;/ref&amp;gt;:&lt;br /&gt;
*&amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt;: Used to generate code for controllers, mailers, models, scaffolds and other sets of code.&lt;br /&gt;
*&amp;lt;tt&amp;gt;destroy&amp;lt;/tt&amp;gt;: Used to destroy code created by the &amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
*&amp;lt;tt&amp;gt;server&amp;lt;/tt&amp;gt;: Starts up the Rails application in a self-contained web server.&lt;br /&gt;
*&amp;lt;tt&amp;gt;plugin&amp;lt;/tt&amp;gt;: Helps with the installation and administration of plug-ins to the Rails framework.&lt;br /&gt;
*&amp;lt;tt&amp;gt;performance&amp;lt;/tt&amp;gt; directory: Contains scripts used by the programmer to help understand the performance characteristics of the application being built.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with all of these scripts and compiles them all into a single script named &amp;lt;tt&amp;gt;rails&amp;lt;/tt&amp;gt;. With this script, the programmer can access all of the functionality that was available with the separate scripts. To make things even easier, the necessity to call this script outright is even unnecessary. By using the operating systems installed &amp;lt;tt&amp;gt;'''rails'''&amp;lt;/tt&amp;gt; command (ex, &amp;lt;tt&amp;gt;/usr/bin/rails&amp;lt;/tt&amp;gt; on Linux systems) in the root of any Rails 3 application, it will know to call this script.&lt;br /&gt;
&lt;br /&gt;
==Gem Dependencies==&lt;br /&gt;
&lt;br /&gt;
The ability to extend the Rails framework using a Gem is a very powerful feature. In Rails 2, the &amp;lt;tt&amp;gt;config/environment.rb&amp;lt;/tt&amp;gt; file had to be edited in order to tell the Rails application to require specific Gems using the &amp;lt;tt&amp;gt;'''config.gem'''&amp;lt;/tt&amp;gt; method. To ensure that the Gems were actually installed on the system running the Rails application, the programmer had to execute the &amp;lt;tt&amp;gt;rake gem:install&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with the need to have that manual process of installing Gems by utilizing a file named &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; in the root of the application as well as the Bundler. The Bundler looks at the contents &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; and automatically installs any Gems that are missing from the system. This allows the programmer to focus on more important issues.&lt;br /&gt;
&lt;br /&gt;
==Action Controller==&lt;br /&gt;
&lt;br /&gt;
==Routing DSL==&lt;br /&gt;
&lt;br /&gt;
The routing DSL for Rails went through a major reconditioning and has actually been renamed to Action Dispatch. This rewrite took the logic out of the Action Controller and is now a standalone piece of software resulting in a much cleaner implementation. As well, the definition of routes for each application are now named within your Application module instead of the Action Controller. The difference can be seen in the beginning line of the &amp;lt;tt&amp;gt;config/routes.rb&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
ActionController::Routing::Routes.draw do |map|&lt;br /&gt;
  map.resources :posts&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
AppName::Application.routes do&lt;br /&gt;
  resources :posts&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With all these changes, the &amp;lt;tt&amp;gt;config/routes.rb&amp;lt;/tt&amp;gt; file now has a new syntax. Here are some of the major differences&amp;lt;ref&amp;gt;Reza 2010&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Default Route===&lt;br /&gt;
&lt;br /&gt;
The differences between the default route are minor between the two versions, but the Rails 3 version is much more explicit, as the parentheses indicate parameters that are optional. Also worth noting is that this route is commented out in Rails 3 by default. The reasoning behind this is that there is a big push for a RESTful architecture with the Rails application and this type of route isn't really recommended for that kind of application. It can be uncommented but be warned that doing so will make all actions in every controller accessible via GET requests.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.connect ':controller/:action/:id'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match '/:controller(/:action(/:id))'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Regular Routes===&lt;br /&gt;
The way in which a regular route is defined is much more streamlined and readable. In Rails 2, you had to define a key for the controller and action. With Rails 3, this definition is streamlined with a &amp;lt;tt&amp;gt;:to&amp;lt;/tt&amp;gt; key where you define in a specific format the controller and action responsible for the request. Here is an example to illustrate this point:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.connect 'products/:id', :controller =&amp;gt; 'products', :action =&amp;gt; 'view'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match 'products/:id', :to =&amp;gt; 'catalog#view'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Named Routes===&lt;br /&gt;
Setting up named routes has changed a little bit as well. The rules for the regular routes apply here but the way that you define the name of the route has changed. Now, you utilize the &amp;lt;tt&amp;gt;:as&amp;lt;/tt&amp;gt; key to define the name of the route as shown here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.logout '/logout', :controller =&amp;gt; 'sessions', :action =&amp;gt; 'destroy'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match 'logout', :to =&amp;gt; 'sessions#destroy', :as =&amp;gt; &amp;quot;logout&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Empty Route===&lt;br /&gt;
The empty route defines where to route the application when a user navigates to the root of the website (for normal HTML sites, this is the same as the index page). Rails 2 had a quick way of defining it but in true Ruby fashion, Rails 3 makes it even simpler to define this route as you can see here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.root :controller =&amp;gt; &amp;quot;welcome&amp;quot;, :action =&amp;gt; 'show'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
root :to =&amp;gt; 'welcome#show'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===RESTful Resources===&lt;br /&gt;
RESTful resources are very important and have been a part of Rails since version 1.2. Utilizing the &amp;lt;tt&amp;gt;rails generate scaffold&amp;lt;/tt&amp;gt; command, Rails will generate the route, controller, views and model necessary to have the basic REST functionality for a model. As you can see from the following example, defining a RESTful route is simple in either version. Rails 3 grants you the ability to use this line for multiple resources as well, saving lines of code and making it more readable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.resources :products&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
# Single resource definition&lt;br /&gt;
resources :products&lt;br /&gt;
# Multiple resource definitions&lt;br /&gt;
resources :products, :categories, :comments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, Rails 3 provides you with the ability to extend the routing beyond the seven basic RESTful actions.  There are multiple ways in which you can extend this functionality:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Defining extra collection RESTful actions within a block.&lt;br /&gt;
resources :products do&lt;br /&gt;
  collection do&lt;br /&gt;
    get  :sold&lt;br /&gt;
    post :on_offer&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# An inline extension.&lt;br /&gt;
resources :products do&lt;br /&gt;
  get :sold, :on =&amp;gt; :member&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Active Record==&lt;br /&gt;
&lt;br /&gt;
===Active Model===&lt;br /&gt;
&lt;br /&gt;
==JavaScript Support&amp;lt;ref&amp;gt;Gadbois 2010&amp;lt;/ref&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
There are many JavaScript libraries available to programmers to make their web applications more dynamic and smooth looking. Whenever you created a Rails 2 application, it would automatically install the Prototype and Script.aculo.us frameworks. Rails also provided helpers for these two JavaScript frameworks so that a few method calls were all that you needed to make your application more fluid.&lt;br /&gt;
&lt;br /&gt;
Rails 3 introduces the idea of Unobtrusive JavaScript (UJS). The JavaScript becomes unobtrusive by not being written in with the HTML objects producing cleaner code that is easier to debug. This is mostly done with the utilization of HTML 5 custom attributes such as data-method, data-confirm, data-remote and data-disable-with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;http://host.com&amp;quot; id=&amp;quot;create-post&amp;quot; method=&amp;quot;post&amp;quot; data-remote=&amp;quot;true&amp;quot; data-confirm=&amp;quot;Are you sure you want to submit?&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By doing this, it also frees Rails from being dependent on the Prototype framework, allowing it to become ''JavaScript framework agnostic''. With its current implementation, the framework can support Prototype, jQuery and MooTools.&lt;br /&gt;
&lt;br /&gt;
It might also be helpful to point out that as of Rails 3.1, the jQuery framework has replaced Prototype as the default JavaScript framework. Programmers that wish to still use Prototype must remember to specify this when they create the Rails application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rails new myapp -j prototype&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
==Citation Notes==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Full Reference Information==&lt;br /&gt;
&lt;br /&gt;
Gadbois, John. ''Using Unobtrusive JavaScript and AJAX with Rails 3'' http://net.tutsplus.com/tutorials/javascript-ajax/using-unobtrusive-javascript-and-ajax-with-rails-3/ , 2010.&lt;br /&gt;
&lt;br /&gt;
Lindsaar, Mikel. &amp;quot;Ruby on Rails 3.0 Release Notes&amp;quot; http://edgeguides.rubyonrails.org/3_0_release_notes.html&lt;br /&gt;
&lt;br /&gt;
Reza, Rizwan. &amp;quot;The Lowdown on Routes in Rails 3&amp;quot; http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/ , 2010.&lt;br /&gt;
&lt;br /&gt;
Ruby, Sam, Dave Thomas and David Hansson. ''Agile Web Development with Rails: Third Edition'': The Pragmatic Programmers LLC, 2009.&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=50190</id>
		<title>CSC/ECE 517 Fall 2011/ch2 2f mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=50190"/>
		<updated>2011-09-22T03:27:09Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* Full Reference Information */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
The original Ruby on Rail platform was extracted from the web-based project-management tool called Basecamp developed by 37signals. Ruby on Rails’ creator, David Heinemeier Hansson, began work on the Rails in early 2003 and released it as open source code in 2004, but it wasn’t until 2005 that Hansson shared commit rights to the project. [REFERENCE] Hansson designed Ruby on Rails to be an out of the box development framework that includes everything a programmer needs to create database-driven web applications according to the Model-View-Control pattern of separation. Ruby on Rails is based on the two key paradigms of Convention over Configuration [WIKI LINK] and Don’t Repeat Yourself (DRY) [WIKI LINK].&lt;br /&gt;
&lt;br /&gt;
=History of Rails Development=&lt;br /&gt;
Throughout the development of the Rails framework there have been four significant releases alongside of the usual patches, fixes, and upgrades. Initially, Rails 1.0 was released 15 months after the original source was made available. [REFERENCE] This version contained the structural foundation of what would become a powerful open source motivator for the Ruby platform.  Though there were patches and code adjustments in Rails 1.2 the next major release was Rails 2.0. &lt;br /&gt;
&lt;br /&gt;
Rails 2.0 was a major facelift for the framework and much of the effort went into improving the resources and polishing the overall package by making it more lean. Among some of these improvements was a focus on increasing security by adding a new module to work with HTTP Basic Authentication and providing a built-in mechanism for dealing with CRSF attacks. Other improvements were in the areas of changing certain syntactical nomenclature as well as simplifying the format for a few templates. &lt;br /&gt;
&lt;br /&gt;
The next major update before Rails 3.0 was Rails 2.3 at it was the most substantial update thus far…. not finished..&lt;br /&gt;
&lt;br /&gt;
=Rails 2 vs. Rails 3=&lt;br /&gt;
&lt;br /&gt;
A lot changed in the update from Rails 2 to Rails 3. We will explore a few of the key areas that will affect a programmer's everyday coding.&lt;br /&gt;
&lt;br /&gt;
==Rails Application Scripts==&lt;br /&gt;
&lt;br /&gt;
When you create a new Rails application, a directory named &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; is generated. In Rails 2, this directory is populated with a set of scripts that can be executed by the programmer. A few of the more important ones are as follows&amp;lt;ref&amp;gt;Ruby 2009, pp 257-258 &amp;lt;/ref&amp;gt;:&lt;br /&gt;
*&amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt;: Used to generate code for controllers, mailers, models, scaffolds and other sets of code.&lt;br /&gt;
*&amp;lt;tt&amp;gt;destroy&amp;lt;/tt&amp;gt;: Used to destroy code created by the &amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
*&amp;lt;tt&amp;gt;server&amp;lt;/tt&amp;gt;: Starts up the Rails application in a self-contained web server.&lt;br /&gt;
*&amp;lt;tt&amp;gt;plugin&amp;lt;/tt&amp;gt;: Helps with the installation and administration of plug-ins to the Rails framework.&lt;br /&gt;
*&amp;lt;tt&amp;gt;performance&amp;lt;/tt&amp;gt; directory: Contains scripts used by the programmer to help understand the performance characteristics of the application being built.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with all of these scripts and compiles them all into a single script named &amp;lt;tt&amp;gt;rails&amp;lt;/tt&amp;gt;. With this script, the programmer can access all of the functionality that was available with the separate scripts. To make things even easier, the necessity to call this script outright is even unnecessary. By using the operating systems installed &amp;lt;tt&amp;gt;'''rails'''&amp;lt;/tt&amp;gt; command (ex, &amp;lt;tt&amp;gt;/usr/bin/rails&amp;lt;/tt&amp;gt; on Linux systems) in the root of any Rails 3 application, it will know to call this script.&lt;br /&gt;
&lt;br /&gt;
==Gem Dependencies==&lt;br /&gt;
&lt;br /&gt;
The ability to extend the Rails framework using a Gem is a very powerful feature. In Rails 2, the &amp;lt;tt&amp;gt;config/environment.rb&amp;lt;/tt&amp;gt; file had to be edited in order to tell the Rails application to require specific Gems using the &amp;lt;tt&amp;gt;'''config.gem'''&amp;lt;/tt&amp;gt; method. To ensure that the Gems were actually installed on the system running the Rails application, the programmer had to execute the &amp;lt;tt&amp;gt;rake gem:install&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with the need to have that manual process of installing Gems by utilizing a file named &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; in the root of the application as well as the Bundler. The Bundler looks at the contents &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; and automatically installs any Gems that are missing from the system. This allows the programmer to focus on more important issues.&lt;br /&gt;
&lt;br /&gt;
==Action Controller==&lt;br /&gt;
&lt;br /&gt;
==Routing DSL==&lt;br /&gt;
&lt;br /&gt;
The routing DSL for Rails went through a major reconditioning and has actually been renamed to Action Dispatch. This rewrite took the logic out of the Action Controller and is now a standalone piece of software resulting in a much cleaner implementation. As well, the definition of routes for each application are now named within your Application module instead of the Action Controller. The difference can be seen in the beginning line of the &amp;lt;tt&amp;gt;config/routes.rb&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
ActionController::Routing::Routes.draw do |map|&lt;br /&gt;
  map.resources :posts&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
AppName::Application.routes do&lt;br /&gt;
  resources :posts&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With all these changes, the &amp;lt;tt&amp;gt;config/routes.rb&amp;lt;/tt&amp;gt; file now has a new syntax. Here are some of the major differences&amp;lt;ref&amp;gt;Reza 2010&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Default Route===&lt;br /&gt;
&lt;br /&gt;
The differences between the default route are minor between the two versions, but the Rails 3 version is much more explicit, as the parentheses indicate parameters that are optional. Also worth noting is that this route is commented out in Rails 3 by default. The reasoning behind this is that there is a big push for a RESTful architecture with the Rails application and this type of route isn't really recommended for that kind of application. It can be uncommented but be warned that doing so will make all actions in every controller accessible via GET requests.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.connect ':controller/:action/:id'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match '/:controller(/:action(/:id))'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Regular Routes===&lt;br /&gt;
The way in which a regular route is defined is much more streamlined and readable. In Rails 2, you had to define a key for the controller and action. With Rails 3, this definition is streamlined with a &amp;lt;tt&amp;gt;:to&amp;lt;/tt&amp;gt; key where you define in a specific format the controller and action responsible for the request. Here is an example to illustrate this point:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.connect 'products/:id', :controller =&amp;gt; 'products', :action =&amp;gt; 'view'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match 'products/:id', :to =&amp;gt; 'catalog#view'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Named Routes===&lt;br /&gt;
Setting up named routes has changed a little bit as well. The rules for the regular routes apply here but the way that you define the name of the route has changed. Now, you utilize the &amp;lt;tt&amp;gt;:as&amp;lt;/tt&amp;gt; key to define the name of the route as shown here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.logout '/logout', :controller =&amp;gt; 'sessions', :action =&amp;gt; 'destroy'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match 'logout', :to =&amp;gt; 'sessions#destroy', :as =&amp;gt; &amp;quot;logout&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Empty Route===&lt;br /&gt;
The empty route defines where to route the application when a user navigates to the root of the website (for normal HTML sites, this is the same as the index page). Rails 2 had a quick way of defining it but in true Ruby fashion, Rails 3 makes it even simpler to define this route as you can see here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.root :controller =&amp;gt; &amp;quot;welcome&amp;quot;, :action =&amp;gt; 'show'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
root :to =&amp;gt; 'welcome#show'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===RESTful Resources===&lt;br /&gt;
RESTful resources are very important and have been a part of Rails since version 1.2. Utilizing the &amp;lt;tt&amp;gt;rails generate scaffold&amp;lt;/tt&amp;gt; command, Rails will generate the route, controller, views and model necessary to have the basic REST functionality for a model. As you can see from the following example, defining a RESTful route is simple in either version. Rails 3 grants you the ability to use this line for multiple resources as well, saving lines of code and making it more readable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.resources :products&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
# Single resource definition&lt;br /&gt;
resources :products&lt;br /&gt;
# Multiple resource definitions&lt;br /&gt;
resources :products, :categories, :comments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, Rails 3 provides you with the ability to extend the routing beyond the seven basic RESTful actions.  There are multiple ways in which you can extend this functionality:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Defining extra collection RESTful actions within a block.&lt;br /&gt;
resources :products do&lt;br /&gt;
  collection do&lt;br /&gt;
    get  :sold&lt;br /&gt;
    post :on_offer&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# An inline extension.&lt;br /&gt;
resources :products do&lt;br /&gt;
  get :sold, :on =&amp;gt; :member&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Active Record==&lt;br /&gt;
&lt;br /&gt;
===Active Model===&lt;br /&gt;
&lt;br /&gt;
==JavaScript Support&amp;lt;ref&amp;gt;Gadbois 2010&amp;lt;/ref&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
There are many JavaScript libraries available to programmers to make their web applications more dynamic and smooth looking. Whenever you created a Rails 2 application, it would automatically install the Prototype and Script.aculo.us frameworks. Rails also provided helpers for these two JavaScript frameworks so that a few method calls were all that you needed to make your application more fluid.&lt;br /&gt;
&lt;br /&gt;
Rails 3 introduces the idea of Unobtrusive JavaScript (UJS). The JavaScript becomes unobtrusive by not being written in with the HTML objects producing cleaner code that is easier to debug. This is mostly done with the utilization of HTML 5 custom attributes such as data-method, data-confirm, data-remote and data-disable-with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;http://host.com&amp;quot; id=&amp;quot;create-post&amp;quot; method=&amp;quot;post&amp;quot; data-remote=&amp;quot;true&amp;quot; data-confirm=&amp;quot;Are you sure you want to submit?&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By doing this, it also frees Rails from being dependent on the Prototype framework, allowing it to become ''JavaScript framework agnostic''. With its current implementation, the framework can support Prototype, jQuery and MooTools.&lt;br /&gt;
&lt;br /&gt;
It might also be helpful to point out that as of Rails 3.1, the jQuery framework has replaced Prototype as the default JavaScript framework. Programmers that wish to still use Prototype must remember to specify this when they create the Rails application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rails new myapp -j prototype&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
==Citation Notes==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Full Reference Information==&lt;br /&gt;
&lt;br /&gt;
Gadbois, John. ''Using Unobtrusive JavaScript and AJAX with Rails 3'' http://net.tutsplus.com/tutorials/javascript-ajax/using-unobtrusive-javascript-and-ajax-with-rails-3/ , 2010.&lt;br /&gt;
&lt;br /&gt;
RailsGuides. &amp;quot;Ruby on Rails 3.0 Release Notes&amp;quot; http://edgeguides.rubyonrails.org/3_0_release_notes.html , &lt;br /&gt;
&lt;br /&gt;
Reza, Rizwan. &amp;quot;The Lowdown on Routes in Rails 3&amp;quot; http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/ , 2010.&lt;br /&gt;
&lt;br /&gt;
Ruby, Sam, Dave Thomas and David Hansson. ''Agile Web Development with Rails: Third Edition'': The Pragmatic Programmers LLC, 2009.&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=50135</id>
		<title>CSC/ECE 517 Fall 2011/ch2 2f mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=50135"/>
		<updated>2011-09-22T02:26:23Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* RESTful Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
The original Ruby on Rail platform was extracted from the web-based project-management tool called Basecamp developed by 37signals. Ruby on Rails’ creator, David Heinemeier Hansson, began work on the Rails in early 2003 and released it as open source code in 2004, but it wasn’t until 2005 that Hansson shared commit rights to the project. [REFERENCE] Hansson designed Ruby on Rails to be an out of the box development framework that includes everything a programmer needs to create database-driven web applications according to the Model-View-Control pattern of separation. Ruby on Rails is based on the two key paradigms of Convention over Configuration [WIKI LINK] and Don’t Repeat Yourself (DRY) [WIKI LINK].&lt;br /&gt;
&lt;br /&gt;
=History of Rails Development=&lt;br /&gt;
Throughout the development of the Rails framework there have been four significant releases alongside of the usual patches, fixes, and upgrades. Initially, Rails 1.0 was released 15 months after the original source was made available. [REFERENCE] This version contained the structural foundation of what would become a powerful open source motivator for the Ruby platform.  Though there were patches and code adjustments in Rails 1.2 the next major release was Rails 2.0. &lt;br /&gt;
&lt;br /&gt;
Rails 2.0 was a major facelift for the framework and much of the effort went into improving the resources and polishing the overall package by making it more lean. Among some of these improvements was a focus on increasing security by adding a new module to work with HTTP Basic Authentication and providing a built-in mechanism for dealing with CRSF attacks. Other improvements were in the areas of changing certain syntactical nomenclature as well as simplifying the format for a few templates. &lt;br /&gt;
&lt;br /&gt;
The next major update before Rails 3.0 was Rails 2.3 at it was the most substantial update thus far…. not finished..&lt;br /&gt;
&lt;br /&gt;
=Rails 2 vs. Rails 3=&lt;br /&gt;
&lt;br /&gt;
A lot changed in the update from Rails 2 to Rails 3. We will explore a few of the key areas that will affect a programmer's everyday coding.&lt;br /&gt;
&lt;br /&gt;
==Rails Application Scripts==&lt;br /&gt;
&lt;br /&gt;
When you create a new Rails application, a directory named &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; is generated. In Rails 2, this directory is populated with a set of scripts that can be executed by the programmer. A few of the more important ones are as follows&amp;lt;ref&amp;gt;Ruby 2009, pp 257-258 &amp;lt;/ref&amp;gt;:&lt;br /&gt;
*&amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt;: Used to generate code for controllers, mailers, models, scaffolds and other sets of code.&lt;br /&gt;
*&amp;lt;tt&amp;gt;destroy&amp;lt;/tt&amp;gt;: Used to destroy code created by the &amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
*&amp;lt;tt&amp;gt;server&amp;lt;/tt&amp;gt;: Starts up the Rails application in a self-contained web server.&lt;br /&gt;
*&amp;lt;tt&amp;gt;plugin&amp;lt;/tt&amp;gt;: Helps with the installation and administration of plug-ins to the Rails framework.&lt;br /&gt;
*&amp;lt;tt&amp;gt;performance&amp;lt;/tt&amp;gt; directory: Contains scripts used by the programmer to help understand the performance characteristics of the application being built.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with all of these scripts and compiles them all into a single script named &amp;lt;tt&amp;gt;rails&amp;lt;/tt&amp;gt;. With this script, the programmer can access all of the functionality that was available with the separate scripts. To make things even easier, the necessity to call this script outright is even unnecessary. By using the operating systems installed &amp;lt;tt&amp;gt;'''rails'''&amp;lt;/tt&amp;gt; command (ex, &amp;lt;tt&amp;gt;/usr/bin/rails&amp;lt;/tt&amp;gt; on Linux systems) in the root of any Rails 3 application, it will know to call this script.&lt;br /&gt;
&lt;br /&gt;
==Gem Dependencies==&lt;br /&gt;
&lt;br /&gt;
The ability to extend the Rails framework using a Gem is a very powerful feature. In Rails 2, the &amp;lt;tt&amp;gt;config/environment.rb&amp;lt;/tt&amp;gt; file had to be edited in order to tell the Rails application to require specific Gems using the &amp;lt;tt&amp;gt;'''config.gem'''&amp;lt;/tt&amp;gt; method. To ensure that the Gems were actually installed on the system running the Rails application, the programmer had to execute the &amp;lt;tt&amp;gt;rake gem:install&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with the need to have that manual process of installing Gems by utilizing a file named &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; in the root of the application as well as the Bundler. The Bundler looks at the contents &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; and automatically installs any Gems that are missing from the system. This allows the programmer to focus on more important issues.&lt;br /&gt;
&lt;br /&gt;
==Action Controller==&lt;br /&gt;
&lt;br /&gt;
==Routing DSL==&lt;br /&gt;
&lt;br /&gt;
The routing DSL for Rails went through a major reconditioning and has actually been renamed to Action Dispatch. This rewrite took the logic out of the Action Controller and is now a standalone piece of software resulting in a much cleaner implementation. As well, the definition of routes for each application are now named within your Application module instead of the Action Controller. The difference can be seen in the beginning line of the &amp;lt;tt&amp;gt;config/routes.rb&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
ActionController::Routing::Routes.draw do |map|&lt;br /&gt;
  map.resources :posts&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
AppName::Application.routes do&lt;br /&gt;
  resources :posts&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With all these changes, the &amp;lt;tt&amp;gt;config/routes.rb&amp;lt;/tt&amp;gt; file now has a new syntax. Here are some of the major differences&amp;lt;ref&amp;gt;Reza 2010&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Default Route===&lt;br /&gt;
&lt;br /&gt;
The differences between the default route are minor between the two versions, but the Rails 3 version is much more explicit, as the parentheses indicate parameters that are optional. Also worth noting is that this route is commented out in Rails 3 by default. The reasoning behind this is that there is a big push for a RESTful architecture with the Rails application and this type of route isn't really recommended for that kind of application. It can be uncommented but be warned that doing so will make all actions in every controller accessible via GET requests.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.connect ':controller/:action/:id'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match '/:controller(/:action(/:id))'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Regular Routes===&lt;br /&gt;
The way in which a regular route is defined is much more streamlined and readable. In Rails 2, you had to define a key for the controller and action. With Rails 3, this definition is streamlined with a &amp;lt;tt&amp;gt;:to&amp;lt;/tt&amp;gt; key where you define in a specific format the controller and action responsible for the request. Here is an example to illustrate this point:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.connect 'products/:id', :controller =&amp;gt; 'products', :action =&amp;gt; 'view'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match 'products/:id', :to =&amp;gt; 'catalog#view'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Named Routes===&lt;br /&gt;
Setting up named routes has changed a little bit as well. The rules for the regular routes apply here but the way that you define the name of the route has changed. Now, you utilize the &amp;lt;tt&amp;gt;:as&amp;lt;/tt&amp;gt; key to define the name of the route as shown here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.logout '/logout', :controller =&amp;gt; 'sessions', :action =&amp;gt; 'destroy'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match 'logout', :to =&amp;gt; 'sessions#destroy', :as =&amp;gt; &amp;quot;logout&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Empty Route===&lt;br /&gt;
The empty route defines where to route the application when a user navigates to the root of the website (for normal HTML sites, this is the same as the index page). Rails 2 had a quick way of defining it but in true Ruby fashion, Rails 3 makes it even simpler to define this route as you can see here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.root :controller =&amp;gt; &amp;quot;welcome&amp;quot;, :action =&amp;gt; 'show'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
root :to =&amp;gt; 'welcome#show'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===RESTful Resources===&lt;br /&gt;
RESTful resources are very important and have been a part of Rails since version 1.2. Utilizing the &amp;lt;tt&amp;gt;rails generate scaffold&amp;lt;/tt&amp;gt; command, Rails will generate the route, controller, views and model necessary to have the basic REST functionality for a model. As you can see from the following example, defining a RESTful route is simple in either version. Rails 3 grants you the ability to use this line for multiple resources as well, saving lines of code and making it more readable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.resources :products&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
# Single resource definition&lt;br /&gt;
resources :products&lt;br /&gt;
# Multiple resource definitions&lt;br /&gt;
resources :products, :categories, :comments&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, Rails 3 provides you with the ability to extend the routing beyond the seven basic RESTful actions.  There are multiple ways in which you can extend this functionality:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Defining extra collection RESTful actions within a block.&lt;br /&gt;
resources :products do&lt;br /&gt;
  collection do&lt;br /&gt;
    get  :sold&lt;br /&gt;
    post :on_offer&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# An inline extension.&lt;br /&gt;
resources :products do&lt;br /&gt;
  get :sold, :on =&amp;gt; :member&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Active Record==&lt;br /&gt;
&lt;br /&gt;
===Active Model===&lt;br /&gt;
&lt;br /&gt;
==JavaScript Support&amp;lt;ref&amp;gt;Gadbois 2010&amp;lt;/ref&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
There are many JavaScript libraries available to programmers to make their web applications more dynamic and smooth looking. Whenever you created a Rails 2 application, it would automatically install the Prototype and Script.aculo.us frameworks. Rails also provided helpers for these two JavaScript frameworks so that a few method calls were all that you needed to make your application more fluid.&lt;br /&gt;
&lt;br /&gt;
Rails 3 introduces the idea of Unobtrusive JavaScript (UJS). The JavaScript becomes unobtrusive by not being written in with the HTML objects producing cleaner code that is easier to debug. This is mostly done with the utilization of HTML 5 custom attributes such as data-method, data-confirm, data-remote and data-disable-with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;http://host.com&amp;quot; id=&amp;quot;create-post&amp;quot; method=&amp;quot;post&amp;quot; data-remote=&amp;quot;true&amp;quot; data-confirm=&amp;quot;Are you sure you want to submit?&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By doing this, it also frees Rails from being dependent on the Prototype framework, allowing it to become ''JavaScript framework agnostic''. With its current implementation, the framework can support Prototype, jQuery and MooTools.&lt;br /&gt;
&lt;br /&gt;
It might also be helpful to point out that as of Rails 3.1, the jQuery framework has replaced Prototype as the default JavaScript framework. Programmers that wish to still use Prototype must remember to specify this when they create the Rails application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rails new myapp -j prototype&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
==Citation Notes==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Full Reference Information==&lt;br /&gt;
&lt;br /&gt;
Gadbois, John. ''Using Unobtrusive JavaScript and AJAX with Rails 3'' http://net.tutsplus.com/tutorials/javascript-ajax/using-unobtrusive-javascript-and-ajax-with-rails-3/ , 2010.&lt;br /&gt;
&lt;br /&gt;
Reza, Rizwan. &amp;quot;The Lowdown on Routes in Rails 3&amp;quot; http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/ , 2010.&lt;br /&gt;
&lt;br /&gt;
Ruby, Sam, Dave Thomas and David Hansson. ''Agile Web Development with Rails: Third Edition'': The Pragmatic Programmers LLC, 2009.&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=50132</id>
		<title>CSC/ECE 517 Fall 2011/ch2 2f mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=50132"/>
		<updated>2011-09-22T02:18:14Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* Full Reference Information */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
The original Ruby on Rail platform was extracted from the web-based project-management tool called Basecamp developed by 37signals. Ruby on Rails’ creator, David Heinemeier Hansson, began work on the Rails in early 2003 and released it as open source code in 2004, but it wasn’t until 2005 that Hansson shared commit rights to the project. [REFERENCE] Hansson designed Ruby on Rails to be an out of the box development framework that includes everything a programmer needs to create database-driven web applications according to the Model-View-Control pattern of separation. Ruby on Rails is based on the two key paradigms of Convention over Configuration [WIKI LINK] and Don’t Repeat Yourself (DRY) [WIKI LINK].&lt;br /&gt;
&lt;br /&gt;
=History of Rails Development=&lt;br /&gt;
Throughout the development of the Rails framework there have been four significant releases alongside of the usual patches, fixes, and upgrades. Initially, Rails 1.0 was released 15 months after the original source was made available. [REFERENCE] This version contained the structural foundation of what would become a powerful open source motivator for the Ruby platform.  Though there were patches and code adjustments in Rails 1.2 the next major release was Rails 2.0. &lt;br /&gt;
&lt;br /&gt;
Rails 2.0 was a major facelift for the framework and much of the effort went into improving the resources and polishing the overall package by making it more lean. Among some of these improvements was a focus on increasing security by adding a new module to work with HTTP Basic Authentication and providing a built-in mechanism for dealing with CRSF attacks. Other improvements were in the areas of changing certain syntactical nomenclature as well as simplifying the format for a few templates. &lt;br /&gt;
&lt;br /&gt;
The next major update before Rails 3.0 was Rails 2.3 at it was the most substantial update thus far…. not finished..&lt;br /&gt;
&lt;br /&gt;
=Rails 2 vs. Rails 3=&lt;br /&gt;
&lt;br /&gt;
A lot changed in the update from Rails 2 to Rails 3. We will explore a few of the key areas that will affect a programmer's everyday coding.&lt;br /&gt;
&lt;br /&gt;
==Rails Application Scripts==&lt;br /&gt;
&lt;br /&gt;
When you create a new Rails application, a directory named &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; is generated. In Rails 2, this directory is populated with a set of scripts that can be executed by the programmer. A few of the more important ones are as follows&amp;lt;ref&amp;gt;Ruby 2009, pp 257-258 &amp;lt;/ref&amp;gt;:&lt;br /&gt;
*&amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt;: Used to generate code for controllers, mailers, models, scaffolds and other sets of code.&lt;br /&gt;
*&amp;lt;tt&amp;gt;destroy&amp;lt;/tt&amp;gt;: Used to destroy code created by the &amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
*&amp;lt;tt&amp;gt;server&amp;lt;/tt&amp;gt;: Starts up the Rails application in a self-contained web server.&lt;br /&gt;
*&amp;lt;tt&amp;gt;plugin&amp;lt;/tt&amp;gt;: Helps with the installation and administration of plug-ins to the Rails framework.&lt;br /&gt;
*&amp;lt;tt&amp;gt;performance&amp;lt;/tt&amp;gt; directory: Contains scripts used by the programmer to help understand the performance characteristics of the application being built.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with all of these scripts and compiles them all into a single script named &amp;lt;tt&amp;gt;rails&amp;lt;/tt&amp;gt;. With this script, the programmer can access all of the functionality that was available with the separate scripts. To make things even easier, the necessity to call this script outright is even unnecessary. By using the operating systems installed &amp;lt;tt&amp;gt;'''rails'''&amp;lt;/tt&amp;gt; command (ex, &amp;lt;tt&amp;gt;/usr/bin/rails&amp;lt;/tt&amp;gt; on Linux systems) in the root of any Rails 3 application, it will know to call this script.&lt;br /&gt;
&lt;br /&gt;
==Gem Dependencies==&lt;br /&gt;
&lt;br /&gt;
The ability to extend the Rails framework using a Gem is a very powerful feature. In Rails 2, the &amp;lt;tt&amp;gt;config/environment.rb&amp;lt;/tt&amp;gt; file had to be edited in order to tell the Rails application to require specific Gems using the &amp;lt;tt&amp;gt;'''config.gem'''&amp;lt;/tt&amp;gt; method. To ensure that the Gems were actually installed on the system running the Rails application, the programmer had to execute the &amp;lt;tt&amp;gt;rake gem:install&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with the need to have that manual process of installing Gems by utilizing a file named &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; in the root of the application as well as the Bundler. The Bundler looks at the contents &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; and automatically installs any Gems that are missing from the system. This allows the programmer to focus on more important issues.&lt;br /&gt;
&lt;br /&gt;
==Action Controller==&lt;br /&gt;
&lt;br /&gt;
==Routing DSL==&lt;br /&gt;
&lt;br /&gt;
The routing DSL for Rails went through a major reconditioning and has actually been renamed to Action Dispatch. This rewrite took the logic out of the Action Controller and is now a standalone piece of software resulting in a much cleaner implementation. As well, the definition of routes for each application are now named within your Application module instead of the Action Controller. The difference can be seen in the beginning line of the &amp;lt;tt&amp;gt;config/routes.rb&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
ActionController::Routing::Routes.draw do |map|&lt;br /&gt;
  map.resources :posts&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
AppName::Application.routes do&lt;br /&gt;
  resources :posts&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With all these changes, the &amp;lt;tt&amp;gt;config/routes.rb&amp;lt;/tt&amp;gt; file now has a new syntax. Here are some of the major differences&amp;lt;ref&amp;gt;Reza 2010&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Default Route===&lt;br /&gt;
&lt;br /&gt;
The differences between the default route are minor between the two versions, but the Rails 3 version is much more explicit, as the parentheses indicate parameters that are optional. Also worth noting is that this route is commented out in Rails 3 by default. The reasoning behind this is that there is a big push for a RESTful architecture with the Rails application and this type of route isn't really recommended for that kind of application. It can be uncommented but be warned that doing so will make all actions in every controller accessible via GET requests.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.connect ':controller/:action/:id'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match '/:controller(/:action(/:id))'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Regular Routes===&lt;br /&gt;
The way in which a regular route is defined is much more streamlined and readable. In Rails 2, you had to define a key for the controller and action. With Rails 3, this definition is streamlined with a &amp;lt;tt&amp;gt;:to&amp;lt;/tt&amp;gt; key where you define in a specific format the controller and action responsible for the request. Here is an example to illustrate this point:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.connect 'products/:id', :controller =&amp;gt; 'products', :action =&amp;gt; 'view'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match 'products/:id', :to =&amp;gt; 'catalog#view'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Named Routes===&lt;br /&gt;
Setting up named routes has changed a little bit as well. The rules for the regular routes apply here but the way that you define the name of the route has changed. Now, you utilize the &amp;lt;tt&amp;gt;:as&amp;lt;/tt&amp;gt; key to define the name of the route as shown here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.logout '/logout', :controller =&amp;gt; 'sessions', :action =&amp;gt; 'destroy'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match 'logout', :to =&amp;gt; 'sessions#destroy', :as =&amp;gt; &amp;quot;logout&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Empty Route===&lt;br /&gt;
The empty route defines where to route the application when a user navigates to the root of the website (for normal HTML sites, this is the same as the index page). Rails 2 had a quick way of defining it but in true Ruby fashion, Rails 3 makes it even simpler to define this route as you can see here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.root :controller =&amp;gt; &amp;quot;welcome&amp;quot;, :action =&amp;gt; 'show'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
root :to =&amp;gt; 'welcome#show'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===RESTful Resources===&lt;br /&gt;
&lt;br /&gt;
==Active Record==&lt;br /&gt;
&lt;br /&gt;
===Active Model===&lt;br /&gt;
&lt;br /&gt;
==JavaScript Support&amp;lt;ref&amp;gt;Gadbois 2010&amp;lt;/ref&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
There are many JavaScript libraries available to programmers to make their web applications more dynamic and smooth looking. Whenever you created a Rails 2 application, it would automatically install the Prototype and Script.aculo.us frameworks. Rails also provided helpers for these two JavaScript frameworks so that a few method calls were all that you needed to make your application more fluid.&lt;br /&gt;
&lt;br /&gt;
Rails 3 introduces the idea of Unobtrusive JavaScript (UJS). The JavaScript becomes unobtrusive by not being written in with the HTML objects producing cleaner code that is easier to debug. This is mostly done with the utilization of HTML 5 custom attributes such as data-method, data-confirm, data-remote and data-disable-with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;http://host.com&amp;quot; id=&amp;quot;create-post&amp;quot; method=&amp;quot;post&amp;quot; data-remote=&amp;quot;true&amp;quot; data-confirm=&amp;quot;Are you sure you want to submit?&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By doing this, it also frees Rails from being dependent on the Prototype framework, allowing it to become ''JavaScript framework agnostic''. With its current implementation, the framework can support Prototype, jQuery and MooTools.&lt;br /&gt;
&lt;br /&gt;
It might also be helpful to point out that as of Rails 3.1, the jQuery framework has replaced Prototype as the default JavaScript framework. Programmers that wish to still use Prototype must remember to specify this when they create the Rails application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rails new myapp -j prototype&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
==Citation Notes==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Full Reference Information==&lt;br /&gt;
&lt;br /&gt;
Gadbois, John. ''Using Unobtrusive JavaScript and AJAX with Rails 3'' http://net.tutsplus.com/tutorials/javascript-ajax/using-unobtrusive-javascript-and-ajax-with-rails-3/ , 2010.&lt;br /&gt;
&lt;br /&gt;
Reza, Rizwan. &amp;quot;The Lowdown on Routes in Rails 3&amp;quot; http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/ , 2010.&lt;br /&gt;
&lt;br /&gt;
Ruby, Sam, Dave Thomas and David Hansson. ''Agile Web Development with Rails: Third Edition'': The Pragmatic Programmers LLC, 2009.&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=50131</id>
		<title>CSC/ECE 517 Fall 2011/ch2 2f mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=50131"/>
		<updated>2011-09-22T02:17:06Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* Routing DSL */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
The original Ruby on Rail platform was extracted from the web-based project-management tool called Basecamp developed by 37signals. Ruby on Rails’ creator, David Heinemeier Hansson, began work on the Rails in early 2003 and released it as open source code in 2004, but it wasn’t until 2005 that Hansson shared commit rights to the project. [REFERENCE] Hansson designed Ruby on Rails to be an out of the box development framework that includes everything a programmer needs to create database-driven web applications according to the Model-View-Control pattern of separation. Ruby on Rails is based on the two key paradigms of Convention over Configuration [WIKI LINK] and Don’t Repeat Yourself (DRY) [WIKI LINK].&lt;br /&gt;
&lt;br /&gt;
=History of Rails Development=&lt;br /&gt;
Throughout the development of the Rails framework there have been four significant releases alongside of the usual patches, fixes, and upgrades. Initially, Rails 1.0 was released 15 months after the original source was made available. [REFERENCE] This version contained the structural foundation of what would become a powerful open source motivator for the Ruby platform.  Though there were patches and code adjustments in Rails 1.2 the next major release was Rails 2.0. &lt;br /&gt;
&lt;br /&gt;
Rails 2.0 was a major facelift for the framework and much of the effort went into improving the resources and polishing the overall package by making it more lean. Among some of these improvements was a focus on increasing security by adding a new module to work with HTTP Basic Authentication and providing a built-in mechanism for dealing with CRSF attacks. Other improvements were in the areas of changing certain syntactical nomenclature as well as simplifying the format for a few templates. &lt;br /&gt;
&lt;br /&gt;
The next major update before Rails 3.0 was Rails 2.3 at it was the most substantial update thus far…. not finished..&lt;br /&gt;
&lt;br /&gt;
=Rails 2 vs. Rails 3=&lt;br /&gt;
&lt;br /&gt;
A lot changed in the update from Rails 2 to Rails 3. We will explore a few of the key areas that will affect a programmer's everyday coding.&lt;br /&gt;
&lt;br /&gt;
==Rails Application Scripts==&lt;br /&gt;
&lt;br /&gt;
When you create a new Rails application, a directory named &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; is generated. In Rails 2, this directory is populated with a set of scripts that can be executed by the programmer. A few of the more important ones are as follows&amp;lt;ref&amp;gt;Ruby 2009, pp 257-258 &amp;lt;/ref&amp;gt;:&lt;br /&gt;
*&amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt;: Used to generate code for controllers, mailers, models, scaffolds and other sets of code.&lt;br /&gt;
*&amp;lt;tt&amp;gt;destroy&amp;lt;/tt&amp;gt;: Used to destroy code created by the &amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
*&amp;lt;tt&amp;gt;server&amp;lt;/tt&amp;gt;: Starts up the Rails application in a self-contained web server.&lt;br /&gt;
*&amp;lt;tt&amp;gt;plugin&amp;lt;/tt&amp;gt;: Helps with the installation and administration of plug-ins to the Rails framework.&lt;br /&gt;
*&amp;lt;tt&amp;gt;performance&amp;lt;/tt&amp;gt; directory: Contains scripts used by the programmer to help understand the performance characteristics of the application being built.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with all of these scripts and compiles them all into a single script named &amp;lt;tt&amp;gt;rails&amp;lt;/tt&amp;gt;. With this script, the programmer can access all of the functionality that was available with the separate scripts. To make things even easier, the necessity to call this script outright is even unnecessary. By using the operating systems installed &amp;lt;tt&amp;gt;'''rails'''&amp;lt;/tt&amp;gt; command (ex, &amp;lt;tt&amp;gt;/usr/bin/rails&amp;lt;/tt&amp;gt; on Linux systems) in the root of any Rails 3 application, it will know to call this script.&lt;br /&gt;
&lt;br /&gt;
==Gem Dependencies==&lt;br /&gt;
&lt;br /&gt;
The ability to extend the Rails framework using a Gem is a very powerful feature. In Rails 2, the &amp;lt;tt&amp;gt;config/environment.rb&amp;lt;/tt&amp;gt; file had to be edited in order to tell the Rails application to require specific Gems using the &amp;lt;tt&amp;gt;'''config.gem'''&amp;lt;/tt&amp;gt; method. To ensure that the Gems were actually installed on the system running the Rails application, the programmer had to execute the &amp;lt;tt&amp;gt;rake gem:install&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with the need to have that manual process of installing Gems by utilizing a file named &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; in the root of the application as well as the Bundler. The Bundler looks at the contents &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; and automatically installs any Gems that are missing from the system. This allows the programmer to focus on more important issues.&lt;br /&gt;
&lt;br /&gt;
==Action Controller==&lt;br /&gt;
&lt;br /&gt;
==Routing DSL==&lt;br /&gt;
&lt;br /&gt;
The routing DSL for Rails went through a major reconditioning and has actually been renamed to Action Dispatch. This rewrite took the logic out of the Action Controller and is now a standalone piece of software resulting in a much cleaner implementation. As well, the definition of routes for each application are now named within your Application module instead of the Action Controller. The difference can be seen in the beginning line of the &amp;lt;tt&amp;gt;config/routes.rb&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
ActionController::Routing::Routes.draw do |map|&lt;br /&gt;
  map.resources :posts&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
AppName::Application.routes do&lt;br /&gt;
  resources :posts&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With all these changes, the &amp;lt;tt&amp;gt;config/routes.rb&amp;lt;/tt&amp;gt; file now has a new syntax. Here are some of the major differences&amp;lt;ref&amp;gt;Reza 2010&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Default Route===&lt;br /&gt;
&lt;br /&gt;
The differences between the default route are minor between the two versions, but the Rails 3 version is much more explicit, as the parentheses indicate parameters that are optional. Also worth noting is that this route is commented out in Rails 3 by default. The reasoning behind this is that there is a big push for a RESTful architecture with the Rails application and this type of route isn't really recommended for that kind of application. It can be uncommented but be warned that doing so will make all actions in every controller accessible via GET requests.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.connect ':controller/:action/:id'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match '/:controller(/:action(/:id))'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Regular Routes===&lt;br /&gt;
The way in which a regular route is defined is much more streamlined and readable. In Rails 2, you had to define a key for the controller and action. With Rails 3, this definition is streamlined with a &amp;lt;tt&amp;gt;:to&amp;lt;/tt&amp;gt; key where you define in a specific format the controller and action responsible for the request. Here is an example to illustrate this point:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.connect 'products/:id', :controller =&amp;gt; 'products', :action =&amp;gt; 'view'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match 'products/:id', :to =&amp;gt; 'catalog#view'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Named Routes===&lt;br /&gt;
Setting up named routes has changed a little bit as well. The rules for the regular routes apply here but the way that you define the name of the route has changed. Now, you utilize the &amp;lt;tt&amp;gt;:as&amp;lt;/tt&amp;gt; key to define the name of the route as shown here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.logout '/logout', :controller =&amp;gt; 'sessions', :action =&amp;gt; 'destroy'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
match 'logout', :to =&amp;gt; 'sessions#destroy', :as =&amp;gt; &amp;quot;logout&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Empty Route===&lt;br /&gt;
The empty route defines where to route the application when a user navigates to the root of the website (for normal HTML sites, this is the same as the index page). Rails 2 had a quick way of defining it but in true Ruby fashion, Rails 3 makes it even simpler to define this route as you can see here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Rails 2&lt;br /&gt;
map.root :controller =&amp;gt; &amp;quot;welcome&amp;quot;, :action =&amp;gt; 'show'&lt;br /&gt;
&lt;br /&gt;
# Rails 3&lt;br /&gt;
root :to =&amp;gt; 'welcome#show'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===RESTful Resources===&lt;br /&gt;
&lt;br /&gt;
==Active Record==&lt;br /&gt;
&lt;br /&gt;
===Active Model===&lt;br /&gt;
&lt;br /&gt;
==JavaScript Support&amp;lt;ref&amp;gt;Gadbois 2010&amp;lt;/ref&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
There are many JavaScript libraries available to programmers to make their web applications more dynamic and smooth looking. Whenever you created a Rails 2 application, it would automatically install the Prototype and Script.aculo.us frameworks. Rails also provided helpers for these two JavaScript frameworks so that a few method calls were all that you needed to make your application more fluid.&lt;br /&gt;
&lt;br /&gt;
Rails 3 introduces the idea of Unobtrusive JavaScript (UJS). The JavaScript becomes unobtrusive by not being written in with the HTML objects producing cleaner code that is easier to debug. This is mostly done with the utilization of HTML 5 custom attributes such as data-method, data-confirm, data-remote and data-disable-with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;http://host.com&amp;quot; id=&amp;quot;create-post&amp;quot; method=&amp;quot;post&amp;quot; data-remote=&amp;quot;true&amp;quot; data-confirm=&amp;quot;Are you sure you want to submit?&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By doing this, it also frees Rails from being dependent on the Prototype framework, allowing it to become ''JavaScript framework agnostic''. With its current implementation, the framework can support Prototype, jQuery and MooTools.&lt;br /&gt;
&lt;br /&gt;
It might also be helpful to point out that as of Rails 3.1, the jQuery framework has replaced Prototype as the default JavaScript framework. Programmers that wish to still use Prototype must remember to specify this when they create the Rails application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rails new myapp -j prototype&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
==Citation Notes==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Full Reference Information==&lt;br /&gt;
&lt;br /&gt;
Ruby, Sam, Dave Thomas and David Hansson. ''Agile Web Development with Rails: Third Edition'': The Pragmatic Programmers LLC, 2009.&lt;br /&gt;
&lt;br /&gt;
Gadbois, John. ''Using Unobtrusive JavaScript and AJAX with Rails 3'' http://net.tutsplus.com/tutorials/javascript-ajax/using-unobtrusive-javascript-and-ajax-with-rails-3/ , 2010.&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=49928</id>
		<title>CSC/ECE 517 Fall 2011/ch2 2f mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=49928"/>
		<updated>2011-09-21T04:33:47Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* Full Reference Information */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
&lt;br /&gt;
=Rails 2 vs. Rails 3=&lt;br /&gt;
&lt;br /&gt;
A lot changed in the update from Rails 2 to Rails 3. We will explore a few of the key areas that will affect a programmer's everyday coding.&lt;br /&gt;
&lt;br /&gt;
==Rails Application Scripts==&lt;br /&gt;
&lt;br /&gt;
When you create a new Rails application, a directory named &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; is generated. In Rails 2, this directory is populated with a set of scripts that can be executed by the programmer. A few of the more important ones are as follows&amp;lt;ref&amp;gt;Ruby 2009, pp 257-258 &amp;lt;/ref&amp;gt;:&lt;br /&gt;
*&amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt;: Used to generate code for controllers, mailers, models, scaffolds and other sets of code.&lt;br /&gt;
*&amp;lt;tt&amp;gt;destroy&amp;lt;/tt&amp;gt;: Used to destroy code created by the &amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
*&amp;lt;tt&amp;gt;server&amp;lt;/tt&amp;gt;: Starts up the Rails application in a self-contained web server.&lt;br /&gt;
*&amp;lt;tt&amp;gt;plugin&amp;lt;/tt&amp;gt;: Helps with the installation and administration of plug-ins to the Rails framework.&lt;br /&gt;
*&amp;lt;tt&amp;gt;performance&amp;lt;/tt&amp;gt; directory: Contains scripts used by the programmer to help understand the performance characteristics of the application being built.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with all of these scripts and compiles them all into a single script named &amp;lt;tt&amp;gt;rails&amp;lt;/tt&amp;gt;. With this script, the programmer can access all of the functionality that was available with the separate scripts. To make things even easier, the necessity to call this script outright is even unnecessary. By using the operating systems installed &amp;lt;tt&amp;gt;'''rails'''&amp;lt;/tt&amp;gt; command (ex, &amp;lt;tt&amp;gt;/usr/bin/rails&amp;lt;/tt&amp;gt; on Linux systems) in the root of any Rails 3 application, it will know to call this script.&lt;br /&gt;
&lt;br /&gt;
==Gem Dependencies==&lt;br /&gt;
&lt;br /&gt;
The ability to extend the Rails framework using a Gem is a very powerful feature. In Rails 2, the &amp;lt;tt&amp;gt;config/environment.rb&amp;lt;/tt&amp;gt; file had to be edited in order to tell the Rails application to require specific Gems using the &amp;lt;tt&amp;gt;'''config.gem'''&amp;lt;/tt&amp;gt; method. To ensure that the Gems were actually installed on the system running the Rails application, the programmer had to execute the &amp;lt;tt&amp;gt;rake gem:install&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with the need to have that manual process of installing Gems by utilizing a file named &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; in the root of the application as well as the Bundler. The Bundler looks at the contents &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; and automatically installs any Gems that are missing from the system. This allows the programmer to focus on more important issues.&lt;br /&gt;
&lt;br /&gt;
==Action Controller==&lt;br /&gt;
&lt;br /&gt;
==Routing DSL==&lt;br /&gt;
&lt;br /&gt;
==Active Record==&lt;br /&gt;
&lt;br /&gt;
===Active Model===&lt;br /&gt;
&lt;br /&gt;
==JavaScript Support&amp;lt;ref&amp;gt;Gadbois 2010&amp;lt;/ref&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
There are many JavaScript libraries available to programmers to make their web applications more dynamic and smooth looking. Whenever you created a Rails 2 application, it would automatically install the Prototype and Script.aculo.us frameworks. Rails also provided helpers for these two JavaScript frameworks so that a few method calls were all that you needed to make your application more fluid.&lt;br /&gt;
&lt;br /&gt;
Rails 3 introduces the idea of Unobtrusive JavaScript (UJS). The JavaScript becomes unobtrusive by not being written in with the HTML objects producing cleaner code that is easier to debug. This is mostly done with the utilization of HTML 5 custom attributes such as data-method, data-confirm, data-remote and data-disable-with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;http://host.com&amp;quot; id=&amp;quot;create-post&amp;quot; method=&amp;quot;post&amp;quot; data-remote=&amp;quot;true&amp;quot; data-confirm=&amp;quot;Are you sure you want to submit?&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By doing this, it also frees Rails from being dependent on the Prototype framework, allowing it to become ''JavaScript framework agnostic''. With its current implementation, the framework can support Prototype, jQuery and MooTools.&lt;br /&gt;
&lt;br /&gt;
It might also be helpful to point out that as of Rails 3.1, the jQuery framework has replaced Prototype as the default JavaScript framework. Programmers that wish to still use Prototype must remember to specify this when they create the Rails application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rails new myapp -j prototype&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
==Citation Notes==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Full Reference Information==&lt;br /&gt;
&lt;br /&gt;
Ruby, Sam, Dave Thomas and David Hansson. ''Agile Web Development with Rails: Third Edition'': The Pragmatic Programmers LLC, 2009.&lt;br /&gt;
&lt;br /&gt;
Gadbois, John. ''Using Unobtrusive JavaScript and AJAX with Rails 3'' http://net.tutsplus.com/tutorials/javascript-ajax/using-unobtrusive-javascript-and-ajax-with-rails-3/ , 2010.&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=49927</id>
		<title>CSC/ECE 517 Fall 2011/ch2 2f mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=49927"/>
		<updated>2011-09-21T04:31:29Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: /* JavaScript Libraries */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
&lt;br /&gt;
=Rails 2 vs. Rails 3=&lt;br /&gt;
&lt;br /&gt;
A lot changed in the update from Rails 2 to Rails 3. We will explore a few of the key areas that will affect a programmer's everyday coding.&lt;br /&gt;
&lt;br /&gt;
==Rails Application Scripts==&lt;br /&gt;
&lt;br /&gt;
When you create a new Rails application, a directory named &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; is generated. In Rails 2, this directory is populated with a set of scripts that can be executed by the programmer. A few of the more important ones are as follows&amp;lt;ref&amp;gt;Ruby 2009, pp 257-258 &amp;lt;/ref&amp;gt;:&lt;br /&gt;
*&amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt;: Used to generate code for controllers, mailers, models, scaffolds and other sets of code.&lt;br /&gt;
*&amp;lt;tt&amp;gt;destroy&amp;lt;/tt&amp;gt;: Used to destroy code created by the &amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
*&amp;lt;tt&amp;gt;server&amp;lt;/tt&amp;gt;: Starts up the Rails application in a self-contained web server.&lt;br /&gt;
*&amp;lt;tt&amp;gt;plugin&amp;lt;/tt&amp;gt;: Helps with the installation and administration of plug-ins to the Rails framework.&lt;br /&gt;
*&amp;lt;tt&amp;gt;performance&amp;lt;/tt&amp;gt; directory: Contains scripts used by the programmer to help understand the performance characteristics of the application being built.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with all of these scripts and compiles them all into a single script named &amp;lt;tt&amp;gt;rails&amp;lt;/tt&amp;gt;. With this script, the programmer can access all of the functionality that was available with the separate scripts. To make things even easier, the necessity to call this script outright is even unnecessary. By using the operating systems installed &amp;lt;tt&amp;gt;'''rails'''&amp;lt;/tt&amp;gt; command (ex, &amp;lt;tt&amp;gt;/usr/bin/rails&amp;lt;/tt&amp;gt; on Linux systems) in the root of any Rails 3 application, it will know to call this script.&lt;br /&gt;
&lt;br /&gt;
==Gem Dependencies==&lt;br /&gt;
&lt;br /&gt;
The ability to extend the Rails framework using a Gem is a very powerful feature. In Rails 2, the &amp;lt;tt&amp;gt;config/environment.rb&amp;lt;/tt&amp;gt; file had to be edited in order to tell the Rails application to require specific Gems using the &amp;lt;tt&amp;gt;'''config.gem'''&amp;lt;/tt&amp;gt; method. To ensure that the Gems were actually installed on the system running the Rails application, the programmer had to execute the &amp;lt;tt&amp;gt;rake gem:install&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with the need to have that manual process of installing Gems by utilizing a file named &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; in the root of the application as well as the Bundler. The Bundler looks at the contents &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; and automatically installs any Gems that are missing from the system. This allows the programmer to focus on more important issues.&lt;br /&gt;
&lt;br /&gt;
==Action Controller==&lt;br /&gt;
&lt;br /&gt;
==Routing DSL==&lt;br /&gt;
&lt;br /&gt;
==Active Record==&lt;br /&gt;
&lt;br /&gt;
===Active Model===&lt;br /&gt;
&lt;br /&gt;
==JavaScript Support&amp;lt;ref&amp;gt;Gadbois 2010&amp;lt;/ref&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
There are many JavaScript libraries available to programmers to make their web applications more dynamic and smooth looking. Whenever you created a Rails 2 application, it would automatically install the Prototype and Script.aculo.us frameworks. Rails also provided helpers for these two JavaScript frameworks so that a few method calls were all that you needed to make your application more fluid.&lt;br /&gt;
&lt;br /&gt;
Rails 3 introduces the idea of Unobtrusive JavaScript (UJS). The JavaScript becomes unobtrusive by not being written in with the HTML objects producing cleaner code that is easier to debug. This is mostly done with the utilization of HTML 5 custom attributes such as data-method, data-confirm, data-remote and data-disable-with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;http://host.com&amp;quot; id=&amp;quot;create-post&amp;quot; method=&amp;quot;post&amp;quot; data-remote=&amp;quot;true&amp;quot; data-confirm=&amp;quot;Are you sure you want to submit?&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By doing this, it also frees Rails from being dependent on the Prototype framework, allowing it to become ''JavaScript framework agnostic''. With its current implementation, the framework can support Prototype, jQuery and MooTools.&lt;br /&gt;
&lt;br /&gt;
It might also be helpful to point out that as of Rails 3.1, the jQuery framework has replaced Prototype as the default JavaScript framework. Programmers that wish to still use Prototype must remember to specify this when they create the Rails application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rails new myapp -j prototype&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
==Citation Notes==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Full Reference Information==&lt;br /&gt;
&lt;br /&gt;
Ruby, Sam, Dave Thomas and David Hansson. ''Agile Web Development with Rails: Third Edition'': The Pragmatic Programmers LLC, 2009.&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=49926</id>
		<title>CSC/ECE 517 Fall 2011/ch2 2f mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=49926"/>
		<updated>2011-09-21T04:12:55Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
&lt;br /&gt;
=Rails 2 vs. Rails 3=&lt;br /&gt;
&lt;br /&gt;
A lot changed in the update from Rails 2 to Rails 3. We will explore a few of the key areas that will affect a programmer's everyday coding.&lt;br /&gt;
&lt;br /&gt;
==Rails Application Scripts==&lt;br /&gt;
&lt;br /&gt;
When you create a new Rails application, a directory named &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; is generated. In Rails 2, this directory is populated with a set of scripts that can be executed by the programmer. A few of the more important ones are as follows&amp;lt;ref&amp;gt;Ruby 2009, pp 257-258 &amp;lt;/ref&amp;gt;:&lt;br /&gt;
*&amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt;: Used to generate code for controllers, mailers, models, scaffolds and other sets of code.&lt;br /&gt;
*&amp;lt;tt&amp;gt;destroy&amp;lt;/tt&amp;gt;: Used to destroy code created by the &amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
*&amp;lt;tt&amp;gt;server&amp;lt;/tt&amp;gt;: Starts up the Rails application in a self-contained web server.&lt;br /&gt;
*&amp;lt;tt&amp;gt;plugin&amp;lt;/tt&amp;gt;: Helps with the installation and administration of plug-ins to the Rails framework.&lt;br /&gt;
*&amp;lt;tt&amp;gt;performance&amp;lt;/tt&amp;gt; directory: Contains scripts used by the programmer to help understand the performance characteristics of the application being built.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with all of these scripts and compiles them all into a single script named &amp;lt;tt&amp;gt;rails&amp;lt;/tt&amp;gt;. With this script, the programmer can access all of the functionality that was available with the separate scripts. To make things even easier, the necessity to call this script outright is even unnecessary. By using the operating systems installed &amp;lt;tt&amp;gt;'''rails'''&amp;lt;/tt&amp;gt; command (ex, &amp;lt;tt&amp;gt;/usr/bin/rails&amp;lt;/tt&amp;gt; on Linux systems) in the root of any Rails 3 application, it will know to call this script.&lt;br /&gt;
&lt;br /&gt;
==Gem Dependencies==&lt;br /&gt;
&lt;br /&gt;
The ability to extend the Rails framework using a Gem is a very powerful feature. In Rails 2, the &amp;lt;tt&amp;gt;config/environment.rb&amp;lt;/tt&amp;gt; file had to be edited in order to tell the Rails application to require specific Gems using the &amp;lt;tt&amp;gt;'''config.gem'''&amp;lt;/tt&amp;gt; method. To ensure that the Gems were actually installed on the system running the Rails application, the programmer had to execute the &amp;lt;tt&amp;gt;rake gem:install&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with the need to have that manual process of installing Gems by utilizing a file named &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; in the root of the application as well as the Bundler. The Bundler looks at the contents &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; and automatically installs any Gems that are missing from the system. This allows the programmer to focus on more important issues.&lt;br /&gt;
&lt;br /&gt;
==Action Controller==&lt;br /&gt;
&lt;br /&gt;
==Routing DSL==&lt;br /&gt;
&lt;br /&gt;
==Active Record==&lt;br /&gt;
&lt;br /&gt;
===Active Model===&lt;br /&gt;
&lt;br /&gt;
==JavaScript Libraries==&lt;br /&gt;
&lt;br /&gt;
There are many JavaScript libraries available to programmers to make their web applications more dynamic and smooth looking. Whenever you created a Rails 2 application, it would automatically install the Prototype framework. As of Rails 3.1, the jQuery framework has replaced Prototype as the default JavaScript framework. Programmers that wish to still use Prototype must remember to specify this when they create the Rails application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rails new myapp -j prototype&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
==Citation Notes==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Full Reference Information==&lt;br /&gt;
&lt;br /&gt;
Ruby, Sam, Dave Thomas and David Hansson. ''Agile Web Development with Rails: Third Edition'': The Pragmatic Programmers LLC, 2009.&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=49920</id>
		<title>CSC/ECE 517 Fall 2011/ch2 2f mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=49920"/>
		<updated>2011-09-21T04:05:01Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
&lt;br /&gt;
=Rails 2 vs. Rails 3=&lt;br /&gt;
&lt;br /&gt;
A lot changed in the update from Rails 2 to Rails 3. We will explore a few of the key areas that will affect a programmer's everyday coding.&lt;br /&gt;
&lt;br /&gt;
==Rails Application Scripts==&lt;br /&gt;
&lt;br /&gt;
When you create a new Rails application, a directory named &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; is generated. In Rails 2, this directory is populated with a set of scripts that can be executed by the programmer. A few of the more important ones are as follows&amp;lt;ref&amp;gt;Ruby 2009, pp 257-258 &amp;lt;/ref&amp;gt;:&lt;br /&gt;
*&amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt;: Used to generate code for controllers, mailers, models, scaffolds and other sets of code.&lt;br /&gt;
*&amp;lt;tt&amp;gt;destroy&amp;lt;/tt&amp;gt;: Used to destroy code created by the &amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
*&amp;lt;tt&amp;gt;server&amp;lt;/tt&amp;gt;: Starts up the Rails application in a self-contained web server.&lt;br /&gt;
*&amp;lt;tt&amp;gt;plugin&amp;lt;/tt&amp;gt;: Helps with the installation and administration of plug-ins to the Rails framework.&lt;br /&gt;
*&amp;lt;tt&amp;gt;performance&amp;lt;/tt&amp;gt; directory: Contains scripts used by the programmer to help understand the performance characteristics of the application being built.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with all of these scripts and compiles them all into a single script named &amp;lt;tt&amp;gt;rails&amp;lt;/tt&amp;gt;. With this script, the programmer can access all of the functionality that was available with the separate scripts. To make things even easier, the necessity to call this script outright is even unnecessary. By using the operating systems installed &amp;lt;tt&amp;gt;'''rails'''&amp;lt;/tt&amp;gt; command (ex, &amp;lt;tt&amp;gt;/usr/bin/rails&amp;lt;/tt&amp;gt; on Linux systems) in the root of any Rails 3 application, it will know to call this script.&lt;br /&gt;
&lt;br /&gt;
==Gem Dependencies==&lt;br /&gt;
&lt;br /&gt;
The ability to extend the Rails framework using a Gem is a very powerful feature. In Rails 2, the &amp;lt;tt&amp;gt;config/environment.rb&amp;lt;/tt&amp;gt; file had to be edited in order to tell the Rails application to require specific Gems using the &amp;lt;tt&amp;gt;'''config.gem'''&amp;lt;/tt&amp;gt; method. To ensure that the Gems were actually installed on the system running the Rails application, the programmer had to execute the &amp;lt;tt&amp;gt;rake gem:install&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with the need to have that manual process of installing Gems by utilizing a file named &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; in the root of the application as well as the Bundler. The Bundler looks at the contents &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; and automatically installs any Gems that are missing from the system. This allows the programmer to focus on more important issues.&lt;br /&gt;
&lt;br /&gt;
==Action Controller==&lt;br /&gt;
&lt;br /&gt;
==Routing DSL==&lt;br /&gt;
&lt;br /&gt;
==Active Record==&lt;br /&gt;
&lt;br /&gt;
===Active Model===&lt;br /&gt;
&lt;br /&gt;
==JavaScript Libraries==&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
==Citation Notes==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Full Reference Information==&lt;br /&gt;
&lt;br /&gt;
Ruby, Sam, Dave Thomas and David Hansson. ''Agile Web Development with Rails: Third Edition'': The Pragmatic Programmers LLC, 2009.&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=49918</id>
		<title>CSC/ECE 517 Fall 2011/ch2 2f mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=49918"/>
		<updated>2011-09-21T03:56:00Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
&lt;br /&gt;
=Rails 2 vs. Rails 3=&lt;br /&gt;
&lt;br /&gt;
A lot changed in the update from Rails 2 to Rails 3. We will explore a few of the key areas that will affect a programmer's everyday coding.&lt;br /&gt;
&lt;br /&gt;
==Rails Application Scripts==&lt;br /&gt;
&lt;br /&gt;
When you create a new Rails application, a directory named &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; is generated. In Rails 2, this directory is populated with a set of scripts that can be executed by the programmer. A few of the more important ones are as follows&amp;lt;ref&amp;gt;Ruby 2009, pp 257-258 &amp;lt;/ref&amp;gt;:&lt;br /&gt;
*&amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt;: Used to generate code for controllers, mailers, models, scaffolds and other sets of code.&lt;br /&gt;
*&amp;lt;tt&amp;gt;destroy&amp;lt;/tt&amp;gt;: Used to destroy code created by the &amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
*&amp;lt;tt&amp;gt;server&amp;lt;/tt&amp;gt;: Starts up the Rails application in a self-contained web server.&lt;br /&gt;
*&amp;lt;tt&amp;gt;plugin&amp;lt;/tt&amp;gt;: Helps with the installation and administration of plug-ins to the Rails framework.&lt;br /&gt;
*&amp;lt;tt&amp;gt;performance&amp;lt;/tt&amp;gt; directory: Contains scripts used by the programmer to help understand the performance characteristics of the application being built.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with all of these scripts and compiles them all into a single script named &amp;lt;tt&amp;gt;rails&amp;lt;/tt&amp;gt;. With this script, the programmer can access all of the functionality that was available with the separate scripts. To make things even easier, the necessity to call this script outright is even unnecessary. By using the operating systems installed &amp;lt;tt&amp;gt;'''rails'''&amp;lt;/tt&amp;gt; command (ex, &amp;lt;tt&amp;gt;/usr/bin/rails&amp;lt;/tt&amp;gt; on Linux systems) in the root of any Rails 3 application, it will know to call this script.&lt;br /&gt;
&lt;br /&gt;
==Gem Dependencies==&lt;br /&gt;
&lt;br /&gt;
The ability to extend the Rails framework using a Gem is a very powerful feature. In Rails 2, the &amp;lt;tt&amp;gt;config/environment.rb&amp;lt;/tt&amp;gt; file had to be edited in order to tell the Rails application to require specific Gems using the &amp;lt;tt&amp;gt;'''config.gem'''&amp;lt;/tt&amp;gt; method. To ensure that the Gems were actually installed on the system running the Rails application, the programmer had to execute the &amp;lt;tt&amp;gt;rake gem:install&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with the need to have that manual process of installing Gems by utilizing a file named &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; in the root of the application as well as the Bundler. The Bundler looks at the contents &amp;lt;tt&amp;gt;Gemfile&amp;lt;/tt&amp;gt; and automatically installs any Gems that are missing from the system. This allows the programmer to focus on more important issues.&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
==Citation Notes==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Full Reference Information==&lt;br /&gt;
&lt;br /&gt;
Ruby, Sam, Dave Thomas and David Hansson. ''Agile Web Development with Rails: Third Edition'': The Pragmatic Programmers LLC, 2009.&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=49916</id>
		<title>CSC/ECE 517 Fall 2011/ch2 2f mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=49916"/>
		<updated>2011-09-21T03:45:49Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
&lt;br /&gt;
=Rails 2 vs. Rails 3=&lt;br /&gt;
&lt;br /&gt;
A lot changed in the update from Rails 2 to Rails 3. We will explore a few of the key areas that will affect a programmer's everyday coding.&lt;br /&gt;
&lt;br /&gt;
==Rails Application Scripts==&lt;br /&gt;
&lt;br /&gt;
When you create a new Rails application, a directory named &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; is generated. In Rails 2, this directory is populated with a set of scripts that can be executed by the programmer. A few of the more important ones are as follows&amp;lt;ref&amp;gt;Ruby 2009, pp 257-258 &amp;lt;/ref&amp;gt;:&lt;br /&gt;
*&amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt;: Used to generate code for controllers, mailers, models, scaffolds and other sets of code.&lt;br /&gt;
*&amp;lt;tt&amp;gt;destroy&amp;lt;/tt&amp;gt;: Used to destroy code created by the &amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
*&amp;lt;tt&amp;gt;server&amp;lt;/tt&amp;gt;: Starts up the Rails application in a self-contained web server.&lt;br /&gt;
*&amp;lt;tt&amp;gt;plugin&amp;lt;/tt&amp;gt;: Helps with the installation and administration of plug-ins to the Rails framework.&lt;br /&gt;
*&amp;lt;tt&amp;gt;performance&amp;lt;/tt&amp;gt; directory: Contains scripts used by the programmer to help understand the performance characteristics of the application being built.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with all of these scripts and compiles them all into a single script named &amp;lt;tt&amp;gt;rails&amp;lt;/tt&amp;gt;. With this script, the programmer can access all of the functionality that was available with the separate scripts. To make things even easier, the necessity to call this script outright is even unnecessary. By using the operating systems installed &amp;lt;tt&amp;gt;'''rails'''&amp;lt;/tt&amp;gt; command (ex, &amp;lt;tt&amp;gt;/usr/bin/rails&amp;lt;/tt&amp;gt; on Linux systems) in the root of any Rails 3 application, it will know to call this script.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
&lt;br /&gt;
==Citation Notes==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Full Reference Information==&lt;br /&gt;
&lt;br /&gt;
Ruby, Sam, Dave Thomas and David Hansson. ''Agile Web Development with Rails: Third Edition'': The Pragmatic Programmers LLC, 2009.&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=49915</id>
		<title>CSC/ECE 517 Fall 2011/ch2 2f mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=49915"/>
		<updated>2011-09-21T03:36:54Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
&lt;br /&gt;
=Rails 2 vs. Rails 3=&lt;br /&gt;
&lt;br /&gt;
A lot changed in the update from Rails 2 to Rails 3. We will explore a few of the key areas that will affect a programmer's everyday coding.&lt;br /&gt;
&lt;br /&gt;
==Rails Application Scripts==&lt;br /&gt;
&lt;br /&gt;
When you create a new Rails application, a directory named &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; is generated. In Rails 2, this directory is populated with a set of scripts that can be executed by the programmer. A few of the more important ones are as follows:&lt;br /&gt;
*&amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt;: Used to generate code for controllers, mailers, models, scaffolds and other sets of code.&lt;br /&gt;
*&amp;lt;tt&amp;gt;destroy&amp;lt;/tt&amp;gt;: Used to destroy code created by the &amp;lt;tt&amp;gt;generate&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
*&amp;lt;tt&amp;gt;server&amp;lt;/tt&amp;gt;: Starts up the Rails application in a self-contained web server.&lt;br /&gt;
*&amp;lt;tt&amp;gt;plugin&amp;lt;/tt&amp;gt;: Helps with the installation and administration of plug-ins to the Rails framework.&lt;br /&gt;
*&amp;lt;tt&amp;gt;performance&amp;lt;/tt&amp;gt; directory: Contains scripts used by the programmer to help understand the performance characteristics of the application being built.&lt;br /&gt;
&lt;br /&gt;
Rails 3 does away with all of these scripts and compiles them all into a single script named &amp;lt;tt&amp;gt;rails&amp;lt;/tt&amp;gt;. With this script, the programmer can access all of the functionality that was available with the separate scripts. To make things even easier, the necessity to call this script outright is even unnecessary. By using the operating systems installed &amp;lt;tt&amp;gt;''rails''&amp;lt;/tt&amp;gt; command (ie, &amp;lt;tt&amp;gt;/usr/bin/rails&amp;lt;/tt&amp;gt; on Linux systems) in the root of any Rails 3 application, it will know to call this script.&lt;br /&gt;
&lt;br /&gt;
=References=&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=49828</id>
		<title>CSC/ECE 517 Fall 2011/ch2 2f mm</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch2_2f_mm&amp;diff=49828"/>
		<updated>2011-09-20T23:48:29Z</updated>

		<summary type="html">&lt;p&gt;Mrmanrin: Created page with &amp;quot;=Introduction=&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;/div&gt;</summary>
		<author><name>Mrmanrin</name></author>
	</entry>
</feed>