<?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=ISuite</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=ISuite"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/ISuite"/>
	<updated>2026-05-17T13:10:59Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5e_dr&amp;diff=40022</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5e dr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5e_dr&amp;diff=40022"/>
		<updated>2010-11-03T22:41:31Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Dependency Injection'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
Every enterprise application involves handful number of objects that work together to achieve some purpose. These objects are coupled with each other and work in collaboration, making the classes highly dependent. However, creating such code involving highly coupled classes defeats an important tenet of Object oriented design- ‘loose coupling’. Loose coupling means that objects should have the minimum number of dependencies, which makes the code easy to understand, modify and debug. It also allows for greater code reusability and improves the maintainability.[http://www.codeproject.com/KB/architecture/DependencyInjection.aspx] This drive to decouple the code from its highly dependent objects leads to the concept of Dependency Injection.&lt;br /&gt;
&lt;br /&gt;
= Definition =&lt;br /&gt;
The basic concept of Dependency Injection(DI) is that you do not create the objects themselves, but describe how they should be created. It is one of the more popular design paradigms known today, by which the objects define their dependencies, i.e. the objects or classes they work with. DI pattern provides better a software design that makes the code cleaner, since the object doesn’t need to look for other components it works with, or know their location and class.[http://www.springframework.net/doc-latest/reference/html/objects.html#objects-factory-collaborators]&lt;br /&gt;
It facilitates the design of applications, using a framework that links the components, instead of the components linking themselves.  &lt;br /&gt;
&lt;br /&gt;
In other words, Dependency Injection, also known as Inversion Of Control(IoC), transfers the responsibility to locate and create the objects to the framework or the container which supports plug-n-play implementation, by injecting the dependencies into your code.&lt;br /&gt;
&lt;br /&gt;
= Features of Dependency Injection =&lt;br /&gt;
Main features of Dependency Injection Framework are:&lt;br /&gt;
* Better Design Pattern - Supports good Object-Oriented Design.&lt;br /&gt;
* Clean Code- Eliminates the need of looking up code from the application.&lt;br /&gt;
* Reuse - Promotes better code reusability.&lt;br /&gt;
* Loose Coupling- Objects are loosely coupled using DI&lt;br /&gt;
* Simple- It is very simple to implement, just need to inject the dependencies of any object.&lt;br /&gt;
* Maintainable- It is very easy to reconfigure and maintain in case of any future changes.&lt;br /&gt;
* More Testable- It makes it very easy to test the code, as objects get instantiated with values using configuration files.&lt;br /&gt;
&lt;br /&gt;
= Dependency Injection Frameworks =&lt;br /&gt;
Dependency Injection requires a framework that helps the developer to declare the dependencies, to locate, instantiate, and initialize the components or the objects. A developer has many available frameworks to him:&lt;br /&gt;
* '''Spring Framework''' – A light weight container, most widely used for DI and very large framework, which includes a lot many other features like Aspect Oriented, framework, container, etc. along with Dependency Injection.[http://www.springsource.org/]&lt;br /&gt;
* '''XWork''' -  It is a standalone framework and mostly works in conjunction with Webworks. It is a highly effective command pattern framework that provides a lot of features for DI.[http://www.opensymphony.com/xwork/]&lt;br /&gt;
* '''Apache Avalon'''- This is also a container framework which supports the dependency injection design pattern. This frameworks is now divided into sub-frameworks.[http://excalibur.apache.org/framework/index.html]&lt;br /&gt;
* '''PicoContainer''' - It is a highly focused DI framework available.[http://www.picocontainer.org/]&lt;br /&gt;
* '''Hivelogic''' – Another DI framework to inject dependencies.[http://hivelogic.com/]&lt;br /&gt;
&lt;br /&gt;
== Example of Dependency Injection Framework ==&lt;br /&gt;
&lt;br /&gt;
Let us consider a simple example to understand the basic idea of DI.&lt;br /&gt;
Suppose we have an Employee class which depends on the Department object. We need some Assembler (DI Framework) to instantiate the Department field of Employee class. Rather than Employee class creating this object for itself, it will delegate this task of instantiation to any framework selected from above. To do this, it uses configuration files, which are mostly .xml files. We will see comprehensive example using the framework in the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch5_5e_dr#Types_of_Dependency_Injection section 4]. &lt;br /&gt;
&lt;br /&gt;
 '''''Employee.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class Employee&lt;br /&gt;
  {&lt;br /&gt;
         //dependent object ‘dept'&lt;br /&gt;
         private Department dept;&lt;br /&gt;
         public void Employee( ){ }  &lt;br /&gt;
         &lt;br /&gt;
         setDepartment(dept){&lt;br /&gt;
             this.dept=dept;&lt;br /&gt;
         }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
 '''''Department.java'''''&lt;br /&gt;
  package myPackage;&lt;br /&gt;
  public class Department&lt;br /&gt;
   {&lt;br /&gt;
      private String name; &lt;br /&gt;
      public String getName(){&lt;br /&gt;
          return name;&lt;br /&gt;
       }&lt;br /&gt;
      public void setName(String name){&lt;br /&gt;
          this.name=name;&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
The framework will instantiate the Department object by looking into the configuration file for any existing dependencies of Employee object. It will form an Employee object with a Department instance. For example, in Spring Framework, the configuration file will be ApplicationContext.xml, where the binding of beans is done as follows:&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationContext.xml'''''&lt;br /&gt;
 &amp;lt;beans&amp;gt;&lt;br /&gt;
      &amp;lt;bean id=&amp;quot;employee&amp;quot; class=&amp;quot; myPackage .Employee.java&amp;quot;&amp;gt;&lt;br /&gt;
     	   &amp;lt;property name=&amp;quot;name &amp;quot; ref=&amp;quot;yetAnotherBean&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/bean&amp;gt;&lt;br /&gt;
      &amp;lt;bean id=&amp;quot;department&amp;quot; class=&amp;quot; myPackage .Department.java&amp;quot;&amp;gt;     	&lt;br /&gt;
  	   &amp;lt;property name=&amp;quot;name&amp;quot; value=&amp;quot;Java&amp;quot;/&amp;gt;      &lt;br /&gt;
      &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
thereby creating the dependency diagram as: &amp;lt;br&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
[[Image:Di_image1.png]]&lt;br /&gt;
&lt;br /&gt;
Here we can see that, the classes themselves do not create their own instances, but it is the framework that does this job for them, making the code cleaner, reusable and loosely coupled. In future if one wants to add on, delete or modify any of the dependent objects, one only needs to update the configuration file. There is no need to look up the code all over again to find the class’s dependent objects. One can make modifications to the lines of code creating instances, which may be,&lt;br /&gt;
		&lt;br /&gt;
  // used everywhere in code without Dependency Injection.&lt;br /&gt;
  Department dept=new Department ();  &lt;br /&gt;
&lt;br /&gt;
Thus it makes our code configurable and maintainable. &lt;br /&gt;
Let us now move on and see some more examples to understand the different types of injections available within different frameworks.&lt;br /&gt;
&lt;br /&gt;
= Types of Dependency Injection =&lt;br /&gt;
&lt;br /&gt;
There are a number of Dependency Injection variants that exists to allow the developer to implement and write loosely coupled code. The dependencies can be injected in various forms like: &lt;br /&gt;
* Type 1- Interface Injection&lt;br /&gt;
* Type 2- Setter Injection&lt;br /&gt;
* Type 3- Constructor Injection&lt;br /&gt;
&lt;br /&gt;
== Type 1- Interface Injection ==&lt;br /&gt;
&lt;br /&gt;
Interface injection is a technique to add the dependency for interfaces in components at run time. The components implement these interfaces based on the injected dependency. Spring framework does not support interface injection, so let us see this injection by using the Avalon framework.&lt;br /&gt;
&lt;br /&gt;
For example, we have an ApplicationDAO interface, while AccountApplicationDAO and  CustomerApplicationDAO are the classes implementing ApplicationDAO, &lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public interface ApplicationDAO&lt;br /&gt;
   {&lt;br /&gt;
       void getEntity();&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
 '''''AccountApplicationDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class AccountApplicationDAO implements ApplicationDAO&lt;br /&gt;
 {&lt;br /&gt;
        void getEntity(){&lt;br /&gt;
             //get all accounts.&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
 '''''CustomerApplicationDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class CustomerApplicationDAO implements ApplicationDAO&lt;br /&gt;
 {&lt;br /&gt;
        void getEntity()&lt;br /&gt;
        {&lt;br /&gt;
               //get all customers.&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We also have ApplicationService interface, which depends on the ApplicationDAO interface. The ApplicationServiceImpl class implements the ApplicationService inteface, which in turn implements the ApplicationDAO interface, provided by the container.&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationService.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public interface ApplicationService&lt;br /&gt;
 {&lt;br /&gt;
       getEntity(ApplicationDAO applicationDAO);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationServiceImpl.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class ApplicationServiceImpl implements ApplicationService &lt;br /&gt;
  {&lt;br /&gt;
        ApplicationDAO applicationDAO;&lt;br /&gt;
        validateEntity (ApplicationDAO applicationDAO)&lt;br /&gt;
         {&lt;br /&gt;
                this. applicationDAO= applicationDAO;&lt;br /&gt;
                applicationDAO.getEntity();&lt;br /&gt;
                //code to validate the Entity (Account/Customer),as per the configuration in xml file.&lt;br /&gt;
          }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
Now, our main program will get the interface dependency from the container, which uses configuration file for look up, &lt;br /&gt;
&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class MyClass&lt;br /&gt;
 {&lt;br /&gt;
        public static void main(string[] args)&lt;br /&gt;
        {&lt;br /&gt;
            // Get the correct dependency based on configuration file&lt;br /&gt;
            ApplicationDAO dependencyDAO = getDependecny();&lt;br /&gt;
 &lt;br /&gt;
            // Create our applicationServiceImpl class and inject the dependency&lt;br /&gt;
 	    ApplicationServiceImpl applicationServiceImpl = new ApplicationServiceImpl();&lt;br /&gt;
            // call validateEntity()&lt;br /&gt;
            ((ApplicationService)applicationServiceImpl).validateEntity(dependencyDAO);&lt;br /&gt;
 &lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        public static ApplicationDAO getDependency()&lt;br /&gt;
        {&lt;br /&gt;
            string implementClass =  &lt;br /&gt;
                                    System.Configuration.ConfigurationManager.AppSettings[&amp;quot;selectedClass&amp;quot;];&lt;br /&gt;
            Type type = System.Type.GetType(implementClass);&lt;br /&gt;
            ApplicationDAO applicationDAO = (ApplicationDAO)Activator.CreateInstance(type);&lt;br /&gt;
             &lt;br /&gt;
            return applicationDAO;&lt;br /&gt;
        }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
The Configuration File that will be used by MyClass file to lookup the dependency configurations will be of type:&lt;br /&gt;
&lt;br /&gt;
 '''''App.Config'''''&lt;br /&gt;
 &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
 &amp;lt;configuration&amp;gt;&lt;br /&gt;
      &amp;lt;appSettings&amp;gt;&lt;br /&gt;
            &amp;lt;add key=&amp;quot; selectedClass &amp;quot; value=&amp;quot;myPackage. AccountApplicationDAO &amp;quot; /&amp;gt;&lt;br /&gt;
       &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
 &amp;lt;/configuration&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
In this example, validateEntity() in ApplicationServiceImpl will call getEntity() using  &lt;br /&gt;
ApplicationDAO reference. The getEntity() that is invoked will actually depend on the dependency that is injected via the configuration file.&lt;br /&gt;
&lt;br /&gt;
==Type 2- Setter Injection==&lt;br /&gt;
&lt;br /&gt;
Dependency can be injected using the setter method of a class. If a class is dependent on another class or object instances, then the dependency should be declared as a state(variable) of the class and the class should have a setter method for it. The dependencies are set onto public attributes of the object in need. One of the primary motive for using setters, is supporting dependency injection without having to modify the constructor of a legacy class. Another use is to allow the creation of expensive resources or services as late as possible and only when needed, which is an edge over the Constructor Injection, which we will see in few moments.&lt;br /&gt;
&lt;br /&gt;
Let us consider an example of Setter injection by using Spring Framework.[3] Before using Spring, let us study some basic features of Spring. We will cover only a brief overview of the Spring Framework. &lt;br /&gt;
&lt;br /&gt;
* Spring is a lightweight container which along with supporting features like Dependency Injection, also include other ones as:  Container, Framework, AOP[http://static.springsource.org/spring/docs/2.5.x/reference/aop.html], MVC, etc. &lt;br /&gt;
* Spring Framework supports both Setter Injection and Constructor Injection, but not Interface Injection. Spring jars that can be included are : &lt;br /&gt;
** spring-beans.jar&lt;br /&gt;
** spring-core.jar&lt;br /&gt;
* Packages that provide Spring Frameworks’s IoC container are:&lt;br /&gt;
** org.springframeworks.beans&lt;br /&gt;
** org.springframeworks.context&lt;br /&gt;
&lt;br /&gt;
Now let us see Setter injection using the Spring framework.&lt;br /&gt;
The example below includes a class, DoctorService. The DoctorService class needs a data-access object for communicating with the database. Assume, the PrescriptionDAO (&amp;quot;order data-access object&amp;quot;) is the class on which DoctorService depends. &amp;lt;br&amp;gt;[[image:di_image2.png]] &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 '''''DoctorService.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class DoctorService&lt;br /&gt;
 {&lt;br /&gt;
       private PrescriptionDAO prescriptionDAO;&lt;br /&gt;
       //empty constructor&lt;br /&gt;
       public DoctorService () {}&lt;br /&gt;
       public PrescriptionDAO getPrescriptionDAO() &lt;br /&gt;
       { &lt;br /&gt;
              return this.prescriptionDAO;&lt;br /&gt;
       }&lt;br /&gt;
       //setter for prescriptionDAO&lt;br /&gt;
       public setPrescriptionDAO(prescriptionDAO) &lt;br /&gt;
       { &lt;br /&gt;
              this.prescriptionDAO = prescriptionDAO; &lt;br /&gt;
       }&lt;br /&gt;
       //business logic that actually uses prescriptionDAOto access its variables and methods.&lt;br /&gt;
       public void print()&lt;br /&gt;
       {&lt;br /&gt;
              System.out.println(“prescription: “+prescriptionDAO.prescription);&lt;br /&gt;
              System.out.println(“dose: “+prescriptionDAO.dose);&lt;br /&gt;
       }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
 '''''PrescriptionDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class PrescriptionDAO&lt;br /&gt;
 {&lt;br /&gt;
        private String prescription;&lt;br /&gt;
        private int dose;&lt;br /&gt;
        public PrescriptionDAO(){}&lt;br /&gt;
        public String getPrescription () &lt;br /&gt;
        {&lt;br /&gt;
                return  this.prescription;&lt;br /&gt;
        }&lt;br /&gt;
        public void setPrescription(String prescription) &lt;br /&gt;
        {&lt;br /&gt;
           this. prescription = prescription;&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Here, the invoking object is responsible for setting the PrescriptionDAO dependency. There is no code inside the class that is creating new instance of PrescriptionDAO. This is because this task will be performed by the Spring container, by looking for dependencies of DoctorService inside applicationContext.xml file.&lt;br /&gt;
&lt;br /&gt;
The Spring framework uses a setter method to create this dependent object. Note the &amp;lt;property&amp;gt; tag which is used inside ApplicationContext.xml file for setter injection. &lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationContext.xml'''''&lt;br /&gt;
 &amp;lt;beans xmlns=&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;br /&gt;
    xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;br /&gt;
    xmlns:p=&amp;quot;http://www.springframework.org/schema/p&amp;quot;&lt;br /&gt;
    xsi:schemaLocation=&amp;quot;http://www.springframework.org/schema/beans&lt;br /&gt;
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&amp;quot;&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
       &amp;lt;bean id=&amp;quot;doctorServiceId &amp;quot; class=&amp;quot;myPackage.DoctorService&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;!-- setter injection using the nested &amp;lt;ref/&amp;gt; element --&amp;gt;&lt;br /&gt;
                  &amp;lt;property name=&amp;quot; prescriptionDAO &amp;quot;&amp;gt;&amp;lt;ref bean=&amp;quot; prescriptionDAOId &amp;quot;/&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
       &amp;lt;/bean&amp;gt;&lt;br /&gt;
       &amp;lt;bean id=&amp;quot; prescriptionDAOId&amp;quot;  class=&amp;quot; myPackage.PrescriptionDAO &amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;prescription&amp;quot; value=&amp;quot;Take medicine regularly.&amp;quot;/&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;dose&amp;quot; value=&amp;quot;3&amp;quot;/&amp;gt;&lt;br /&gt;
       &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, Client is a class that is used to instantiate the Spring Container and retrieve the bean definitions from inside.&lt;br /&gt;
&lt;br /&gt;
 '''''MyClient.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 import java.io;&lt;br /&gt;
 import org.springframework.beans.factory.*;&lt;br /&gt;
 import org.springframework.beans.factory.xml.*;&lt;br /&gt;
 import org.springframework.core.io;&lt;br /&gt;
 public class MyClient&lt;br /&gt;
 {&lt;br /&gt;
        public static void main(String args[])&lt;br /&gt;
        {&lt;br /&gt;
                Resource res=new ClassPathResource(“./myPackage/ ApplicationContext.xml”);&lt;br /&gt;
                BeanFactory factory =new XmlBeanFactory(res); &lt;br /&gt;
                //” doctorServiceId” is the same id defined in ApplicationContext.xml&lt;br /&gt;
                DoctorService doctorService= (DoctorService) factory.getBean(“doctorServiceId”);&lt;br /&gt;
         }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Here, first the path for the ApplicationContext is specified, and then this file is used as a resource by the container. The BeanFactory container uses the xml file to access the bean defined inside the configuration file.&lt;br /&gt;
&lt;br /&gt;
However, Setter Injection unnecessarily adds to the abstraction. The developer needs to know which dependencies are needed when. On the other hand, it can save on modifying a lot of legacy code when introducing new methods, and can provide a performance boost if the dependency is expensive or not easily accessible.&lt;br /&gt;
&lt;br /&gt;
==Type 3- Constructor Injection==&lt;br /&gt;
&lt;br /&gt;
Constructor Injection is the DI technique of passing an object's dependencies to its constructor. It addresses the most common scenario where a class requires one or more Dependencies, and no reasonable local defaults are available.&lt;br /&gt;
&lt;br /&gt;
Constructor Injection addresses this scenario very well, because it guarantees that the Dependency is always present. If the depending class absolutely cannot function without the Dependency, such a guarantee is valuable. Constructor-injection enforces the order of initialization and prevents circular dependencies [http://en.wikipedia.org/wiki/Circular_dependency]. &lt;br /&gt;
On the other hand, with Setter injection, it is not clear, in which order things need to be instantiated. Apart from the guaranteed injection, this pattern is also very easy to implement. &lt;br /&gt;
&lt;br /&gt;
Continuing with the example mentioned above, we can implement the same using constructor injection as follows, &amp;lt;br&amp;gt; [[image:di_image3.png]] &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 '''''DoctorService.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class DoctorService&lt;br /&gt;
 {&lt;br /&gt;
         private PrescriptionDAO prescriptionDAO;&lt;br /&gt;
         // constructor for instantiatng prescriptionDAO&lt;br /&gt;
         public DoctorService (prescriptionDAO)&lt;br /&gt;
         { &lt;br /&gt;
            this.prescriptionDAO = prescriptionDAO; &lt;br /&gt;
         }&lt;br /&gt;
         //business logic that actually uses prescriptionDAOto access its variables and methods.&lt;br /&gt;
          public void print()&lt;br /&gt;
          {	&lt;br /&gt;
               System.out.println(&amp;quot;prescription:&amp;quot; +prescriptionDAO.prescription);&lt;br /&gt;
               System.out.println(&amp;quot;dose: &amp;quot;+prescriptionDAO.dose); &lt;br /&gt;
          }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
In the example, you must have noticed the parametrized constructor which Spring framework uses to instantiate the value of prescriptionDAO. &lt;br /&gt;
Now, the question is- how Spring container will come to know whether it has to use Constructor injection or Setter Injection? Tags inside the &amp;lt;bean&amp;gt; tag will specify this:&lt;br /&gt;
* &amp;lt;property&amp;gt; tag   is used for Setter Injection&lt;br /&gt;
* &amp;lt;constructor-arg&amp;gt; is used for Constructor Injection.&lt;br /&gt;
&lt;br /&gt;
ApplicationContect.xml for Constructor injection will be:&lt;br /&gt;
 '''''ApplicationContect.xml'''''&lt;br /&gt;
 &amp;lt;beans xmlns=&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;br /&gt;
    xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;br /&gt;
    xmlns:p=&amp;quot;http://www.springframework.org/schema/p&amp;quot;&lt;br /&gt;
    xsi:schemaLocation=&amp;quot;http://www.springframework.org/schema/beans&lt;br /&gt;
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;bean id=&amp;quot;doctorServiceId &amp;quot; class=&amp;quot;myPackage.DoctorService&amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;lt;!-- constructor injection using the nested &amp;lt;ref/&amp;gt; element --&amp;gt;&lt;br /&gt;
 		 &amp;lt;constructor-arg&amp;gt;&lt;br /&gt;
                 &amp;lt;ref bean=&amp;quot; prescriptionDAOId &amp;quot;/&amp;gt;&lt;br /&gt;
                 &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;
          &amp;lt;/bean&amp;gt;&lt;br /&gt;
          &amp;lt;bean id=&amp;quot; prescriptionDAOId&amp;quot;  class=&amp;quot; myPackage.PrescriptionDAO &amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;prescription&amp;quot; value=&amp;quot;Take medicine regularly.&amp;quot;/&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;dose&amp;quot; value=&amp;quot;3&amp;quot;/&amp;gt;&lt;br /&gt;
          &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Definitions for PrescriptionDAO.java and MyClient.java will remain the same.&lt;br /&gt;
The advantage of using Constructor Injection is that it can create the objects at the time of instantiation itself. Hence it guarantees the developer, that the objects will definitely get created and no exception will be raised. &lt;br /&gt;
&lt;br /&gt;
However, unlike [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch5_5e_dr#Type_2-_Setter_Injection Setter injection] it won’t allow changes to the dependency, once it is created.&lt;br /&gt;
&lt;br /&gt;
=Advantages and Disadvantages=&lt;br /&gt;
&lt;br /&gt;
Advantage of using Dependency injection are &lt;br /&gt;
* Clean code which helps to separate out the logic and the instantiation modules. &lt;br /&gt;
* It is also easy to maintain the code with the use of configuration files where we can make changes in future whenever required. &lt;br /&gt;
* It is very easy to test the code using Dependency Injection.&lt;br /&gt;
* It makes the code more readable.&lt;br /&gt;
&lt;br /&gt;
But the down side of Dependency Injection are that, &lt;br /&gt;
* It is not quite easy to understand the code for developers as there seems to be an abstraction layer which is performing initializing and instantiation of objects. &lt;br /&gt;
* Moreover, developers should have an expertise in coding such design patterns.&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
Hence, Dependency Injection design pattern is good enough to implement in the enterprise applications of large scale, as it helps in reusability, maintainability and testing.&lt;br /&gt;
&lt;br /&gt;
= References and Notes =&lt;br /&gt;
[1] [Spring in Action by Craig Walls, Ryan Briedenbach]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [Java Development with Spring Framework,  by Rod Johnson, Juergen Hoeller, Alef Arendsen, Thomas Risberg, Colin Sampaleanu]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://www.springsource.org/ Spring Framework]&amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://www.opensymphony.com/xwork/ Xwork]&amp;lt;br&amp;gt;&lt;br /&gt;
[5] [http://static.springsource.org/spring/docs/2.5.x/reference/aop.html Aspect Oriented Programming]&amp;lt;br&amp;gt;&lt;br /&gt;
[6] [http://en.wikipedia.org/wiki/Circular_dependency Circular Dependency]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
[1] [http://www.codeproject.com/KB/architecture/DependencyInjection.aspx Dependency Injection for Loose Coupling]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [http://www.springframework.net/doc-latest/reference/html/objects.html#objects-factory-collaborators Dependency injection]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://excalibur.apache.org/framework/index.html Excalibur Apache Avalon]&amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://www.picocontainer.org/ PicoContainer]&amp;lt;br&amp;gt;&lt;br /&gt;
[5] [http://hivelogic.com/ Hivelogic]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Further Reading =&lt;br /&gt;
[1] [Dependency Injection in .NET by Mark Seemann]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [Dependency Injection by Dhanji R Prassanna]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://www.developer.com/net/csharp/article.php/3722931/Dependency-Injection-with-SpringNet.htm Dependency Injection with Spring .NET] &amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://needle.rubyforge.org/api/ Dependency Injection in Ruby]&lt;br /&gt;
[5] [http://onestepback.org/index.cgi/Tech/Ruby/DependencyInjectionInRuby.rdoc ]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5e_dr&amp;diff=40021</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5e dr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5e_dr&amp;diff=40021"/>
		<updated>2010-11-03T22:40:56Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Dependency Injection'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
Every enterprise application involves handful number of objects that work together to achieve some purpose. These objects are coupled with each other and work in collaboration, making the classes highly dependent. However, creating such code involving highly coupled classes defeats an important tenet of Object oriented design- ‘loose coupling’. Loose coupling means that objects should have the minimum number of dependencies, which makes the code easy to understand, modify and debug. It also allows for greater code reusability and improves the maintainability.[http://www.codeproject.com/KB/architecture/DependencyInjection.aspx] This drive to decouple the code from its highly dependent objects leads to the concept of Dependency Injection.&lt;br /&gt;
&lt;br /&gt;
= Definition =&lt;br /&gt;
The basic concept of Dependency Injection(DI) is that you do not create the objects themselves, but describe how they should be created. It is one of the more popular design paradigms known today, by which the objects define their dependencies, i.e. the objects or classes they work with. DI pattern provides better a software design that makes the code cleaner, since the object doesn’t need to look for other components it works with, or know their location and class.[http://www.springframework.net/doc-latest/reference/html/objects.html#objects-factory-collaborators]&lt;br /&gt;
It facilitates the design of applications, using a framework that links the components, instead of the components linking themselves.  &lt;br /&gt;
&lt;br /&gt;
In other words, Dependency Injection, also known as Inversion Of Control(IoC), transfers the responsibility to locate and create the objects to the framework or the container which supports plug-n-play implementation, by injecting the dependencies into your code.&lt;br /&gt;
&lt;br /&gt;
= Features of Dependency Injection =&lt;br /&gt;
Main features of Dependency Injection Framework are:&lt;br /&gt;
* Better Design Pattern - Supports good Object-Oriented Design.&lt;br /&gt;
* Clean Code- Eliminates the need of looking up code from the application.&lt;br /&gt;
* Reuse - Promotes better code reusability.&lt;br /&gt;
* Loose Coupling- Objects are loosely coupled using DI&lt;br /&gt;
* Simple- It is very simple to implement, just need to inject the dependencies of any object.&lt;br /&gt;
* Maintainable- It is very easy to reconfigure and maintain in case of any future changes.&lt;br /&gt;
* More Testable- It makes it very easy to test the code, as objects get instantiated with values using configuration files.&lt;br /&gt;
&lt;br /&gt;
= Dependency Injection Frameworks =&lt;br /&gt;
Dependency Injection requires a framework that helps the developer to declare the dependencies, to locate, instantiate, and initialize the components or the objects. A developer has many available frameworks to him:&lt;br /&gt;
* '''Spring Framework''' – A light weight container, most widely used for DI and very large framework, which includes a lot many other features like Aspect Oriented, framework, container, etc. along with Dependency Injection.[http://www.springsource.org/]&lt;br /&gt;
* '''XWork''' -  It is a standalone framework and mostly works in conjunction with Webworks. It is a highly effective command pattern framework that provides a lot of features for DI.[http://www.opensymphony.com/xwork/]&lt;br /&gt;
* '''Apache Avalon'''- This is also a container framework which supports the dependency injection design pattern. This frameworks is now divided into sub-frameworks.[http://excalibur.apache.org/framework/index.html]&lt;br /&gt;
* '''PicoContainer''' - It is a highly focused DI framework available.[http://www.picocontainer.org/]&lt;br /&gt;
* '''Hivelogic''' – Another DI framework to inject dependencies.[http://hivelogic.com/]&lt;br /&gt;
&lt;br /&gt;
== Example of Dependency Injection Framework ==&lt;br /&gt;
&lt;br /&gt;
Let us consider a simple example to understand the basic idea of DI.&lt;br /&gt;
Suppose we have an Employee class which depends on the Department object. We need some Assembler (DI Framework) to instantiate the Department field of Employee class. Rather than Employee class creating this object for itself, it will delegate this task of instantiation to any framework selected from above. To do this, it uses configuration files, which are mostly .xml files. We will see comprehensive example using the framework in the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch5_5e_dr#Types_of_Dependency_Injection section 4]. &lt;br /&gt;
&lt;br /&gt;
 '''''Employee.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class Employee&lt;br /&gt;
  {&lt;br /&gt;
         //dependent object ‘dept'&lt;br /&gt;
         private Department dept;&lt;br /&gt;
         public void Employee( ){ }  &lt;br /&gt;
         &lt;br /&gt;
         setDepartment(dept){&lt;br /&gt;
             this.dept=dept;&lt;br /&gt;
         }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
 '''''Department.java'''''&lt;br /&gt;
  package myPackage;&lt;br /&gt;
  public class Department&lt;br /&gt;
   {&lt;br /&gt;
      private String name; &lt;br /&gt;
      public String getName(){&lt;br /&gt;
          return name;&lt;br /&gt;
       }&lt;br /&gt;
      public void setName(String name){&lt;br /&gt;
          this.name=name;&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
The framework will instantiate the Department object by looking into the configuration file for any existing dependencies of Employee object. It will form an Employee object with a Department instance. For example, in Spring Framework, the configuration file will be ApplicationContext.xml, where the binding of beans is done as follows:&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationContext.xml'''''&lt;br /&gt;
 &amp;lt;beans&amp;gt;&lt;br /&gt;
      &amp;lt;bean id=&amp;quot;employee&amp;quot; class=&amp;quot; myPackage .Employee.java&amp;quot;&amp;gt;&lt;br /&gt;
     	   &amp;lt;property name=&amp;quot;name &amp;quot; ref=&amp;quot;yetAnotherBean&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/bean&amp;gt;&lt;br /&gt;
      &amp;lt;bean id=&amp;quot;department&amp;quot; class=&amp;quot; myPackage .Department.java&amp;quot;&amp;gt;     	&lt;br /&gt;
  	   &amp;lt;property name=&amp;quot;name&amp;quot; value=&amp;quot;Java&amp;quot;/&amp;gt;      &lt;br /&gt;
      &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
thereby creating the dependency diagram as: &amp;lt;br&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
[[Image:Di_image1.png]]&lt;br /&gt;
&lt;br /&gt;
Here we can see that, the classes themselves do not create their own instances, but it is the framework that does this job for them, making the code cleaner, reusable and loosely coupled. In future if one wants to add on, delete or modify any of the dependent objects, one only needs to update the configuration file. There is no need to look up the code all over again to find the class’s dependent objects. One can make modifications to the lines of code creating instances, which may be,&lt;br /&gt;
		&lt;br /&gt;
  // used everywhere in code without Dependency Injection.&lt;br /&gt;
  Department dept=new Department ();  &lt;br /&gt;
&lt;br /&gt;
Thus it makes our code configurable and maintainable. &lt;br /&gt;
Let us now move on and see some more examples to understand the different types of injections available within different frameworks.&lt;br /&gt;
&lt;br /&gt;
= Types of Dependency Injection =&lt;br /&gt;
&lt;br /&gt;
There are a number of Dependency Injection variants that exists to allow the developer to implement and write loosely coupled code. The dependencies can be injected in various forms like: &lt;br /&gt;
* Type 1- Interface Injection&lt;br /&gt;
* Type 2- Setter Injection&lt;br /&gt;
* Type 3- Constructor Injection&lt;br /&gt;
&lt;br /&gt;
== Type 1- Interface Injection ==&lt;br /&gt;
&lt;br /&gt;
Interface injection is a technique to add the dependency for interfaces in components at run time. The components implement these interfaces based on the injected dependency. Spring framework does not support interface injection, so let us see this injection by using the Avalon framework.&lt;br /&gt;
&lt;br /&gt;
For example, we have an ApplicationDAO interface, while AccountApplicationDAO and  CustomerApplicationDAO are the classes implementing ApplicationDAO, &lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public interface ApplicationDAO&lt;br /&gt;
   {&lt;br /&gt;
       void getEntity();&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
 '''''AccountApplicationDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class AccountApplicationDAO implements ApplicationDAO&lt;br /&gt;
 {&lt;br /&gt;
        void getEntity(){&lt;br /&gt;
             //get all accounts.&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
 '''''CustomerApplicationDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class CustomerApplicationDAO implements ApplicationDAO&lt;br /&gt;
 {&lt;br /&gt;
        void getEntity()&lt;br /&gt;
        {&lt;br /&gt;
               //get all customers.&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We also have ApplicationService interface, which depends on the ApplicationDAO interface. The ApplicationServiceImpl class implements the ApplicationService inteface, which in turn implements the ApplicationDAO interface, provided by the container.&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationService.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public interface ApplicationService&lt;br /&gt;
 {&lt;br /&gt;
       getEntity(ApplicationDAO applicationDAO);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationServiceImpl.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class ApplicationServiceImpl implements ApplicationService &lt;br /&gt;
  {&lt;br /&gt;
        ApplicationDAO applicationDAO;&lt;br /&gt;
        validateEntity (ApplicationDAO applicationDAO)&lt;br /&gt;
         {&lt;br /&gt;
                this. applicationDAO= applicationDAO;&lt;br /&gt;
                applicationDAO.getEntity();&lt;br /&gt;
                //code to validate the Entity (Account/Customer),as per the configuration in xml file.&lt;br /&gt;
          }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
Now, our main program will get the interface dependency from the container, which uses configuration file for look up, &lt;br /&gt;
&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class MyClass&lt;br /&gt;
 {&lt;br /&gt;
        public static void main(string[] args)&lt;br /&gt;
        {&lt;br /&gt;
            // Get the correct dependency based on configuration file&lt;br /&gt;
            ApplicationDAO dependencyDAO = getDependecny();&lt;br /&gt;
 &lt;br /&gt;
            // Create our applicationServiceImpl class and inject the dependency&lt;br /&gt;
 	    ApplicationServiceImpl applicationServiceImpl = new ApplicationServiceImpl();&lt;br /&gt;
            // call validateEntity()&lt;br /&gt;
            ((ApplicationService)applicationServiceImpl).validateEntity(dependencyDAO);&lt;br /&gt;
 &lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        public static ApplicationDAO getDependency()&lt;br /&gt;
        {&lt;br /&gt;
            string implementClass =  &lt;br /&gt;
                                    System.Configuration.ConfigurationManager.AppSettings[&amp;quot;selectedClass&amp;quot;];&lt;br /&gt;
            Type type = System.Type.GetType(implementClass);&lt;br /&gt;
            ApplicationDAO applicationDAO = (ApplicationDAO)Activator.CreateInstance(type);&lt;br /&gt;
             &lt;br /&gt;
            return applicationDAO;&lt;br /&gt;
        }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
The Configuration File that will be used by MyClass file to lookup the dependency configurations will be of type:&lt;br /&gt;
&lt;br /&gt;
 '''''App.Config'''''&lt;br /&gt;
 &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
 &amp;lt;configuration&amp;gt;&lt;br /&gt;
      &amp;lt;appSettings&amp;gt;&lt;br /&gt;
            &amp;lt;add key=&amp;quot; selectedClass &amp;quot; value=&amp;quot;myPackage. AccountApplicationDAO &amp;quot; /&amp;gt;&lt;br /&gt;
       &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
 &amp;lt;/configuration&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
In this example, validateEntity() in ApplicationServiceImpl will call getEntity() using  &lt;br /&gt;
ApplicationDAO reference. The getEntity() that is invoked will actually depend on the dependency that is injected via the configuration file.&lt;br /&gt;
&lt;br /&gt;
==Type 2- Setter Injection==&lt;br /&gt;
&lt;br /&gt;
Dependency can be injected using the setter method of a class. If a class is dependent on another class or object instances, then the dependency should be declared as a state(variable) of the class and the class should have a setter method for it. The dependencies are set onto public attributes of the object in need. One of the primary motive for using setters, is supporting dependency injection without having to modify the constructor of a legacy class. Another use is to allow the creation of expensive resources or services as late as possible and only when needed, which is an edge over the Constructor Injection, which we will see in few moments.&lt;br /&gt;
&lt;br /&gt;
Let us consider an example of Setter injection by using Spring Framework.[3] Before using Spring, let us study some basic features of Spring. We will cover only a brief overview of the Spring Framework. &lt;br /&gt;
&lt;br /&gt;
* Spring is a lightweight container which along with supporting features like Dependency Injection, also include other ones as:  Container, Framework, AOP[http://static.springsource.org/spring/docs/2.5.x/reference/aop.html], MVC, etc. &lt;br /&gt;
* Spring Framework supports both Setter Injection and Constructor Injection, but not Interface Injection. Spring jars that can be included are : &lt;br /&gt;
** spring-beans.jar&lt;br /&gt;
** spring-core.jar&lt;br /&gt;
* Packages that provide Spring Frameworks’s IoC container are:&lt;br /&gt;
** org.springframeworks.beans&lt;br /&gt;
** org.springframeworks.context&lt;br /&gt;
&lt;br /&gt;
Now let us see Setter injection using the Spring framework.&lt;br /&gt;
The example below includes a class, DoctorService. The DoctorService class needs a data-access object for communicating with the database. Assume, the PrescriptionDAO (&amp;quot;order data-access object&amp;quot;) is the class on which DoctorService depends. &amp;lt;br&amp;gt;[[image:di_image2.png]] &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 '''''DoctorService.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class DoctorService&lt;br /&gt;
 {&lt;br /&gt;
       private PrescriptionDAO prescriptionDAO;&lt;br /&gt;
       //empty constructor&lt;br /&gt;
       public DoctorService () {}&lt;br /&gt;
       public PrescriptionDAO getPrescriptionDAO() &lt;br /&gt;
       { &lt;br /&gt;
              return this.prescriptionDAO;&lt;br /&gt;
       }&lt;br /&gt;
       //setter for prescriptionDAO&lt;br /&gt;
       public setPrescriptionDAO(prescriptionDAO) &lt;br /&gt;
       { &lt;br /&gt;
              this.prescriptionDAO = prescriptionDAO; &lt;br /&gt;
       }&lt;br /&gt;
       //business logic that actually uses prescriptionDAOto access its variables and methods.&lt;br /&gt;
       public void print()&lt;br /&gt;
       {&lt;br /&gt;
              System.out.println(“prescription: “+prescriptionDAO.prescription);&lt;br /&gt;
              System.out.println(“dose: “+prescriptionDAO.dose);&lt;br /&gt;
       }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
 '''''PrescriptionDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class PrescriptionDAO&lt;br /&gt;
 {&lt;br /&gt;
        private String prescription;&lt;br /&gt;
        private int dose;&lt;br /&gt;
        public PrescriptionDAO(){}&lt;br /&gt;
        public String getPrescription () &lt;br /&gt;
        {&lt;br /&gt;
                return  this.prescription;&lt;br /&gt;
        }&lt;br /&gt;
        public void setPrescription(String prescription) &lt;br /&gt;
        {&lt;br /&gt;
           this. prescription = prescription;&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Here, the invoking object is responsible for setting the PrescriptionDAO dependency. There is no code inside the class that is creating new instance of PrescriptionDAO. This is because this task will be performed by the Spring container, by looking for dependencies of DoctorService inside applicationContext.xml file.&lt;br /&gt;
&lt;br /&gt;
The Spring framework uses a setter method to create this dependent object. Note the &amp;lt;property&amp;gt; tag which is used inside ApplicationContext.xml file for setter injection. &lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationContext.xml'''''&lt;br /&gt;
 &amp;lt;beans xmlns=&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;br /&gt;
    xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;br /&gt;
    xmlns:p=&amp;quot;http://www.springframework.org/schema/p&amp;quot;&lt;br /&gt;
    xsi:schemaLocation=&amp;quot;http://www.springframework.org/schema/beans&lt;br /&gt;
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&amp;quot;&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
       &amp;lt;bean id=&amp;quot;doctorServiceId &amp;quot; class=&amp;quot;myPackage.DoctorService&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;!-- setter injection using the nested &amp;lt;ref/&amp;gt; element --&amp;gt;&lt;br /&gt;
                  &amp;lt;property name=&amp;quot; prescriptionDAO &amp;quot;&amp;gt;&amp;lt;ref bean=&amp;quot; prescriptionDAOId &amp;quot;/&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
       &amp;lt;/bean&amp;gt;&lt;br /&gt;
       &amp;lt;bean id=&amp;quot; prescriptionDAOId&amp;quot;  class=&amp;quot; myPackage.PrescriptionDAO &amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;prescription&amp;quot; value=&amp;quot;Take medicine regularly.&amp;quot;/&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;dose&amp;quot; value=&amp;quot;3&amp;quot;/&amp;gt;&lt;br /&gt;
       &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, Client is a class that is used to instantiate the Spring Container and retrieve the bean definitions from inside.&lt;br /&gt;
&lt;br /&gt;
 '''''MyClient.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 import java.io;&lt;br /&gt;
 import org.springframework.beans.factory.*;&lt;br /&gt;
 import org.springframework.beans.factory.xml.*;&lt;br /&gt;
 import org.springframework.core.io;&lt;br /&gt;
 public class MyClient&lt;br /&gt;
 {&lt;br /&gt;
        public static void main(String args[])&lt;br /&gt;
        {&lt;br /&gt;
                Resource res=new ClassPathResource(“./myPackage/ ApplicationContext.xml”);&lt;br /&gt;
                BeanFactory factory =new XmlBeanFactory(res); &lt;br /&gt;
                //” doctorServiceId” is the same id defined in ApplicationContext.xml&lt;br /&gt;
                DoctorService doctorService= (DoctorService) factory.getBean(“doctorServiceId”);&lt;br /&gt;
         }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Here, first the path for the ApplicationContext is specified, and then this file is used as a resource by the container. The BeanFactory container uses the xml file to access the bean defined inside the configuration file.&lt;br /&gt;
&lt;br /&gt;
However, Setter Injection unnecessarily adds to the abstraction. The developer needs to know which dependencies are needed when. On the other hand, it can save on modifying a lot of legacy code when introducing new methods, and can provide a performance boost if the dependency is expensive or not easily accessible.&lt;br /&gt;
&lt;br /&gt;
==Type 3- Constructor Injection==&lt;br /&gt;
&lt;br /&gt;
Constructor Injection is the DI technique of passing an object's dependencies to its constructor. It addresses the most common scenario where a class requires one or more Dependencies, and no reasonable local defaults are available.&lt;br /&gt;
&lt;br /&gt;
Constructor Injection addresses this scenario very well, because it guarantees that the Dependency is always present. If the depending class absolutely cannot function without the Dependency, such a guarantee is valuable. Constructor-injection enforces the order of initialization and prevents circular dependencies [http://en.wikipedia.org/wiki/Circular_dependency]. &lt;br /&gt;
On the other hand, with Setter injection, it is not clear, in which order things need to be instantiated. Apart from the guaranteed injection, this pattern is also very easy to implement. &lt;br /&gt;
&lt;br /&gt;
Continuing with the example mentioned above, we can implement the same using constructor injection as follows, &amp;lt;br&amp;gt; [[image:di_image3.png]] &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 '''''DoctorService.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class DoctorService&lt;br /&gt;
 {&lt;br /&gt;
         private PrescriptionDAO prescriptionDAO;&lt;br /&gt;
         // constructor for instantiatng prescriptionDAO&lt;br /&gt;
         public DoctorService (prescriptionDAO)&lt;br /&gt;
         { &lt;br /&gt;
            this.prescriptionDAO = prescriptionDAO; &lt;br /&gt;
         }&lt;br /&gt;
         //business logic that actually uses prescriptionDAOto access its variables and methods.&lt;br /&gt;
          public void print()&lt;br /&gt;
          {	&lt;br /&gt;
               System.out.println(&amp;quot;prescription:&amp;quot; +prescriptionDAO.prescription);&lt;br /&gt;
               System.out.println(&amp;quot;dose: &amp;quot;+prescriptionDAO.dose); &lt;br /&gt;
          }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
In the example, you must have noticed the parametrized constructor which Spring framework uses to instantiate the value of prescriptionDAO. &lt;br /&gt;
Now, the question is- how Spring container will come to know whether it has to use Constructor injection or Setter Injection? Tags inside the &amp;lt;bean&amp;gt; tag will specify this:&lt;br /&gt;
* &amp;lt;property&amp;gt; tag   is used for Setter Injection&lt;br /&gt;
* &amp;lt;constructor-arg&amp;gt; is used for Constructor Injection.&lt;br /&gt;
&lt;br /&gt;
ApplicationContect.xml for Constructor injection will be:&lt;br /&gt;
 '''''ApplicationContect.xml'''''&lt;br /&gt;
 &amp;lt;beans xmlns=&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;br /&gt;
    xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;br /&gt;
    xmlns:p=&amp;quot;http://www.springframework.org/schema/p&amp;quot;&lt;br /&gt;
    xsi:schemaLocation=&amp;quot;http://www.springframework.org/schema/beans&lt;br /&gt;
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;bean id=&amp;quot;doctorServiceId &amp;quot; class=&amp;quot;myPackage.DoctorService&amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;lt;!-- constructor injection using the nested &amp;lt;ref/&amp;gt; element --&amp;gt;&lt;br /&gt;
 		 &amp;lt;constructor-arg&amp;gt;&lt;br /&gt;
                 &amp;lt;ref bean=&amp;quot; prescriptionDAOId &amp;quot;/&amp;gt;&lt;br /&gt;
                 &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;
          &amp;lt;/bean&amp;gt;&lt;br /&gt;
          &amp;lt;bean id=&amp;quot; prescriptionDAOId&amp;quot;  class=&amp;quot; myPackage.PrescriptionDAO &amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;prescription&amp;quot; value=&amp;quot;Take medicine regularly.&amp;quot;/&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;dose&amp;quot; value=&amp;quot;3&amp;quot;/&amp;gt;&lt;br /&gt;
          &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Definitions for PrescriptionDAO.java and MyClient.java will remain the same.&lt;br /&gt;
The advantage of using Constructor Injection is that it can create the objects at the time of instantiation itself. Hence it guarantees the developer, that the objects will definitely get created and no exception will be raised. &lt;br /&gt;
&lt;br /&gt;
However, unlike [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch5_5e_dr#Type_2-_Setter_Injection Setter injection] it won’t allow changes to the dependency, once it is created.&lt;br /&gt;
&lt;br /&gt;
=Advantages and Disadvantages=&lt;br /&gt;
&lt;br /&gt;
Advantage of using Dependency injection are &lt;br /&gt;
* Clean code which helps to separate out the logic and the instantiation modules. &lt;br /&gt;
* It is also easy to maintain the code with the use of configuration files where we can make changes in future whenever required. &lt;br /&gt;
* It is very easy to test the code using Dependency Injection.&lt;br /&gt;
* It makes the code more readable.&lt;br /&gt;
&lt;br /&gt;
But the down side of Dependency Injection are that, &lt;br /&gt;
* It is not quite easy to understand the code for developers as there seems to be an abstraction layer which is performing initializing and instantiation of objects. &lt;br /&gt;
* Moreover, developers should have an expertise in coding such design patterns.&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
Hence, Dependency Injection design pattern is good enough to implement in the enterprise applications of large scale, as it helps in reusability, maintainability and testing.&lt;br /&gt;
&lt;br /&gt;
= References and Notes =&lt;br /&gt;
[1] [Spring in Action by Craig Walls, Ryan Briedenbach]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [Java Development with Spring Framework,  by Rod Johnson, Juergen Hoeller, Alef Arendsen, Thomas Risberg, Colin Sampaleanu]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://www.springsource.org/ Spring Framework]&amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://www.opensymphony.com/xwork/ Xwork]&amp;lt;br&amp;gt;&lt;br /&gt;
[8] [http://static.springsource.org/spring/docs/2.5.x/reference/aop.html Aspect Oriented Programming]&amp;lt;br&amp;gt;&lt;br /&gt;
[9] [http://en.wikipedia.org/wiki/Circular_dependency Circular Dependency]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=External Links=&lt;br /&gt;
[1] [http://www.codeproject.com/KB/architecture/DependencyInjection.aspx Dependency Injection for Loose Coupling]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [http://www.springframework.net/doc-latest/reference/html/objects.html#objects-factory-collaborators Dependency injection]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://excalibur.apache.org/framework/index.html Excalibur Apache Avalon]&amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://www.picocontainer.org/ PicoContainer]&amp;lt;br&amp;gt;&lt;br /&gt;
[5] [http://hivelogic.com/ Hivelogic]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Further Reading =&lt;br /&gt;
[1] [Dependency Injection in .NET by Mark Seemann]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [Dependency Injection by Dhanji R Prassanna]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://www.developer.com/net/csharp/article.php/3722931/Dependency-Injection-with-SpringNet.htm Dependency Injection with Spring .NET] &amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://needle.rubyforge.org/api/ Dependency Injection in Ruby]&lt;br /&gt;
[5] [http://onestepback.org/index.cgi/Tech/Ruby/DependencyInjectionInRuby.rdoc ]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5e_dr&amp;diff=40015</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5e dr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5e_dr&amp;diff=40015"/>
		<updated>2010-11-03T22:18:46Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Dependency Injection'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
Every enterprise application involves handful number of objects that work together to achieve some purpose. These objects are coupled with each other and work in collaboration, making the classes highly dependent. However, creating such code involving highly coupled classes defeats an important tenet of Object oriented design- ‘loose coupling’. Loose coupling means that objects should have the minimum number of dependencies, which makes the code easy to understand, modify and debug. It also allows for greater code reusability and improves the maintainability.[http://www.codeproject.com/KB/architecture/DependencyInjection.aspx] This drive to decouple the code from its highly dependent objects leads to the concept of Dependency Injection.&lt;br /&gt;
&lt;br /&gt;
= Definition =&lt;br /&gt;
The basic concept of Dependency Injection(DI) is that you do not create the objects themselves, but describe how they should be created. It is one of the more popular design paradigms known today, by which the objects define their dependencies, i.e. the objects or classes they work with. DI pattern provides better a software design that makes the code cleaner, since the object doesn’t need to look for other components it works with, or know their location and class.[http://www.springframework.net/doc-latest/reference/html/objects.html#objects-factory-collaborators]&lt;br /&gt;
It facilitates the design of applications, using a framework that links the components, instead of the components linking themselves.  &lt;br /&gt;
&lt;br /&gt;
In other words, Dependency Injection, also known as Inversion Of Control(IoC), transfers the responsibility to locate and create the objects to the framework or the container which supports plug-n-play implementation, by injecting the dependencies into your code.&lt;br /&gt;
&lt;br /&gt;
= Features of Dependency Injection =&lt;br /&gt;
Main features of Dependency Injection Framework are:&lt;br /&gt;
* Better Design Pattern - Supports good Object-Oriented Design.&lt;br /&gt;
* Clean Code- Eliminates the need of looking up code from the application.&lt;br /&gt;
* Reuse - Promotes better code reusability.&lt;br /&gt;
* Loose Coupling- Objects are loosely coupled using DI&lt;br /&gt;
* Simple- It is very simple to implement, just need to inject the dependencies of any object.&lt;br /&gt;
* Maintainable- It is very easy to reconfigure and maintain in case of any future changes.&lt;br /&gt;
* More Testable- It makes it very easy to test the code, as objects get instantiated with values using configuration files.&lt;br /&gt;
&lt;br /&gt;
= Dependency Injection Frameworks =&lt;br /&gt;
Dependency Injection requires a framework that helps the developer to declare the dependencies, to locate, instantiate, and initialize the components or the objects. A developer has many available frameworks to him:&lt;br /&gt;
* '''Spring Framework''' – A light weight container, most widely used for DI and very large framework, which includes a lot many other features like Aspect Oriented, framework, container, etc. along with Dependency Injection.[http://www.springsource.org/]&lt;br /&gt;
* '''XWork''' -  It is a standalone framework and mostly works in conjunction with Webworks. It is a highly effective command pattern framework that provides a lot of features for DI.[http://www.opensymphony.com/xwork/]&lt;br /&gt;
* '''Apache Avalon'''- This is also a container framework which supports the dependency injection design pattern. This frameworks is now divided into sub-frameworks.[http://excalibur.apache.org/framework/index.html]&lt;br /&gt;
* '''PicoContainer''' - It is a highly focused DI framework available.[http://www.picocontainer.org/]&lt;br /&gt;
* '''Hivelogic''' – Another DI framework to inject dependencies.[http://hivelogic.com/]&lt;br /&gt;
&lt;br /&gt;
== Example of Dependency Injection Framework ==&lt;br /&gt;
&lt;br /&gt;
Let us consider a simple example to understand the basic idea of DI.&lt;br /&gt;
Suppose we have an Employee class which depends on the Department object. We need some Assembler (DI Framework) to instantiate the Department field of Employee class. Rather than Employee class creating this object for itself, it will delegate this task of instantiation to any framework selected from above. To do this, it uses configuration files, which are mostly .xml files. We will see comprehensive example using the framework in the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch5_5e_dr#Types_of_Dependency_Injection section 4]. &lt;br /&gt;
&lt;br /&gt;
 '''''Employee.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class Employee&lt;br /&gt;
  {&lt;br /&gt;
         //dependent object ‘dept'&lt;br /&gt;
         private Department dept;&lt;br /&gt;
         public void Employee( ){ }  &lt;br /&gt;
         &lt;br /&gt;
         setDepartment(dept){&lt;br /&gt;
             this.dept=dept;&lt;br /&gt;
         }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
 '''''Department.java'''''&lt;br /&gt;
  package myPackage;&lt;br /&gt;
  public class Department&lt;br /&gt;
   {&lt;br /&gt;
      private String name; &lt;br /&gt;
      public String getName(){&lt;br /&gt;
          return name;&lt;br /&gt;
       }&lt;br /&gt;
      public void setName(String name){&lt;br /&gt;
          this.name=name;&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
The framework will instantiate the Department object by looking into the configuration file for any existing dependencies of Employee object. It will form an Employee object with a Department instance. For example, in Spring Framework, the configuration file will be ApplicationContext.xml, where the binding of beans is done as follows:&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationContext.xml'''''&lt;br /&gt;
 &amp;lt;beans&amp;gt;&lt;br /&gt;
      &amp;lt;bean id=&amp;quot;employee&amp;quot; class=&amp;quot; myPackage .Employee.java&amp;quot;&amp;gt;&lt;br /&gt;
     	   &amp;lt;property name=&amp;quot;name &amp;quot; ref=&amp;quot;yetAnotherBean&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/bean&amp;gt;&lt;br /&gt;
      &amp;lt;bean id=&amp;quot;department&amp;quot; class=&amp;quot; myPackage .Department.java&amp;quot;&amp;gt;     	&lt;br /&gt;
  	   &amp;lt;property name=&amp;quot;name&amp;quot; value=&amp;quot;Java&amp;quot;/&amp;gt;      &lt;br /&gt;
      &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
thereby creating the dependency diagram as: &amp;lt;br&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
[[Image:Di_image1.png]]&lt;br /&gt;
&lt;br /&gt;
Here we can see that, the classes themselves do not create their own instances, but it is the framework that does this job for them, making the code cleaner, reusable and loosely coupled. In future if one wants to add on, delete or modify any of the dependent objects, one only needs to update the configuration file. There is no need to look up the code all over again to find the class’s dependent objects. One can make modifications to the lines of code creating instances, which may be,&lt;br /&gt;
		&lt;br /&gt;
  // used everywhere in code without Dependency Injection.&lt;br /&gt;
  Department dept=new Department ();  &lt;br /&gt;
&lt;br /&gt;
Thus it makes our code configurable and maintainable. &lt;br /&gt;
Let us now move on and see some more examples to understand the different types of injections available within different frameworks.&lt;br /&gt;
&lt;br /&gt;
= Types of Dependency Injection =&lt;br /&gt;
&lt;br /&gt;
There are a number of Dependency Injection variants that exists to allow the developer to implement and write loosely coupled code. The dependencies can be injected in various forms like: &lt;br /&gt;
* Type 1- Interface Injection&lt;br /&gt;
* Type 2- Setter Injection&lt;br /&gt;
* Type 3- Constructor Injection&lt;br /&gt;
&lt;br /&gt;
== Type 1- Interface Injection ==&lt;br /&gt;
&lt;br /&gt;
Interface injection is a technique to add the dependency for interfaces in components at run time. The components implement these interfaces based on the injected dependency. Spring framework does not support interface injection, so let us see this injection by using the Avalon framework.&lt;br /&gt;
&lt;br /&gt;
For example, we have an ApplicationDAO interface, while AccountApplicationDAO and  CustomerApplicationDAO are the classes implementing ApplicationDAO, &lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public interface ApplicationDAO&lt;br /&gt;
   {&lt;br /&gt;
       void getEntity();&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
 '''''AccountApplicationDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class AccountApplicationDAO implements ApplicationDAO&lt;br /&gt;
 {&lt;br /&gt;
        void getEntity(){&lt;br /&gt;
             //get all accounts.&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
 '''''CustomerApplicationDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class CustomerApplicationDAO implements ApplicationDAO&lt;br /&gt;
 {&lt;br /&gt;
        void getEntity()&lt;br /&gt;
        {&lt;br /&gt;
               //get all customers.&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We also have ApplicationService interface, which depends on the ApplicationDAO interface. The ApplicationServiceImpl class implements the ApplicationService inteface, which in turn implements the ApplicationDAO interface, provided by the container.&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationService.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public interface ApplicationService&lt;br /&gt;
 {&lt;br /&gt;
       getEntity(ApplicationDAO applicationDAO);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationServiceImpl.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class ApplicationServiceImpl implements ApplicationService &lt;br /&gt;
  {&lt;br /&gt;
        ApplicationDAO applicationDAO;&lt;br /&gt;
        validateEntity (ApplicationDAO applicationDAO)&lt;br /&gt;
         {&lt;br /&gt;
                this. applicationDAO= applicationDAO;&lt;br /&gt;
                applicationDAO.getEntity();&lt;br /&gt;
                //code to validate the Entity (Account/Customer),as per the configuration in xml file.&lt;br /&gt;
          }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
Now, our main program will get the interface dependency from the container, which uses configuration file for look up, &lt;br /&gt;
&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class MyClass&lt;br /&gt;
 {&lt;br /&gt;
        public static void main(string[] args)&lt;br /&gt;
        {&lt;br /&gt;
            // Get the correct dependency based on configuration file&lt;br /&gt;
            ApplicationDAO dependencyDAO = getDependecny();&lt;br /&gt;
 &lt;br /&gt;
            // Create our applicationServiceImpl class and inject the dependency&lt;br /&gt;
 	    ApplicationServiceImpl applicationServiceImpl = new ApplicationServiceImpl();&lt;br /&gt;
            // call validateEntity()&lt;br /&gt;
            ((ApplicationService)applicationServiceImpl).validateEntity(dependencyDAO);&lt;br /&gt;
 &lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        public static ApplicationDAO getDependency()&lt;br /&gt;
        {&lt;br /&gt;
            string implementClass =  &lt;br /&gt;
                                    System.Configuration.ConfigurationManager.AppSettings[&amp;quot;selectedClass&amp;quot;];&lt;br /&gt;
            Type type = System.Type.GetType(implementClass);&lt;br /&gt;
            ApplicationDAO applicationDAO = (ApplicationDAO)Activator.CreateInstance(type);&lt;br /&gt;
             &lt;br /&gt;
            return applicationDAO;&lt;br /&gt;
        }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
The Configuration File that will be used by MyClass file to lookup the dependency configurations will be of type:&lt;br /&gt;
&lt;br /&gt;
 '''''App.Config'''''&lt;br /&gt;
 &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
 &amp;lt;configuration&amp;gt;&lt;br /&gt;
      &amp;lt;appSettings&amp;gt;&lt;br /&gt;
            &amp;lt;add key=&amp;quot; selectedClass &amp;quot; value=&amp;quot;myPackage. AccountApplicationDAO &amp;quot; /&amp;gt;&lt;br /&gt;
       &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
 &amp;lt;/configuration&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
In this example, validateEntity() in ApplicationServiceImpl will call getEntity() using  &lt;br /&gt;
ApplicationDAO reference. The getEntity() that is invoked will actually depend on the dependency that is injected via the configuration file.&lt;br /&gt;
&lt;br /&gt;
==Type 2- Setter Injection==&lt;br /&gt;
&lt;br /&gt;
Dependency can be injected using the setter method of a class. If a class is dependent on another class or object instances, then the dependency should be declared as a state(variable) of the class and the class should have a setter method for it. The dependencies are set onto public attributes of the object in need. One of the primary motive for using setters, is supporting dependency injection without having to modify the constructor of a legacy class. Another use is to allow the creation of expensive resources or services as late as possible and only when needed, which is an edge over the Constructor Injection, which we will see in few moments.&lt;br /&gt;
&lt;br /&gt;
Let us consider an example of Setter injection by using Spring Framework.[3] Before using Spring, let us study some basic features of Spring. We will cover only a brief overview of the Spring Framework. &lt;br /&gt;
&lt;br /&gt;
* Spring is a lightweight container which along with supporting features like Dependency Injection, also include other ones as:  Container, Framework, AOP[http://static.springsource.org/spring/docs/2.5.x/reference/aop.html], MVC, etc. &lt;br /&gt;
* Spring Framework supports both Setter Injection and Constructor Injection, but not Interface Injection. Spring jars that can be included are : &lt;br /&gt;
** spring-beans.jar&lt;br /&gt;
** spring-core.jar&lt;br /&gt;
* Packages that provide Spring Frameworks’s IoC container are:&lt;br /&gt;
** org.springframeworks.beans&lt;br /&gt;
** org.springframeworks.context&lt;br /&gt;
&lt;br /&gt;
Now let us see Setter injection using the Spring framework.&lt;br /&gt;
The example below includes a class, DoctorService. The DoctorService class needs a data-access object for communicating with the database. Assume, the PrescriptionDAO (&amp;quot;order data-access object&amp;quot;) is the class on which DoctorService depends. &amp;lt;br&amp;gt;[[image:di_image2.png]] &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 '''''DoctorService.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class DoctorService&lt;br /&gt;
 {&lt;br /&gt;
       private PrescriptionDAO prescriptionDAO;&lt;br /&gt;
       //empty constructor&lt;br /&gt;
       public DoctorService () {}&lt;br /&gt;
       public PrescriptionDAO getPrescriptionDAO() &lt;br /&gt;
       { &lt;br /&gt;
              return this.prescriptionDAO;&lt;br /&gt;
       }&lt;br /&gt;
       //setter for prescriptionDAO&lt;br /&gt;
       public setPrescriptionDAO(prescriptionDAO) &lt;br /&gt;
       { &lt;br /&gt;
              this.prescriptionDAO = prescriptionDAO; &lt;br /&gt;
       }&lt;br /&gt;
       //business logic that actually uses prescriptionDAOto access its variables and methods.&lt;br /&gt;
       public void print()&lt;br /&gt;
       {&lt;br /&gt;
              System.out.println(“prescription: “+prescriptionDAO.prescription);&lt;br /&gt;
              System.out.println(“dose: “+prescriptionDAO.dose);&lt;br /&gt;
       }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
 '''''PrescriptionDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class PrescriptionDAO&lt;br /&gt;
 {&lt;br /&gt;
        private String prescription;&lt;br /&gt;
        private int dose;&lt;br /&gt;
        public PrescriptionDAO(){}&lt;br /&gt;
        public String getPrescription () &lt;br /&gt;
        {&lt;br /&gt;
                return  this.prescription;&lt;br /&gt;
        }&lt;br /&gt;
        public void setPrescription(String prescription) &lt;br /&gt;
        {&lt;br /&gt;
           this. prescription = prescription;&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Here, the invoking object is responsible for setting the PrescriptionDAO dependency. There is no code inside the class that is creating new instance of PrescriptionDAO. This is because this task will be performed by the Spring container, by looking for dependencies of DoctorService inside applicationContext.xml file.&lt;br /&gt;
&lt;br /&gt;
The Spring framework uses a setter method to create this dependent object. Note the &amp;lt;property&amp;gt; tag which is used inside ApplicationContext.xml file for setter injection. &lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationContext.xml'''''&lt;br /&gt;
 &amp;lt;beans xmlns=&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;br /&gt;
    xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;br /&gt;
    xmlns:p=&amp;quot;http://www.springframework.org/schema/p&amp;quot;&lt;br /&gt;
    xsi:schemaLocation=&amp;quot;http://www.springframework.org/schema/beans&lt;br /&gt;
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&amp;quot;&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
       &amp;lt;bean id=&amp;quot;doctorServiceId &amp;quot; class=&amp;quot;myPackage.DoctorService&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;!-- setter injection using the nested &amp;lt;ref/&amp;gt; element --&amp;gt;&lt;br /&gt;
                  &amp;lt;property name=&amp;quot; prescriptionDAO &amp;quot;&amp;gt;&amp;lt;ref bean=&amp;quot; prescriptionDAOId &amp;quot;/&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
       &amp;lt;/bean&amp;gt;&lt;br /&gt;
       &amp;lt;bean id=&amp;quot; prescriptionDAOId&amp;quot;  class=&amp;quot; myPackage.PrescriptionDAO &amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;prescription&amp;quot; value=&amp;quot;Take medicine regularly.&amp;quot;/&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;dose&amp;quot; value=&amp;quot;3&amp;quot;/&amp;gt;&lt;br /&gt;
       &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, Client is a class that is used to instantiate the Spring Container and retrieve the bean definitions from inside.&lt;br /&gt;
&lt;br /&gt;
 '''''MyClient.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 import java.io;&lt;br /&gt;
 import org.springframework.beans.factory.*;&lt;br /&gt;
 import org.springframework.beans.factory.xml.*;&lt;br /&gt;
 import org.springframework.core.io;&lt;br /&gt;
 public class MyClient&lt;br /&gt;
 {&lt;br /&gt;
        public static void main(String args[])&lt;br /&gt;
        {&lt;br /&gt;
                Resource res=new ClassPathResource(“./myPackage/ ApplicationContext.xml”);&lt;br /&gt;
                BeanFactory factory =new XmlBeanFactory(res); &lt;br /&gt;
                //” doctorServiceId” is the same id defined in ApplicationContext.xml&lt;br /&gt;
                DoctorService doctorService= (DoctorService) factory.getBean(“doctorServiceId”);&lt;br /&gt;
         }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Here, first the path for the ApplicationContext is specified, and then this file is used as a resource by the container. The BeanFactory container uses the xml file to access the bean defined inside the configuration file.&lt;br /&gt;
&lt;br /&gt;
However, Setter Injection unnecessarily adds to the abstraction. The developer needs to know which dependencies are needed when. On the other hand, it can save on modifying a lot of legacy code when introducing new methods, and can provide a performance boost if the dependency is expensive or not easily accessible.&lt;br /&gt;
&lt;br /&gt;
==Type 3- Constructor Injection==&lt;br /&gt;
&lt;br /&gt;
Constructor Injection is the DI technique of passing an object's dependencies to its constructor. It addresses the most common scenario where a class requires one or more Dependencies, and no reasonable local defaults are available.&lt;br /&gt;
&lt;br /&gt;
Constructor Injection addresses this scenario very well, because it guarantees that the Dependency is always present. If the depending class absolutely cannot function without the Dependency, such a guarantee is valuable. Constructor-injection enforces the order of initialization and prevents circular dependencies [http://en.wikipedia.org/wiki/Circular_dependency]. &lt;br /&gt;
On the other hand, with Setter injection, it is not clear, in which order things need to be instantiated. Apart from the guaranteed injection, this pattern is also very easy to implement. &lt;br /&gt;
&lt;br /&gt;
Continuing with the example mentioned above, we can implement the same using constructor injection as follows, &amp;lt;br&amp;gt; [[image:di_image3.png]] &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 '''''DoctorService.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class DoctorService&lt;br /&gt;
 {&lt;br /&gt;
         private PrescriptionDAO prescriptionDAO;&lt;br /&gt;
         // constructor for instantiatng prescriptionDAO&lt;br /&gt;
         public DoctorService (prescriptionDAO)&lt;br /&gt;
         { &lt;br /&gt;
            this.prescriptionDAO = prescriptionDAO; &lt;br /&gt;
         }&lt;br /&gt;
         //business logic that actually uses prescriptionDAOto access its variables and methods.&lt;br /&gt;
          public void print()&lt;br /&gt;
          {	&lt;br /&gt;
               System.out.println(&amp;quot;prescription:&amp;quot; +prescriptionDAO.prescription);&lt;br /&gt;
               System.out.println(&amp;quot;dose: &amp;quot;+prescriptionDAO.dose); &lt;br /&gt;
          }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
In the example, you must have noticed the parametrized constructor which Spring framework uses to instantiate the value of prescriptionDAO. &lt;br /&gt;
Now, the question is- how Spring container will come to know whether it has to use Constructor injection or Setter Injection? Tags inside the &amp;lt;bean&amp;gt; tag will specify this:&lt;br /&gt;
* &amp;lt;property&amp;gt; tag   is used for Setter Injection&lt;br /&gt;
* &amp;lt;constructor-arg&amp;gt; is used for Constructor Injection.&lt;br /&gt;
&lt;br /&gt;
ApplicationContect.xml for Constructor injection will be:&lt;br /&gt;
 '''''ApplicationContect.xml'''''&lt;br /&gt;
 &amp;lt;beans xmlns=&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;br /&gt;
    xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;br /&gt;
    xmlns:p=&amp;quot;http://www.springframework.org/schema/p&amp;quot;&lt;br /&gt;
    xsi:schemaLocation=&amp;quot;http://www.springframework.org/schema/beans&lt;br /&gt;
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;bean id=&amp;quot;doctorServiceId &amp;quot; class=&amp;quot;myPackage.DoctorService&amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;lt;!-- constructor injection using the nested &amp;lt;ref/&amp;gt; element --&amp;gt;&lt;br /&gt;
 		 &amp;lt;constructor-arg&amp;gt;&lt;br /&gt;
                 &amp;lt;ref bean=&amp;quot; prescriptionDAOId &amp;quot;/&amp;gt;&lt;br /&gt;
                 &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;
          &amp;lt;/bean&amp;gt;&lt;br /&gt;
          &amp;lt;bean id=&amp;quot; prescriptionDAOId&amp;quot;  class=&amp;quot; myPackage.PrescriptionDAO &amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;prescription&amp;quot; value=&amp;quot;Take medicine regularly.&amp;quot;/&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;dose&amp;quot; value=&amp;quot;3&amp;quot;/&amp;gt;&lt;br /&gt;
          &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Definitions for PrescriptionDAO.java and MyClient.java will remain the same.&lt;br /&gt;
The advantage of using Constructor Injection is that it can create the objects at the time of instantiation itself. Hence it guarantees the developer, that the objects will definitely get created and no exception will be raised. &lt;br /&gt;
&lt;br /&gt;
However, unlike [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch5_5e_dr#Type_2-_Setter_Injection Setter injection] it won’t allow changes to the dependency, once it is created.&lt;br /&gt;
&lt;br /&gt;
=Advantages and Disadvantages=&lt;br /&gt;
&lt;br /&gt;
Advantage of using Dependency injection are &lt;br /&gt;
* Clean code which helps to separate out the logic and the instantiation modules. &lt;br /&gt;
* It is also easy to maintain the code with the use of configuration files where we can make changes in future whenever required. &lt;br /&gt;
* It is very easy to test the code using Dependency Injection.&lt;br /&gt;
* It makes the code more readable.&lt;br /&gt;
&lt;br /&gt;
But the down side of Dependency Injection are that, &lt;br /&gt;
* It is not quite easy to understand the code for developers as there seems to be an abstraction layer which is performing initializing and instantiation of objects. &lt;br /&gt;
* Moreover, developers should have an expertise in coding such design patterns.&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
Hence, Dependency Injection design pattern is good enough to implement in the enterprise applications of large scale, as it helps in reusability, maintainability and testing.&lt;br /&gt;
&lt;br /&gt;
= References and Notes =&lt;br /&gt;
[1] [Spring in Action by Craig Walls, Ryan Briedenbach]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [Java Development with Spring Framework,  by Rod Johnson, Juergen Hoeller, Alef Arendsen, Thomas Risberg, Colin Sampaleanu]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://www.springsource.org/ Spring Framework]&amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://www.opensymphony.com/xwork/ Xwork]&amp;lt;br&amp;gt;&lt;br /&gt;
[8] [http://static.springsource.org/spring/docs/2.5.x/reference/aop.html Aspect Oriented Programming]&amp;lt;br&amp;gt;&lt;br /&gt;
[9] [http://en.wikipedia.org/wiki/Circular_dependency Circular Dependency]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
External Links&lt;br /&gt;
[1] [http://www.codeproject.com/KB/architecture/DependencyInjection.aspx Dependency Injection for Loose Coupling]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [http://www.springframework.net/doc-latest/reference/html/objects.html#objects-factory-collaborators Dependency injection]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://excalibur.apache.org/framework/index.html Excalibur Apache Avalon]&amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://www.picocontainer.org/ PicoContainer]&amp;lt;br&amp;gt;&lt;br /&gt;
[5] [http://hivelogic.com/ Hivelogic]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Further Reading =&lt;br /&gt;
[1] [Dependency Injection in .NET by Mark Seemann]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [Dependency Injection by Dhanji R Prassanna]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://www.developer.com/net/csharp/article.php/3722931/Dependency-Injection-with-SpringNet.htm Dependency Injection with Spring .NET] &amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://needle.rubyforge.org/api/ Dependency Injection in Ruby]&lt;br /&gt;
[5] [http://onestepback.org/index.cgi/Tech/Ruby/DependencyInjectionInRuby.rdoc ]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5e_dr&amp;diff=40014</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5e dr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5e_dr&amp;diff=40014"/>
		<updated>2010-11-03T22:17:34Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Dependency Injection'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
Every enterprise application involves handful number of objects that work together to achieve some purpose. These objects are coupled with each other and work in collaboration, making the classes highly dependent. However, creating such code involving highly coupled classes defeats an important tenet of Object oriented design- ‘loose coupling’. Loose coupling means that objects should have the minimum number of dependencies, which makes the code easy to understand, modify and debug. It also allows for greater code reusability and improves the maintainability.[http://www.codeproject.com/KB/architecture/DependencyInjection.aspx] This drive to decouple the code from its highly dependent objects leads to the concept of Dependency Injection.&lt;br /&gt;
&lt;br /&gt;
= Definition =&lt;br /&gt;
The basic concept of Dependency Injection(DI) is that you do not create the objects themselves, but describe how they should be created. It is one of the more popular design paradigms known today, by which the objects define their dependencies, i.e. the objects or classes they work with. DI pattern provides better a software design that makes the code cleaner, since the object doesn’t need to look for other components it works with, or know their location and class.[http://www.springframework.net/doc-latest/reference/html/objects.html#objects-factory-collaborators]&lt;br /&gt;
It facilitates the design of applications, using a framework that links the components, instead of the components linking themselves.  &lt;br /&gt;
&lt;br /&gt;
In other words, Dependency Injection, also known as Inversion Of Control(IoC), transfers the responsibility to locate and create the objects to the framework or the container which supports plug-n-play implementation, by injecting the dependencies into your code.&lt;br /&gt;
&lt;br /&gt;
= Features of Dependency Injection =&lt;br /&gt;
Main features of Dependency Injection Framework are:&lt;br /&gt;
* Better Design Pattern - Supports good Object-Oriented Design.&lt;br /&gt;
* Clean Code- Eliminates the need of looking up code from the application.&lt;br /&gt;
* Reuse - Promotes better code reusability.&lt;br /&gt;
* Loose Coupling- Objects are loosely coupled using DI&lt;br /&gt;
* Simple- It is very simple to implement, just need to inject the dependencies of any object.&lt;br /&gt;
* Maintainable- It is very easy to reconfigure and maintain in case of any future changes.&lt;br /&gt;
* More Testable- It makes it very easy to test the code, as objects get instantiated with values using configuration files.&lt;br /&gt;
&lt;br /&gt;
= Dependency Injection Frameworks =&lt;br /&gt;
Dependency Injection requires a framework that helps the developer to declare the dependencies, to locate, instantiate, and initialize the components or the objects. A developer has many available frameworks to him:&lt;br /&gt;
* '''Spring Framework''' – A light weight container, most widely used for DI and very large framework, which includes a lot many other features like Aspect Oriented, framework, container, etc. along with Dependency Injection.[http://www.springsource.org/]&lt;br /&gt;
* '''XWork''' -  It is a standalone framework and mostly works in conjunction with Webworks. It is a highly effective command pattern framework that provides a lot of features for DI.[http://www.opensymphony.com/xwork/]&lt;br /&gt;
* '''Apache Avalon'''- This is also a container framework which supports the dependency injection design pattern. This frameworks is now divided into sub-frameworks.[http://excalibur.apache.org/framework/index.html]&lt;br /&gt;
* '''PicoContainer''' - It is a highly focused DI framework available.[http://www.picocontainer.org/]&lt;br /&gt;
* '''Hivelogic''' – Another DI framework to inject dependencies.[http://hivelogic.com/]&lt;br /&gt;
&lt;br /&gt;
== Example of Dependency Injection Framework ==&lt;br /&gt;
&lt;br /&gt;
Let us consider a simple example to understand the basic idea of DI.&lt;br /&gt;
Suppose we have an Employee class which depends on the Department object. We need some Assembler (DI Framework) to instantiate the Department field of Employee class. Rather than Employee class creating this object for itself, it will delegate this task of instantiation to any framework selected from above. To do this, it uses configuration files, which are mostly .xml files. We will see comprehensive example using the framework in the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch5_5e_dr#Types_of_Dependency_Injection section 4]. &lt;br /&gt;
&lt;br /&gt;
 '''''Employee.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class Employee&lt;br /&gt;
  {&lt;br /&gt;
         //dependent object ‘dept'&lt;br /&gt;
         private Department dept;&lt;br /&gt;
         public void Employee( ){ }  &lt;br /&gt;
         &lt;br /&gt;
         setDepartment(dept){&lt;br /&gt;
             this.dept=dept;&lt;br /&gt;
         }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
 '''''Department.java'''''&lt;br /&gt;
  package myPackage;&lt;br /&gt;
  public class Department&lt;br /&gt;
   {&lt;br /&gt;
      private String name; &lt;br /&gt;
      public String getName(){&lt;br /&gt;
          return name;&lt;br /&gt;
       }&lt;br /&gt;
      public void setName(String name){&lt;br /&gt;
          this.name=name;&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
The framework will instantiate the Department object by looking into the configuration file for any existing dependencies of Employee object. It will form an Employee object with a Department instance. For example, in Spring Framework, the configuration file will be ApplicationContext.xml, where the binding of beans is done as follows:&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationContext.xml'''''&lt;br /&gt;
 &amp;lt;beans&amp;gt;&lt;br /&gt;
      &amp;lt;bean id=&amp;quot;employee&amp;quot; class=&amp;quot; myPackage .Employee.java&amp;quot;&amp;gt;&lt;br /&gt;
     	   &amp;lt;property name=&amp;quot;name &amp;quot; ref=&amp;quot;yetAnotherBean&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/bean&amp;gt;&lt;br /&gt;
      &amp;lt;bean id=&amp;quot;department&amp;quot; class=&amp;quot; myPackage .Department.java&amp;quot;&amp;gt;     	&lt;br /&gt;
  	   &amp;lt;property name=&amp;quot;name&amp;quot; value=&amp;quot;Java&amp;quot;/&amp;gt;      &lt;br /&gt;
      &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
thereby creating the dependency diagram as: &amp;lt;br&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
[[Image:Di_image1.png]]&lt;br /&gt;
&lt;br /&gt;
Here we can see that, the classes themselves do not create their own instances, but it is the framework that does this job for them, making the code cleaner, reusable and loosely coupled. In future if one wants to add on, delete or modify any of the dependent objects, one only needs to update the configuration file. There is no need to look up the code all over again to find the class’s dependent objects. One can make modifications to the lines of code creating instances, which may be,&lt;br /&gt;
		&lt;br /&gt;
  // used everywhere in code without Dependency Injection.&lt;br /&gt;
  Department dept=new Department ();  &lt;br /&gt;
&lt;br /&gt;
Thus it makes our code configurable and maintainable. &lt;br /&gt;
Let us now move on and see some more examples to understand the different types of injections available within different frameworks.&lt;br /&gt;
&lt;br /&gt;
= Types of Dependency Injection =&lt;br /&gt;
&lt;br /&gt;
There are a number of Dependency Injection variants that exists to allow the developer to implement and write loosely coupled code. The dependencies can be injected in various forms like: &lt;br /&gt;
* Type 1- Interface Injection&lt;br /&gt;
* Type 2- Setter Injection&lt;br /&gt;
* Type 3- Constructor Injection&lt;br /&gt;
&lt;br /&gt;
== Type 1- Interface Injection ==&lt;br /&gt;
&lt;br /&gt;
Interface injection is a technique to add the dependency for interfaces in components at run time. The components implement these interfaces based on the injected dependency. Spring framework does not support interface injection, so let us see this injection by using the Avalon framework.&lt;br /&gt;
&lt;br /&gt;
For example, we have an ApplicationDAO interface, while AccountApplicationDAO and  CustomerApplicationDAO are the classes implementing ApplicationDAO, &lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public interface ApplicationDAO&lt;br /&gt;
   {&lt;br /&gt;
       void getEntity();&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
 '''''AccountApplicationDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class AccountApplicationDAO implements ApplicationDAO&lt;br /&gt;
 {&lt;br /&gt;
        void getEntity(){&lt;br /&gt;
             //get all accounts.&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
 '''''CustomerApplicationDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class CustomerApplicationDAO implements ApplicationDAO&lt;br /&gt;
 {&lt;br /&gt;
        void getEntity()&lt;br /&gt;
        {&lt;br /&gt;
               //get all customers.&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We also have ApplicationService interface, which depends on the ApplicationDAO interface. The ApplicationServiceImpl class implements the ApplicationService inteface, which in turn implements the ApplicationDAO interface, provided by the container.&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationService.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public interface ApplicationService&lt;br /&gt;
 {&lt;br /&gt;
       getEntity(ApplicationDAO applicationDAO);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationServiceImpl.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class ApplicationServiceImpl implements ApplicationService &lt;br /&gt;
  {&lt;br /&gt;
        ApplicationDAO applicationDAO;&lt;br /&gt;
        validateEntity (ApplicationDAO applicationDAO)&lt;br /&gt;
         {&lt;br /&gt;
                this. applicationDAO= applicationDAO;&lt;br /&gt;
                applicationDAO.getEntity();&lt;br /&gt;
                //code to validate the Entity (Account/Customer),as per the configuration in xml file.&lt;br /&gt;
          }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
Now, our main program will get the interface dependency from the container, which uses configuration file for look up, &lt;br /&gt;
&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class MyClass&lt;br /&gt;
 {&lt;br /&gt;
        public static void main(string[] args)&lt;br /&gt;
        {&lt;br /&gt;
            // Get the correct dependency based on configuration file&lt;br /&gt;
            ApplicationDAO dependencyDAO = getDependecny();&lt;br /&gt;
 &lt;br /&gt;
            // Create our applicationServiceImpl class and inject the dependency&lt;br /&gt;
 	    ApplicationServiceImpl applicationServiceImpl = new ApplicationServiceImpl();&lt;br /&gt;
            // call validateEntity()&lt;br /&gt;
            ((ApplicationService)applicationServiceImpl).validateEntity(dependencyDAO);&lt;br /&gt;
 &lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        public static ApplicationDAO getDependency()&lt;br /&gt;
        {&lt;br /&gt;
            string implementClass =  &lt;br /&gt;
                                    System.Configuration.ConfigurationManager.AppSettings[&amp;quot;selectedClass&amp;quot;];&lt;br /&gt;
            Type type = System.Type.GetType(implementClass);&lt;br /&gt;
            ApplicationDAO applicationDAO = (ApplicationDAO)Activator.CreateInstance(type);&lt;br /&gt;
             &lt;br /&gt;
            return applicationDAO;&lt;br /&gt;
        }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
The Configuration File that will be used by MyClass file to lookup the dependency configurations will be of type:&lt;br /&gt;
&lt;br /&gt;
 '''''App.Config'''''&lt;br /&gt;
 &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
 &amp;lt;configuration&amp;gt;&lt;br /&gt;
      &amp;lt;appSettings&amp;gt;&lt;br /&gt;
            &amp;lt;add key=&amp;quot; selectedClass &amp;quot; value=&amp;quot;myPackage. AccountApplicationDAO &amp;quot; /&amp;gt;&lt;br /&gt;
       &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
 &amp;lt;/configuration&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
In this example, validateEntity() in ApplicationServiceImpl will call getEntity() using  &lt;br /&gt;
ApplicationDAO reference. The getEntity() that is invoked will actually depend on the dependency that is injected via the configuration file.&lt;br /&gt;
&lt;br /&gt;
==Type 2- Setter Injection==&lt;br /&gt;
&lt;br /&gt;
Dependency can be injected using the setter method of a class. If a class is dependent on another class or object instances, then the dependency should be declared as a state(variable) of the class and the class should have a setter method for it. The dependencies are set onto public attributes of the object in need. One of the primary motive for using setters, is supporting dependency injection without having to modify the constructor of a legacy class. Another use is to allow the creation of expensive resources or services as late as possible and only when needed, which is an edge over the Constructor Injection, which we will see in few moments.&lt;br /&gt;
&lt;br /&gt;
Let us consider an example of Setter injection by using Spring Framework.[3] Before using Spring, let us study some basic features of Spring. We will cover only a brief overview of the Spring Framework. &lt;br /&gt;
&lt;br /&gt;
* Spring is a lightweight container which along with supporting features like Dependency Injection, also include other ones as:  Container, Framework, AOP[http://static.springsource.org/spring/docs/2.5.x/reference/aop.html], MVC, etc. &lt;br /&gt;
* Spring Framework supports both Setter Injection and Constructor Injection, but not Interface Injection. Spring jars that can be included are : &lt;br /&gt;
** spring-beans.jar&lt;br /&gt;
** spring-core.jar&lt;br /&gt;
* Packages that provide Spring Frameworks’s IoC container are:&lt;br /&gt;
** org.springframeworks.beans&lt;br /&gt;
** org.springframeworks.context&lt;br /&gt;
&lt;br /&gt;
Now let us see Setter injection using the Spring framework.&lt;br /&gt;
The example below includes a class, DoctorService. The DoctorService class needs a data-access object for communicating with the database. Assume, the PrescriptionDAO (&amp;quot;order data-access object&amp;quot;) is the class on which DoctorService depends. &amp;lt;br&amp;gt;[[image:di_image2.png]] &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 '''''DoctorService.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class DoctorService&lt;br /&gt;
 {&lt;br /&gt;
       private PrescriptionDAO prescriptionDAO;&lt;br /&gt;
       //empty constructor&lt;br /&gt;
       public DoctorService () {}&lt;br /&gt;
       public PrescriptionDAO getPrescriptionDAO() &lt;br /&gt;
       { &lt;br /&gt;
              return this.prescriptionDAO;&lt;br /&gt;
       }&lt;br /&gt;
       //setter for prescriptionDAO&lt;br /&gt;
       public setPrescriptionDAO(prescriptionDAO) &lt;br /&gt;
       { &lt;br /&gt;
              this.prescriptionDAO = prescriptionDAO; &lt;br /&gt;
       }&lt;br /&gt;
       //business logic that actually uses prescriptionDAOto access its variables and methods.&lt;br /&gt;
       public void print()&lt;br /&gt;
       {&lt;br /&gt;
              System.out.println(“prescription: “+prescriptionDAO.prescription);&lt;br /&gt;
              System.out.println(“dose: “+prescriptionDAO.dose);&lt;br /&gt;
       }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
 '''''PrescriptionDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class PrescriptionDAO&lt;br /&gt;
 {&lt;br /&gt;
        private String prescription;&lt;br /&gt;
        private int dose;&lt;br /&gt;
        public PrescriptionDAO(){}&lt;br /&gt;
        public String getPrescription () &lt;br /&gt;
        {&lt;br /&gt;
                return  this.prescription;&lt;br /&gt;
        }&lt;br /&gt;
        public void setPrescription(String prescription) &lt;br /&gt;
        {&lt;br /&gt;
           this. prescription = prescription;&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Here, the invoking object is responsible for setting the PrescriptionDAO dependency. There is no code inside the class that is creating new instance of PrescriptionDAO. This is because this task will be performed by the Spring container, by looking for dependencies of DoctorService inside applicationContext.xml file.&lt;br /&gt;
&lt;br /&gt;
The Spring framework uses a setter method to create this dependent object. Note the &amp;lt;property&amp;gt; tag which is used inside ApplicationContext.xml file for setter injection. &lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationContext.xml'''''&lt;br /&gt;
 &amp;lt;beans xmlns=&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;br /&gt;
    xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;br /&gt;
    xmlns:p=&amp;quot;http://www.springframework.org/schema/p&amp;quot;&lt;br /&gt;
    xsi:schemaLocation=&amp;quot;http://www.springframework.org/schema/beans&lt;br /&gt;
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&amp;quot;&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
       &amp;lt;bean id=&amp;quot;doctorServiceId &amp;quot; class=&amp;quot;myPackage.DoctorService&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;!-- setter injection using the nested &amp;lt;ref/&amp;gt; element --&amp;gt;&lt;br /&gt;
                  &amp;lt;property name=&amp;quot; prescriptionDAO &amp;quot;&amp;gt;&amp;lt;ref bean=&amp;quot; prescriptionDAOId &amp;quot;/&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
       &amp;lt;/bean&amp;gt;&lt;br /&gt;
       &amp;lt;bean id=&amp;quot; prescriptionDAOId&amp;quot;  class=&amp;quot; myPackage.PrescriptionDAO &amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;prescription&amp;quot; value=&amp;quot;Take medicine regularly.&amp;quot;/&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;dose&amp;quot; value=&amp;quot;3&amp;quot;/&amp;gt;&lt;br /&gt;
       &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, Client is a class that is used to instantiate the Spring Container and retrieve the bean definitions from inside.&lt;br /&gt;
&lt;br /&gt;
 '''''MyClient.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 import java.io;&lt;br /&gt;
 import org.springframework.beans.factory.*;&lt;br /&gt;
 import org.springframework.beans.factory.xml.*;&lt;br /&gt;
 import org.springframework.core.io;&lt;br /&gt;
 public class MyClient&lt;br /&gt;
 {&lt;br /&gt;
        public static void main(String args[])&lt;br /&gt;
        {&lt;br /&gt;
                Resource res=new ClassPathResource(“./myPackage/ ApplicationContext.xml”);&lt;br /&gt;
                BeanFactory factory =new XmlBeanFactory(res); &lt;br /&gt;
                //” doctorServiceId” is the same id defined in ApplicationContext.xml&lt;br /&gt;
                DoctorService doctorService= (DoctorService) factory.getBean(“doctorServiceId”);&lt;br /&gt;
         }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Here, first the path for the ApplicationContext is specified, and then this file is used as a resource by the container. The BeanFactory container uses the xml file to access the bean defined inside the configuration file.&lt;br /&gt;
&lt;br /&gt;
However, Setter Injection unnecessarily adds to the abstraction. The developer needs to know which dependencies are needed when. On the other hand, it can save on modifying a lot of legacy code when introducing new methods, and can provide a performance boost if the dependency is expensive or not easily accessible.&lt;br /&gt;
&lt;br /&gt;
==Type 3- Constructor Injection==&lt;br /&gt;
&lt;br /&gt;
Constructor Injection is the DI technique of passing an object's dependencies to its constructor. It addresses the most common scenario where a class requires one or more Dependencies, and no reasonable local defaults are available.&lt;br /&gt;
&lt;br /&gt;
Constructor Injection addresses this scenario very well, because it guarantees that the Dependency is always present. If the depending class absolutely cannot function without the Dependency, such a guarantee is valuable. Constructor-injection enforces the order of initialization and prevents circular dependencies [http://en.wikipedia.org/wiki/Circular_dependency]. &lt;br /&gt;
On the other hand, with Setter injection, it is not clear, in which order things need to be instantiated. Apart from the guaranteed injection, this pattern is also very easy to implement. &lt;br /&gt;
&lt;br /&gt;
Continuing with the example mentioned above, we can implement the same using constructor injection as follows, &amp;lt;br&amp;gt; [[image:di_image3.png]] &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 '''''DoctorService.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class DoctorService&lt;br /&gt;
 {&lt;br /&gt;
         private PrescriptionDAO prescriptionDAO;&lt;br /&gt;
         // constructor for instantiatng prescriptionDAO&lt;br /&gt;
         public DoctorService (prescriptionDAO)&lt;br /&gt;
         { &lt;br /&gt;
            this.prescriptionDAO = prescriptionDAO; &lt;br /&gt;
         }&lt;br /&gt;
         //business logic that actually uses prescriptionDAOto access its variables and methods.&lt;br /&gt;
          public void print()&lt;br /&gt;
          {	&lt;br /&gt;
               System.out.println(&amp;quot;prescription:&amp;quot; +prescriptionDAO.prescription);&lt;br /&gt;
               System.out.println(&amp;quot;dose: &amp;quot;+prescriptionDAO.dose); &lt;br /&gt;
          }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
In the example, you must have noticed the parametrized constructor which Spring framework uses to instantiate the value of prescriptionDAO. &lt;br /&gt;
Now, the question is- how Spring container will come to know whether it has to use Constructor injection or Setter Injection? Tags inside the &amp;lt;bean&amp;gt; tag will specify this:&lt;br /&gt;
* &amp;lt;property&amp;gt; tag   is used for Setter Injection&lt;br /&gt;
* &amp;lt;constructor-arg&amp;gt; is used for Constructor Injection.&lt;br /&gt;
&lt;br /&gt;
ApplicationContect.xml for Constructor injection will be:&lt;br /&gt;
 '''''ApplicationContect.xml'''''&lt;br /&gt;
 &amp;lt;beans xmlns=&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;br /&gt;
    xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;br /&gt;
    xmlns:p=&amp;quot;http://www.springframework.org/schema/p&amp;quot;&lt;br /&gt;
    xsi:schemaLocation=&amp;quot;http://www.springframework.org/schema/beans&lt;br /&gt;
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;bean id=&amp;quot;doctorServiceId &amp;quot; class=&amp;quot;myPackage.DoctorService&amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;lt;!-- constructor injection using the nested &amp;lt;ref/&amp;gt; element --&amp;gt;&lt;br /&gt;
 		 &amp;lt;constructor-arg&amp;gt;&lt;br /&gt;
                 &amp;lt;ref bean=&amp;quot; prescriptionDAOId &amp;quot;/&amp;gt;&lt;br /&gt;
                 &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;
          &amp;lt;/bean&amp;gt;&lt;br /&gt;
          &amp;lt;bean id=&amp;quot; prescriptionDAOId&amp;quot;  class=&amp;quot; myPackage.PrescriptionDAO &amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;prescription&amp;quot; value=&amp;quot;Take medicine regularly.&amp;quot;/&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;dose&amp;quot; value=&amp;quot;3&amp;quot;/&amp;gt;&lt;br /&gt;
          &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Definitions for PrescriptionDAO.java and MyClient.java will remain the same.&lt;br /&gt;
The advantage of using Constructor Injection is that it can create the objects at the time of instantiation itself. Hence it guarantees the developer, that the objects will definitely get created and no exception will be raised. &lt;br /&gt;
&lt;br /&gt;
However, unlike [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch5_5e_dr#Type_2-_Setter_Injection Setter injection] it won’t allow changes to the dependency, once it is created.&lt;br /&gt;
&lt;br /&gt;
=Advantages and Disadvantages=&lt;br /&gt;
&lt;br /&gt;
 Advantage of using Dependency injection are &lt;br /&gt;
* Clean code which helps to separate out the logic and the instantiation modules. &lt;br /&gt;
* It is also easy to maintain the code with the use of configuration files where we can make changes in future whenever required. &lt;br /&gt;
* It is very easy to test the code using Dependency Injection.&lt;br /&gt;
* It makes the code more readable.&lt;br /&gt;
&lt;br /&gt;
 But the down side of Dependency Injection are that, &lt;br /&gt;
* It is not quite easy to understand the code for developers as there seems to be an abstraction layer which is performing initializing and instantiation of objects. &lt;br /&gt;
* Moreover, developers should have an expertise in coding such design patterns.&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
Hence, Dependency Injection design pattern is good enough to implement in the enterprise applications of large scale, as it helps in reusability, maintainability and testing.&lt;br /&gt;
&lt;br /&gt;
= References and Notes =&lt;br /&gt;
[1] [Spring in Action by Craig Walls, Ryan Briedenbach]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [Java Development with Spring Framework,  by Rod Johnson, Juergen Hoeller, Alef Arendsen, Thomas Risberg, Colin Sampaleanu]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://www.springsource.org/ Spring Framework]&amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://www.opensymphony.com/xwork/ Xwork]&amp;lt;br&amp;gt;&lt;br /&gt;
[8] [http://static.springsource.org/spring/docs/2.5.x/reference/aop.html Aspect Oriented Programming]&amp;lt;br&amp;gt;&lt;br /&gt;
[9] [http://en.wikipedia.org/wiki/Circular_dependency Circular Dependency]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
External Links&lt;br /&gt;
[1] [http://www.codeproject.com/KB/architecture/DependencyInjection.aspx Dependency Injection for Loose Coupling]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [http://www.springframework.net/doc-latest/reference/html/objects.html#objects-factory-collaborators Dependency injection]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://excalibur.apache.org/framework/index.html Excalibur Apache Avalon]&amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://www.picocontainer.org/ PicoContainer]&amp;lt;br&amp;gt;&lt;br /&gt;
[5] [http://hivelogic.com/ Hivelogic]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Further Reading =&lt;br /&gt;
[1] [Dependency Injection in .NET by Mark Seemann]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [Dependency Injection by Dhanji R Prassanna]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://www.developer.com/net/csharp/article.php/3722931/Dependency-Injection-with-SpringNet.htm Dependency Injection with Spring .NET] &amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://needle.rubyforge.org/api/ Dependency Injection in Ruby]&lt;br /&gt;
[5] [http://onestepback.org/index.cgi/Tech/Ruby/DependencyInjectionInRuby.rdoc ]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5e_dr&amp;diff=40013</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5e dr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5e_dr&amp;diff=40013"/>
		<updated>2010-11-03T22:16:21Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Dependency Injection'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
Every enterprise application involves handful number of objects that work together to achieve some purpose. These objects are coupled with each other and work in collaboration, making the classes highly dependent. However, creating such code involving highly coupled classes defeats an important tenet of Object oriented design- ‘loose coupling’. Loose coupling means that objects should have the minimum number of dependencies, which makes the code easy to understand, modify and debug. It also allows for greater code reusability and improves the maintainability.[http://www.codeproject.com/KB/architecture/DependencyInjection.aspx] This drive to decouple the code from its highly dependent objects leads to the concept of Dependency Injection.&lt;br /&gt;
&lt;br /&gt;
= Definition =&lt;br /&gt;
The basic concept of Dependency Injection(DI) is that you do not create the objects themselves, but describe how they should be created. It is one of the more popular design paradigms known today, by which the objects define their dependencies, i.e. the objects or classes they work with. DI pattern provides better a software design that makes the code cleaner, since the object doesn’t need to look for other components it works with, or know their location and class.[http://www.springframework.net/doc-latest/reference/html/objects.html#objects-factory-collaborators]&lt;br /&gt;
It facilitates the design of applications, using a framework that links the components, instead of the components linking themselves.  &lt;br /&gt;
&lt;br /&gt;
In other words, Dependency Injection, also known as Inversion Of Control(IoC), transfers the responsibility to locate and create the objects to the framework or the container which supports plug-n-play implementation, by injecting the dependencies into your code.&lt;br /&gt;
&lt;br /&gt;
= Features of Dependency Injection =&lt;br /&gt;
Main features of Dependency Injection Framework are:&lt;br /&gt;
* Better Design Pattern - Supports good Object-Oriented Design.&lt;br /&gt;
* Clean Code- Eliminates the need of looking up code from the application.&lt;br /&gt;
* Reuse - Promotes better code reusability.&lt;br /&gt;
* Loose Coupling- Objects are loosely coupled using DI&lt;br /&gt;
* Simple- It is very simple to implement, just need to inject the dependencies of any object.&lt;br /&gt;
* Maintainable- It is very easy to reconfigure and maintain in case of any future changes.&lt;br /&gt;
* More Testable- It makes it very easy to test the code, as objects get instantiated with values using configuration files.&lt;br /&gt;
&lt;br /&gt;
= Dependency Injection Frameworks =&lt;br /&gt;
Dependency Injection requires a framework that helps the developer to declare the dependencies, to locate, instantiate, and initialize the components or the objects. A developer has many available frameworks to him:&lt;br /&gt;
* '''Spring Framework''' – A light weight container, most widely used for DI and very large framework, which includes a lot many other features like Aspect Oriented, framework, container, etc. along with Dependency Injection.[http://www.springsource.org/]&lt;br /&gt;
* '''XWork''' -  It is a standalone framework and mostly works in conjunction with Webworks. It is a highly effective command pattern framework that provides a lot of features for DI.[http://www.opensymphony.com/xwork/]&lt;br /&gt;
* '''Apache Avalon'''- This is also a container framework which supports the dependency injection design pattern. This frameworks is now divided into sub-frameworks.[http://excalibur.apache.org/framework/index.html]&lt;br /&gt;
* '''PicoContainer''' - It is a highly focused DI framework available.[http://www.picocontainer.org/]&lt;br /&gt;
* '''Hivelogic''' – Another DI framework to inject dependencies.[http://hivelogic.com/]&lt;br /&gt;
&lt;br /&gt;
== Example of Dependency Injection Framework ==&lt;br /&gt;
&lt;br /&gt;
Let us consider a simple example to understand the basic idea of DI.&lt;br /&gt;
Suppose we have an Employee class which depends on the Department object. We need some Assembler (DI Framework) to instantiate the Department field of Employee class. Rather than Employee class creating this object for itself, it will delegate this task of instantiation to any framework selected from above. To do this, it uses configuration files, which are mostly .xml files. We will see comprehensive example using the framework in the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch5_5e_dr#Types_of_Dependency_Injection section 4]. &lt;br /&gt;
&lt;br /&gt;
 '''''Employee.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class Employee&lt;br /&gt;
  {&lt;br /&gt;
         //dependent object ‘dept'&lt;br /&gt;
         private Department dept;&lt;br /&gt;
         public void Employee( ){ }  &lt;br /&gt;
         &lt;br /&gt;
         setDepartment(dept){&lt;br /&gt;
             this.dept=dept;&lt;br /&gt;
         }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
 '''''Department.java'''''&lt;br /&gt;
  package myPackage;&lt;br /&gt;
  public class Department&lt;br /&gt;
   {&lt;br /&gt;
      private String name; &lt;br /&gt;
      public String getName(){&lt;br /&gt;
          return name;&lt;br /&gt;
       }&lt;br /&gt;
      public void setName(String name){&lt;br /&gt;
          this.name=name;&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
The framework will instantiate the Department object by looking into the configuration file for any existing dependencies of Employee object. It will form an Employee object with a Department instance. For example, in Spring Framework, the configuration file will be ApplicationContext.xml, where the binding of beans is done as follows:&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationContext.xml'''''&lt;br /&gt;
 &amp;lt;beans&amp;gt;&lt;br /&gt;
      &amp;lt;bean id=&amp;quot;employee&amp;quot; class=&amp;quot; myPackage .Employee.java&amp;quot;&amp;gt;&lt;br /&gt;
     	   &amp;lt;property name=&amp;quot;name &amp;quot; ref=&amp;quot;yetAnotherBean&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/bean&amp;gt;&lt;br /&gt;
      &amp;lt;bean id=&amp;quot;department&amp;quot; class=&amp;quot; myPackage .Department.java&amp;quot;&amp;gt;     	&lt;br /&gt;
  	   &amp;lt;property name=&amp;quot;name&amp;quot; value=&amp;quot;Java&amp;quot;/&amp;gt;      &lt;br /&gt;
      &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
thereby creating the dependency diagram as: &amp;lt;br&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
[[Image:Di_image1.png]]&lt;br /&gt;
&lt;br /&gt;
Here we can see that, the classes themselves do not create their own instances, but it is the framework that does this job for them, making the code cleaner, reusable and loosely coupled. In future if one wants to add on, delete or modify any of the dependent objects, one only needs to update the configuration file. There is no need to look up the code all over again to find the class’s dependent objects. One can make modifications to the lines of code creating instances, which may be,&lt;br /&gt;
		&lt;br /&gt;
  // used everywhere in code without Dependency Injection.&lt;br /&gt;
  Department dept=new Department ();  &lt;br /&gt;
&lt;br /&gt;
Thus it makes our code configurable and maintainable. &lt;br /&gt;
Let us now move on and see some more examples to understand the different types of injections available within different frameworks.&lt;br /&gt;
&lt;br /&gt;
= Types of Dependency Injection =&lt;br /&gt;
&lt;br /&gt;
There are a number of Dependency Injection variants that exists to allow the developer to implement and write loosely coupled code. The dependencies can be injected in various forms like: &lt;br /&gt;
* Type 1- Interface Injection&lt;br /&gt;
* Type 2- Setter Injection&lt;br /&gt;
* Type 3- Constructor Injection&lt;br /&gt;
&lt;br /&gt;
== Type 1- Interface Injection ==&lt;br /&gt;
&lt;br /&gt;
Interface injection is a technique to add the dependency for interfaces in components at run time. The components implement these interfaces based on the injected dependency. Spring framework does not support interface injection, so let us see this injection by using the Avalon framework.&lt;br /&gt;
&lt;br /&gt;
For example, we have an ApplicationDAO interface, while AccountApplicationDAO and  CustomerApplicationDAO are the classes implementing ApplicationDAO, &lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public interface ApplicationDAO&lt;br /&gt;
   {&lt;br /&gt;
       void getEntity();&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
 '''''AccountApplicationDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class AccountApplicationDAO implements ApplicationDAO&lt;br /&gt;
 {&lt;br /&gt;
        void getEntity(){&lt;br /&gt;
             //get all accounts.&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
 '''''CustomerApplicationDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class CustomerApplicationDAO implements ApplicationDAO&lt;br /&gt;
 {&lt;br /&gt;
        void getEntity()&lt;br /&gt;
        {&lt;br /&gt;
               //get all customers.&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We also have ApplicationService interface, which depends on the ApplicationDAO interface. The ApplicationServiceImpl class implements the ApplicationService inteface, which in turn implements the ApplicationDAO interface, provided by the container.&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationService.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public interface ApplicationService&lt;br /&gt;
 {&lt;br /&gt;
       getEntity(ApplicationDAO applicationDAO);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationServiceImpl.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class ApplicationServiceImpl implements ApplicationService &lt;br /&gt;
  {&lt;br /&gt;
        ApplicationDAO applicationDAO;&lt;br /&gt;
        validateEntity (ApplicationDAO applicationDAO)&lt;br /&gt;
         {&lt;br /&gt;
                this. applicationDAO= applicationDAO;&lt;br /&gt;
                applicationDAO.getEntity();&lt;br /&gt;
                //code to validate the Entity (Account/Customer),as per the configuration in xml file.&lt;br /&gt;
          }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
Now, our main program will get the interface dependency from the container, which uses configuration file for look up, &lt;br /&gt;
&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class MyClass&lt;br /&gt;
 {&lt;br /&gt;
        public static void main(string[] args)&lt;br /&gt;
        {&lt;br /&gt;
            // Get the correct dependency based on configuration file&lt;br /&gt;
            ApplicationDAO dependencyDAO = getDependecny();&lt;br /&gt;
 &lt;br /&gt;
            // Create our applicationServiceImpl class and inject the dependency&lt;br /&gt;
 	    ApplicationServiceImpl applicationServiceImpl = new ApplicationServiceImpl();&lt;br /&gt;
            // call validateEntity()&lt;br /&gt;
            ((ApplicationService)applicationServiceImpl).validateEntity(dependencyDAO);&lt;br /&gt;
 &lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        public static ApplicationDAO getDependency()&lt;br /&gt;
        {&lt;br /&gt;
            string implementClass =  &lt;br /&gt;
                                    System.Configuration.ConfigurationManager.AppSettings[&amp;quot;selectedClass&amp;quot;];&lt;br /&gt;
            Type type = System.Type.GetType(implementClass);&lt;br /&gt;
            ApplicationDAO applicationDAO = (ApplicationDAO)Activator.CreateInstance(type);&lt;br /&gt;
             &lt;br /&gt;
            return applicationDAO;&lt;br /&gt;
        }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
The Configuration File that will be used by MyClass file to lookup the dependency configurations will be of type:&lt;br /&gt;
&lt;br /&gt;
 '''''App.Config'''''&lt;br /&gt;
 &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
 &amp;lt;configuration&amp;gt;&lt;br /&gt;
      &amp;lt;appSettings&amp;gt;&lt;br /&gt;
            &amp;lt;add key=&amp;quot; selectedClass &amp;quot; value=&amp;quot;myPackage. AccountApplicationDAO &amp;quot; /&amp;gt;&lt;br /&gt;
       &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
 &amp;lt;/configuration&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
In this example, validateEntity() in ApplicationServiceImpl will call getEntity() using  &lt;br /&gt;
ApplicationDAO reference. The getEntity() that is invoked will actually depend on the dependency that is injected via the configuration file.&lt;br /&gt;
&lt;br /&gt;
==Type 2- Setter Injection==&lt;br /&gt;
&lt;br /&gt;
Dependency can be injected using the setter method of a class. If a class is dependent on another class or object instances, then the dependency should be declared as a state(variable) of the class and the class should have a setter method for it. The dependencies are set onto public attributes of the object in need. One of the primary motive for using setters, is supporting dependency injection without having to modify the constructor of a legacy class. Another use is to allow the creation of expensive resources or services as late as possible and only when needed, which is an edge over the Constructor Injection, which we will see in few moments.&lt;br /&gt;
&lt;br /&gt;
Let us consider an example of Setter injection by using Spring Framework.[3] Before using Spring, let us study some basic features of Spring. We will cover only a brief overview of the Spring Framework. &lt;br /&gt;
&lt;br /&gt;
* Spring is a lightweight container which along with supporting features like Dependency Injection, also include other ones as:  Container, Framework, AOP[http://static.springsource.org/spring/docs/2.5.x/reference/aop.html], MVC, etc. &lt;br /&gt;
* Spring Framework supports both Setter Injection and Constructor Injection, but not Interface Injection. Spring jars that can be included are : &lt;br /&gt;
** spring-beans.jar&lt;br /&gt;
** spring-core.jar&lt;br /&gt;
* Packages that provide Spring Frameworks’s IoC container are:&lt;br /&gt;
** org.springframeworks.beans&lt;br /&gt;
** org.springframeworks.context&lt;br /&gt;
&lt;br /&gt;
Now let us see Setter injection using the Spring framework.&lt;br /&gt;
The example below includes a class, DoctorService. The DoctorService class needs a data-access object for communicating with the database. Assume, the PrescriptionDAO (&amp;quot;order data-access object&amp;quot;) is the class on which DoctorService depends. &amp;lt;br&amp;gt;[[image:di_image2.png]] &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 '''''DoctorService.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class DoctorService&lt;br /&gt;
 {&lt;br /&gt;
       private PrescriptionDAO prescriptionDAO;&lt;br /&gt;
       //empty constructor&lt;br /&gt;
       public DoctorService () {}&lt;br /&gt;
       public PrescriptionDAO getPrescriptionDAO() &lt;br /&gt;
       { &lt;br /&gt;
              return this.prescriptionDAO;&lt;br /&gt;
       }&lt;br /&gt;
       //setter for prescriptionDAO&lt;br /&gt;
       public setPrescriptionDAO(prescriptionDAO) &lt;br /&gt;
       { &lt;br /&gt;
              this.prescriptionDAO = prescriptionDAO; &lt;br /&gt;
       }&lt;br /&gt;
       //business logic that actually uses prescriptionDAOto access its variables and methods.&lt;br /&gt;
       public void print()&lt;br /&gt;
       {&lt;br /&gt;
              System.out.println(“prescription: “+prescriptionDAO.prescription);&lt;br /&gt;
              System.out.println(“dose: “+prescriptionDAO.dose);&lt;br /&gt;
       }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
 '''''PrescriptionDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class PrescriptionDAO&lt;br /&gt;
 {&lt;br /&gt;
        private String prescription;&lt;br /&gt;
        private int dose;&lt;br /&gt;
        public PrescriptionDAO(){}&lt;br /&gt;
        public String getPrescription () &lt;br /&gt;
        {&lt;br /&gt;
                return  this.prescription;&lt;br /&gt;
        }&lt;br /&gt;
        public void setPrescription(String prescription) &lt;br /&gt;
        {&lt;br /&gt;
           this. prescription = prescription;&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Here, the invoking object is responsible for setting the PrescriptionDAO dependency. There is no code inside the class that is creating new instance of PrescriptionDAO. This is because this task will be performed by the Spring container, by looking for dependencies of DoctorService inside applicationContext.xml file.&lt;br /&gt;
&lt;br /&gt;
The Spring framework uses a setter method to create this dependent object. Note the &amp;lt;property&amp;gt; tag which is used inside ApplicationContext.xml file for setter injection. &lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationContext.xml'''''&lt;br /&gt;
 &amp;lt;beans xmlns=&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;br /&gt;
    xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;br /&gt;
    xmlns:p=&amp;quot;http://www.springframework.org/schema/p&amp;quot;&lt;br /&gt;
    xsi:schemaLocation=&amp;quot;http://www.springframework.org/schema/beans&lt;br /&gt;
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&amp;quot;&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
       &amp;lt;bean id=&amp;quot;doctorServiceId &amp;quot; class=&amp;quot;myPackage.DoctorService&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;!-- setter injection using the nested &amp;lt;ref/&amp;gt; element --&amp;gt;&lt;br /&gt;
                  &amp;lt;property name=&amp;quot; prescriptionDAO &amp;quot;&amp;gt;&amp;lt;ref bean=&amp;quot; prescriptionDAOId &amp;quot;/&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
       &amp;lt;/bean&amp;gt;&lt;br /&gt;
       &amp;lt;bean id=&amp;quot; prescriptionDAOId&amp;quot;  class=&amp;quot; myPackage.PrescriptionDAO &amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;prescription&amp;quot; value=&amp;quot;Take medicine regularly.&amp;quot;/&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;dose&amp;quot; value=&amp;quot;3&amp;quot;/&amp;gt;&lt;br /&gt;
       &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, Client is a class that is used to instantiate the Spring Container and retrieve the bean definitions from inside.&lt;br /&gt;
&lt;br /&gt;
 '''''MyClient.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 import java.io;&lt;br /&gt;
 import org.springframework.beans.factory.*;&lt;br /&gt;
 import org.springframework.beans.factory.xml.*;&lt;br /&gt;
 import org.springframework.core.io;&lt;br /&gt;
 public class MyClient&lt;br /&gt;
 {&lt;br /&gt;
        public static void main(String args[])&lt;br /&gt;
        {&lt;br /&gt;
                Resource res=new ClassPathResource(“./myPackage/ ApplicationContext.xml”);&lt;br /&gt;
                BeanFactory factory =new XmlBeanFactory(res); &lt;br /&gt;
                //” doctorServiceId” is the same id defined in ApplicationContext.xml&lt;br /&gt;
                DoctorService doctorService= (DoctorService) factory.getBean(“doctorServiceId”);&lt;br /&gt;
         }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Here, first the path for the ApplicationContext is specified, and then this file is used as a resource by the container. The BeanFactory container uses the xml file to access the bean defined inside the configuration file.&lt;br /&gt;
&lt;br /&gt;
However, Setter Injection unnecessarily adds to the abstraction. The developer needs to know which dependencies are needed when. On the other hand, it can save on modifying a lot of legacy code when introducing new methods, and can provide a performance boost if the dependency is expensive or not easily accessible.&lt;br /&gt;
&lt;br /&gt;
==Type 3- Constructor Injection==&lt;br /&gt;
&lt;br /&gt;
Constructor Injection is the DI technique of passing an object's dependencies to its constructor. It addresses the most common scenario where a class requires one or more Dependencies, and no reasonable local defaults are available.&lt;br /&gt;
&lt;br /&gt;
Constructor Injection addresses this scenario very well, because it guarantees that the Dependency is always present. If the depending class absolutely cannot function without the Dependency, such a guarantee is valuable. Constructor-injection enforces the order of initialization and prevents circular dependencies [http://en.wikipedia.org/wiki/Circular_dependency]. &lt;br /&gt;
On the other hand, with Setter injection, it is not clear, in which order things need to be instantiated. Apart from the guaranteed injection, this pattern is also very easy to implement. &lt;br /&gt;
&lt;br /&gt;
Continuing with the example mentioned above, we can implement the same using constructor injection as follows, &amp;lt;br&amp;gt; [[image:di_image3.png]] &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 '''''DoctorService.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class DoctorService&lt;br /&gt;
 {&lt;br /&gt;
         private PrescriptionDAO prescriptionDAO;&lt;br /&gt;
         // constructor for instantiatng prescriptionDAO&lt;br /&gt;
         public DoctorService (prescriptionDAO)&lt;br /&gt;
         { &lt;br /&gt;
            this.prescriptionDAO = prescriptionDAO; &lt;br /&gt;
         }&lt;br /&gt;
         //business logic that actually uses prescriptionDAOto access its variables and methods.&lt;br /&gt;
          public void print()&lt;br /&gt;
          {	&lt;br /&gt;
               System.out.println(&amp;quot;prescription:&amp;quot; +prescriptionDAO.prescription);&lt;br /&gt;
               System.out.println(&amp;quot;dose: &amp;quot;+prescriptionDAO.dose); &lt;br /&gt;
          }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
In the example, you must have noticed the parametrized constructor which Spring framework uses to instantiate the value of prescriptionDAO. &lt;br /&gt;
Now, the question is- how Spring container will come to know whether it has to use Constructor injection or Setter Injection? Tags inside the &amp;lt;bean&amp;gt; tag will specify this:&lt;br /&gt;
* &amp;lt;property&amp;gt; tag   is used for Setter Injection&lt;br /&gt;
* &amp;lt;constructor-arg&amp;gt; is used for Constructor Injection.&lt;br /&gt;
&lt;br /&gt;
ApplicationContect.xml for Constructor injection will be:&lt;br /&gt;
 '''''ApplicationContect.xml'''''&lt;br /&gt;
 &amp;lt;beans xmlns=&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;br /&gt;
    xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;br /&gt;
    xmlns:p=&amp;quot;http://www.springframework.org/schema/p&amp;quot;&lt;br /&gt;
    xsi:schemaLocation=&amp;quot;http://www.springframework.org/schema/beans&lt;br /&gt;
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;bean id=&amp;quot;doctorServiceId &amp;quot; class=&amp;quot;myPackage.DoctorService&amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;lt;!-- constructor injection using the nested &amp;lt;ref/&amp;gt; element --&amp;gt;&lt;br /&gt;
 		 &amp;lt;constructor-arg&amp;gt;&lt;br /&gt;
                 &amp;lt;ref bean=&amp;quot; prescriptionDAOId &amp;quot;/&amp;gt;&lt;br /&gt;
                 &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;
          &amp;lt;/bean&amp;gt;&lt;br /&gt;
          &amp;lt;bean id=&amp;quot; prescriptionDAOId&amp;quot;  class=&amp;quot; myPackage.PrescriptionDAO &amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;prescription&amp;quot; value=&amp;quot;Take medicine regularly.&amp;quot;/&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;dose&amp;quot; value=&amp;quot;3&amp;quot;/&amp;gt;&lt;br /&gt;
          &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Definitions for PrescriptionDAO.java and MyClient.java will remain the same.&lt;br /&gt;
The advantage of using Constructor Injection is that it can create the objects at the time of instantiation itself. Hence it guarantees the developer, that the objects will definitely get created and no exception will be raised. &lt;br /&gt;
&lt;br /&gt;
However, unlike [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch5_5e_dr#Type_2-_Setter_Injection Setter injection] it won’t allow changes to the dependency, once it is created.&lt;br /&gt;
&lt;br /&gt;
=Advantages and Disadvantages=&lt;br /&gt;
&lt;br /&gt;
Advantage of using Dependency injection are &lt;br /&gt;
* Clean code which helps to separate out the logic and the instantiation modules. &lt;br /&gt;
* It is also easy to maintain the code with the use of configuration files where we can make changes in future whenever required. &lt;br /&gt;
* It is very easy to test the code using Dependency Injection.&lt;br /&gt;
* It makes the code more readable.&lt;br /&gt;
&lt;br /&gt;
But the down side of Dependency Injection are that, &lt;br /&gt;
* It is not quite easy to understand the code for developers as there seems to be an abstraction layer which is performing initializing and instantiation of objects. &lt;br /&gt;
* Moreover, developers should have an expertise in coding such design patterns.&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
Hence, Dependency Injection design pattern is good enough to implement in the enterprise applications of large scale, as it helps in reusability, maintainability and testing.&lt;br /&gt;
&lt;br /&gt;
= References and Notes =&lt;br /&gt;
[1] [Spring in Action by Craig Walls, Ryan Briedenbach]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [Java Development with Spring Framework,  by Rod Johnson, Juergen Hoeller, Alef Arendsen, Thomas Risberg, Colin Sampaleanu]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://www.springsource.org/ Spring Framework]&amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://www.opensymphony.com/xwork/ Xwork]&amp;lt;br&amp;gt;&lt;br /&gt;
[8] [http://static.springsource.org/spring/docs/2.5.x/reference/aop.html Aspect Oriented Programming]&amp;lt;br&amp;gt;&lt;br /&gt;
[9] [http://en.wikipedia.org/wiki/Circular_dependency Circular Dependency]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
External Links&lt;br /&gt;
[1] [http://www.codeproject.com/KB/architecture/DependencyInjection.aspx Dependency Injection for Loose Coupling]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [http://www.springframework.net/doc-latest/reference/html/objects.html#objects-factory-collaborators Dependency injection]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://excalibur.apache.org/framework/index.html Excalibur Apache Avalon]&amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://www.picocontainer.org/ PicoContainer]&amp;lt;br&amp;gt;&lt;br /&gt;
[5] [http://hivelogic.com/ Hivelogic]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Further Reading =&lt;br /&gt;
[1] [Dependency Injection in .NET by Mark Seemann]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [Dependency Injection by Dhanji R Prassanna]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://www.developer.com/net/csharp/article.php/3722931/Dependency-Injection-with-SpringNet.htm Dependency Injection with Spring .NET] &amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://needle.rubyforge.org/api/ Dependency Injection in Ruby]&lt;br /&gt;
[5] [http://onestepback.org/index.cgi/Tech/Ruby/DependencyInjectionInRuby.rdoc ]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5e_dr&amp;diff=40012</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5e dr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5e_dr&amp;diff=40012"/>
		<updated>2010-11-03T22:13:06Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Dependency Injection'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
Every enterprise application involves handful number of objects that work together to achieve some purpose. These objects are coupled with each other and work in collaboration, making the classes highly dependent. However, creating such code involving highly coupled classes defeats an important tenet of Object oriented design- ‘loose coupling’. Loose coupling means that objects should have the minimum number of dependencies, which makes the code easy to understand, modify and debug. It also allows for greater code reusability and improves the maintainability.[http://www.codeproject.com/KB/architecture/DependencyInjection.aspx] This drive to decouple the code from its highly dependent objects leads to the concept of Dependency Injection.&lt;br /&gt;
&lt;br /&gt;
= Definition =&lt;br /&gt;
The basic concept of Dependency Injection(DI) is that you do not create the objects themselves, but describe how they should be created. It is one of the more popular design paradigms known today, by which the objects define their dependencies, i.e. the objects or classes they work with. DI pattern provides better a software design that makes the code cleaner, since the object doesn’t need to look for other components it works with, or know their location and class.[http://www.springframework.net/doc-latest/reference/html/objects.html#objects-factory-collaborators]&lt;br /&gt;
It facilitates the design of applications, using a framework that links the components, instead of the components linking themselves.  &lt;br /&gt;
&lt;br /&gt;
In other words, Dependency Injection, also known as Inversion Of Control(IoC), transfers the responsibility to locate and create the objects to the framework or the container which supports plug-n-play implementation, by injecting the dependencies into your code.&lt;br /&gt;
&lt;br /&gt;
= Features of Dependency Injection =&lt;br /&gt;
Main features of Dependency Injection Framework are:&lt;br /&gt;
* Better Design Pattern - Supports good Object-Oriented Design.&lt;br /&gt;
* Clean Code- Eliminates the need of looking up code from the application.&lt;br /&gt;
* Reuse - Promotes better code reusability.&lt;br /&gt;
* Loose Coupling- Objects are loosely coupled using DI&lt;br /&gt;
* Simple- It is very simple to implement, just need to inject the dependencies of any object.&lt;br /&gt;
* Maintainable- It is very easy to reconfigure and maintain in case of any future changes.&lt;br /&gt;
* More Testable- It makes it very easy to test the code, as objects get instantiated with values using configuration files.&lt;br /&gt;
&lt;br /&gt;
= Dependency Injection Frameworks =&lt;br /&gt;
Dependency Injection requires a framework that helps the developer to declare the dependencies, to locate, instantiate, and initialize the components or the objects. A developer has many available frameworks to him:&lt;br /&gt;
* '''Spring Framework''' – A light weight container, most widely used for DI and very large framework, which includes a lot many other features like Aspect Oriented, framework, container, etc. along with Dependency Injection.[http://www.springsource.org/]&lt;br /&gt;
* '''XWork''' -  It is a standalone framework and mostly works in conjunction with Webworks. It is a highly effective command pattern framework that provides a lot of features for DI.[http://www.opensymphony.com/xwork/]&lt;br /&gt;
* '''Apache Avalon'''- This is also a container framework which supports the dependency injection design pattern. This frameworks is now divided into sub-frameworks.[http://excalibur.apache.org/framework/index.html]&lt;br /&gt;
* '''PicoContainer''' - It is a highly focused DI framework available.[http://www.picocontainer.org/]&lt;br /&gt;
* '''Hivelogic''' – Another DI framework to inject dependencies.[http://hivelogic.com/]&lt;br /&gt;
&lt;br /&gt;
== Example of Dependency Injection Framework ==&lt;br /&gt;
&lt;br /&gt;
Let us consider a simple example to understand the basic idea of DI.&lt;br /&gt;
Suppose we have an Employee class which depends on the Department object. We need some Assembler (DI Framework) to instantiate the Department field of Employee class. Rather than Employee class creating this object for itself, it will delegate this task of instantiation to any framework selected from above. To do this, it uses configuration files, which are mostly .xml files. We will see comprehensive example using the framework in the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch5_5e_dr#Types_of_Dependency_Injection section 4]. &lt;br /&gt;
&lt;br /&gt;
 '''''Employee.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class Employee&lt;br /&gt;
  {&lt;br /&gt;
         //dependent object ‘dept'&lt;br /&gt;
         private Department dept;&lt;br /&gt;
         public void Employee( ){ }  &lt;br /&gt;
         &lt;br /&gt;
         setDepartment(dept){&lt;br /&gt;
             this.dept=dept;&lt;br /&gt;
         }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
 '''''Department.java'''''&lt;br /&gt;
  package myPackage;&lt;br /&gt;
  public class Department&lt;br /&gt;
   {&lt;br /&gt;
      private String name; &lt;br /&gt;
      public String getName(){&lt;br /&gt;
          return name;&lt;br /&gt;
       }&lt;br /&gt;
      public void setName(String name){&lt;br /&gt;
          this.name=name;&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
The framework will instantiate the Department object by looking into the configuration file for any existing dependencies of Employee object. It will form an Employee object with a Department instance. For example, in Spring Framework, the configuration file will be ApplicationContext.xml, where the binding of beans is done as follows:&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationContext.xml'''''&lt;br /&gt;
 &amp;lt;beans&amp;gt;&lt;br /&gt;
      &amp;lt;bean id=&amp;quot;employee&amp;quot; class=&amp;quot; myPackage .Employee.java&amp;quot;&amp;gt;&lt;br /&gt;
     	   &amp;lt;property name=&amp;quot;name &amp;quot; ref=&amp;quot;yetAnotherBean&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/bean&amp;gt;&lt;br /&gt;
      &amp;lt;bean id=&amp;quot;department&amp;quot; class=&amp;quot; myPackage .Department.java&amp;quot;&amp;gt;     	&lt;br /&gt;
  	   &amp;lt;property name=&amp;quot;name&amp;quot; value=&amp;quot;Java&amp;quot;/&amp;gt;      &lt;br /&gt;
      &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
thereby creating the dependency diagram as: &amp;lt;br&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
[[Image:Di_image1.png]]&lt;br /&gt;
&lt;br /&gt;
Here we can see that, the classes themselves do not create their own instances, but it is the framework that does this job for them, making the code cleaner, reusable and loosely coupled. In future if one wants to add on, delete or modify any of the dependent objects, one only needs to update the configuration file. There is no need to look up the code all over again to find the class’s dependent objects. One can make modifications to the lines of code creating instances, which may be,&lt;br /&gt;
		&lt;br /&gt;
  // used everywhere in code without Dependency Injection.&lt;br /&gt;
  Department dept=new Department ();  &lt;br /&gt;
&lt;br /&gt;
Thus it makes our code configurable and maintainable. &lt;br /&gt;
Let us now move on and see some more examples to understand the different types of injections available within different frameworks.&lt;br /&gt;
&lt;br /&gt;
= Types of Dependency Injection =&lt;br /&gt;
&lt;br /&gt;
There are a number of Dependency Injection variants that exists to allow the developer to implement and write loosely coupled code. The dependencies can be injected in various forms like: &lt;br /&gt;
* Type 1- Interface Injection&lt;br /&gt;
* Type 2- Setter Injection&lt;br /&gt;
* Type 3- Constructor Injection&lt;br /&gt;
&lt;br /&gt;
== Type 1- Interface Injection ==&lt;br /&gt;
&lt;br /&gt;
Interface injection is a technique to add the dependency for interfaces in components at run time. The components implement these interfaces based on the injected dependency. Spring framework does not support interface injection, so let us see this injection by using the Avalon framework.&lt;br /&gt;
&lt;br /&gt;
For example, we have an ApplicationDAO interface, while AccountApplicationDAO and  CustomerApplicationDAO are the classes implementing ApplicationDAO, &lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public interface ApplicationDAO&lt;br /&gt;
   {&lt;br /&gt;
       void getEntity();&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
 '''''AccountApplicationDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class AccountApplicationDAO implements ApplicationDAO&lt;br /&gt;
 {&lt;br /&gt;
        void getEntity(){&lt;br /&gt;
             //get all accounts.&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
 '''''CustomerApplicationDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class CustomerApplicationDAO implements ApplicationDAO&lt;br /&gt;
 {&lt;br /&gt;
        void getEntity()&lt;br /&gt;
        {&lt;br /&gt;
               //get all customers.&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We also have ApplicationService interface, which depends on the ApplicationDAO interface. The ApplicationServiceImpl class implements the ApplicationService inteface, which in turn implements the ApplicationDAO interface, provided by the container.&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationService.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public interface ApplicationService&lt;br /&gt;
 {&lt;br /&gt;
       getEntity(ApplicationDAO applicationDAO);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationServiceImpl.java'''''&lt;br /&gt;
  package myPackage;&lt;br /&gt;
 public class ApplicationServiceImpl implements ApplicationService &lt;br /&gt;
  {&lt;br /&gt;
        ApplicationDAO applicationDAO;&lt;br /&gt;
        validateEntity (ApplicationDAO applicationDAO)&lt;br /&gt;
         {&lt;br /&gt;
                this. applicationDAO= applicationDAO;&lt;br /&gt;
                applicationDAO.getEntity();&lt;br /&gt;
                //code to validate the Entity (Account/Customer),as per the configuration in xml file.&lt;br /&gt;
          }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
Now, our main program will get the interface dependency from the container, which uses configuration file for look up, &lt;br /&gt;
&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class MyClass&lt;br /&gt;
 {&lt;br /&gt;
        public static void main(string[] args)&lt;br /&gt;
        {&lt;br /&gt;
            // Get the correct dependency based on configuration file&lt;br /&gt;
            ApplicationDAO dependencyDAO = getDependecny();&lt;br /&gt;
 &lt;br /&gt;
            // Create our applicationServiceImpl class and inject the dependency&lt;br /&gt;
 	    ApplicationServiceImpl applicationServiceImpl = new ApplicationServiceImpl();&lt;br /&gt;
            // call validateEntity()&lt;br /&gt;
            ((ApplicationService)applicationServiceImpl).validateEntity(dependencyDAO);&lt;br /&gt;
 &lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        public static ApplicationDAO getDependency()&lt;br /&gt;
        {&lt;br /&gt;
            string implementClass =  &lt;br /&gt;
                                    System.Configuration.ConfigurationManager.AppSettings[&amp;quot;selectedClass&amp;quot;];&lt;br /&gt;
            Type type = System.Type.GetType(implementClass);&lt;br /&gt;
            ApplicationDAO applicationDAO = (ApplicationDAO)Activator.CreateInstance(type);&lt;br /&gt;
             &lt;br /&gt;
            return applicationDAO;&lt;br /&gt;
        }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
The Configuration File that will be used by MyClass file to lookup the dependency configurations will be of type:&lt;br /&gt;
&lt;br /&gt;
 '''''App.Config'''''&lt;br /&gt;
 &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
 &amp;lt;configuration&amp;gt;&lt;br /&gt;
      &amp;lt;appSettings&amp;gt;&lt;br /&gt;
            &amp;lt;add key=&amp;quot; selectedClass &amp;quot; value=&amp;quot;myPackage. AccountApplicationDAO &amp;quot; /&amp;gt;&lt;br /&gt;
       &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
 &amp;lt;/configuration&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
In this example, validateEntity() in ApplicationServiceImpl will call getEntity() using  &lt;br /&gt;
ApplicationDAO reference. The getEntity() that is invoked will actually depend on the dependency that is injected via the configuration file.&lt;br /&gt;
&lt;br /&gt;
==Type 2- Setter Injection==&lt;br /&gt;
&lt;br /&gt;
Dependency can be injected using the setter method of a class. If a class is dependent on another class or object instances, then the dependency should be declared as a state(variable) of the class and the class should have a setter method for it. The dependencies are set onto public attributes of the object in need. One of the primary motive for using setters, is supporting dependency injection without having to modify the constructor of a legacy class. Another use is to allow the creation of expensive resources or services as late as possible and only when needed, which is an edge over the Constructor Injection, which we will see in few moments.&lt;br /&gt;
&lt;br /&gt;
Let us consider an example of Setter injection by using Spring Framework.[3] Before using Spring, let us study some basic features of Spring. We will cover only a brief overview of the Spring Framework. &lt;br /&gt;
&lt;br /&gt;
* Spring is a lightweight container which along with supporting features like Dependency Injection, also include other ones as:  Container, Framework, AOP[http://static.springsource.org/spring/docs/2.5.x/reference/aop.html], MVC, etc. &lt;br /&gt;
* Spring Framework supports both Setter Injection and Constructor Injection, but not Interface Injection. Spring jars that can be included are : &lt;br /&gt;
** spring-beans.jar&lt;br /&gt;
** spring-core.jar&lt;br /&gt;
* Packages that provide Spring Frameworks’s IoC container are:&lt;br /&gt;
** org.springframeworks.beans&lt;br /&gt;
** org.springframeworks.context&lt;br /&gt;
&lt;br /&gt;
Now let us see Setter injection using the Spring framework.&lt;br /&gt;
The example below includes a class, DoctorService. The DoctorService class needs a data-access object for communicating with the database. Assume, the PrescriptionDAO (&amp;quot;order data-access object&amp;quot;) is the class on which DoctorService depends. &amp;lt;br&amp;gt;[[image:di_image2.png]] &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 '''''DoctorService.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class DoctorService&lt;br /&gt;
 {&lt;br /&gt;
       private PrescriptionDAO prescriptionDAO;&lt;br /&gt;
       //empty constructor&lt;br /&gt;
       public DoctorService () {}&lt;br /&gt;
       public PrescriptionDAO getPrescriptionDAO() &lt;br /&gt;
       { &lt;br /&gt;
              return this.prescriptionDAO;&lt;br /&gt;
       }&lt;br /&gt;
       //setter for prescriptionDAO&lt;br /&gt;
       public setPrescriptionDAO(prescriptionDAO) &lt;br /&gt;
       { &lt;br /&gt;
              this.prescriptionDAO = prescriptionDAO; &lt;br /&gt;
       }&lt;br /&gt;
       //business logic that actually uses prescriptionDAOto access its variables and methods.&lt;br /&gt;
       public void print()&lt;br /&gt;
       {&lt;br /&gt;
              System.out.println(“prescription: “+prescriptionDAO.prescription);&lt;br /&gt;
              System.out.println(“dose: “+prescriptionDAO.dose);&lt;br /&gt;
       }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
 '''''PrescriptionDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class PrescriptionDAO&lt;br /&gt;
 {&lt;br /&gt;
        private String prescription;&lt;br /&gt;
        private int dose;&lt;br /&gt;
        public PrescriptionDAO(){}&lt;br /&gt;
        public String getPrescription () &lt;br /&gt;
        {&lt;br /&gt;
                return  this.prescription;&lt;br /&gt;
        }&lt;br /&gt;
        public void setPrescription(String prescription) &lt;br /&gt;
        {&lt;br /&gt;
           this. prescription = prescription;&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, the invoking object is responsible for setting the PrescriptionDAO dependency. There is no code inside the class that is creating new instance of PrescriptionDAO. This is because this task will be performed by the Spring container, by looking for dependencies of DoctorService inside applicationContext.xml file.&lt;br /&gt;
&lt;br /&gt;
The Spring framework uses a setter method to create this dependent object. Note the &amp;lt;property&amp;gt; tag which is used inside ApplicationContext.xml file for setter injection. &lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationContext.xml'''''&lt;br /&gt;
 &amp;lt;beans xmlns=&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;br /&gt;
    xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;br /&gt;
    xmlns:p=&amp;quot;http://www.springframework.org/schema/p&amp;quot;&lt;br /&gt;
    xsi:schemaLocation=&amp;quot;http://www.springframework.org/schema/beans&lt;br /&gt;
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&amp;quot;&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
       &amp;lt;bean id=&amp;quot;doctorServiceId &amp;quot; class=&amp;quot;myPackage.DoctorService&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;!-- setter injection using the nested &amp;lt;ref/&amp;gt; element --&amp;gt;&lt;br /&gt;
                  &amp;lt;property name=&amp;quot; prescriptionDAO &amp;quot;&amp;gt;&amp;lt;ref bean=&amp;quot; prescriptionDAOId &amp;quot;/&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
       &amp;lt;/bean&amp;gt;&lt;br /&gt;
       &amp;lt;bean id=&amp;quot; prescriptionDAOId&amp;quot;  class=&amp;quot; myPackage.PrescriptionDAO &amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;prescription&amp;quot; value=&amp;quot;Take medicine regularly.&amp;quot;/&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;dose&amp;quot; value=&amp;quot;3&amp;quot;/&amp;gt;&lt;br /&gt;
       &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, Client is a class that is used to instantiate the Spring Container and retrieve the bean definitions from inside.&lt;br /&gt;
&lt;br /&gt;
 '''''MyClient.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 import java.io;&lt;br /&gt;
 import org.springframework.beans.factory.*;&lt;br /&gt;
 import org.springframework.beans.factory.xml.*;&lt;br /&gt;
 import org.springframework.core.io;&lt;br /&gt;
 public class MyClient&lt;br /&gt;
 {&lt;br /&gt;
    public static void main(String args[])&lt;br /&gt;
        {&lt;br /&gt;
                Resource res=new ClassPathResource(“./myPackage/ ApplicationContext.xml”);&lt;br /&gt;
                BeanFactory factory =new XmlBeanFactory(res); &lt;br /&gt;
                //” doctorServiceId” is the same id defined in ApplicationContext.xml&lt;br /&gt;
                DoctorService doctorService= (DoctorService) factory.getBean(“doctorServiceId”);&lt;br /&gt;
         }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Here, first the path for the ApplicationContext is specified, and then this file is used as a resource by the container. The BeanFactory container uses the xml file to access the bean defined inside the configuration file.&lt;br /&gt;
&lt;br /&gt;
However, Setter Injection unnecessarily adds to the abstraction. The developer needs to know which dependencies are needed when. On the other hand, it can save on modifying a lot of legacy code when introducing new methods, and can provide a performance boost if the dependency is expensive or not easily accessible.&lt;br /&gt;
&lt;br /&gt;
==Type 3- Constructor Injection==&lt;br /&gt;
&lt;br /&gt;
Constructor Injection is the DI technique of passing an object's dependencies to its constructor. It addresses the most common scenario where a class requires one or more Dependencies, and no reasonable local defaults are available.&lt;br /&gt;
&lt;br /&gt;
Constructor Injection addresses this scenario very well, because it guarantees that the Dependency is always present. If the depending class absolutely cannot function without the Dependency, such a guarantee is valuable. Constructor-injection enforces the order of initialization and prevents circular dependencies [http://en.wikipedia.org/wiki/Circular_dependency]. &lt;br /&gt;
On the other hand, with Setter injection, it is not clear, in which order things need to be instantiated. Apart from the guaranteed injection, this pattern is also very easy to implement. &lt;br /&gt;
&lt;br /&gt;
Continuing with the example mentioned above, we can implement the same using constructor injection as follows, &amp;lt;br&amp;gt; [[image:di_image3.png]] &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 '''''DoctorService.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class DoctorService&lt;br /&gt;
 {&lt;br /&gt;
         private PrescriptionDAO prescriptionDAO;&lt;br /&gt;
         // constructor for instantiatng prescriptionDAO&lt;br /&gt;
         public DoctorService (prescriptionDAO)&lt;br /&gt;
         { &lt;br /&gt;
            this.prescriptionDAO = prescriptionDAO; &lt;br /&gt;
         }&lt;br /&gt;
         //business logic that actually uses prescriptionDAOto access its variables and methods.&lt;br /&gt;
          public void print()&lt;br /&gt;
          {	&lt;br /&gt;
               System.out.println(&amp;quot;prescription:&amp;quot; +prescriptionDAO.prescription);&lt;br /&gt;
               System.out.println(&amp;quot;dose: &amp;quot;+prescriptionDAO.dose); &lt;br /&gt;
          }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
In the example, you must have noticed the parametrized constructor which Spring framework uses to instantiate the value of prescriptionDAO. &lt;br /&gt;
Now, the question is- how Spring container will come to know whether it has to use Constructor injection or Setter Injection? Tags inside the &amp;lt;bean&amp;gt; tag will specify this:&lt;br /&gt;
* &amp;lt;property&amp;gt; tag   is used for Setter Injection&lt;br /&gt;
* &amp;lt;constructor-arg&amp;gt; is used for Constructor Injection.&lt;br /&gt;
&lt;br /&gt;
ApplicationContect.xml for Constructor injection will be:&lt;br /&gt;
 '''''ApplicationContect.xml'''''&lt;br /&gt;
 &amp;lt;beans xmlns=&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;br /&gt;
    xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;br /&gt;
    xmlns:p=&amp;quot;http://www.springframework.org/schema/p&amp;quot;&lt;br /&gt;
    xsi:schemaLocation=&amp;quot;http://www.springframework.org/schema/beans&lt;br /&gt;
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;bean id=&amp;quot;doctorServiceId &amp;quot; class=&amp;quot;myPackage.DoctorService&amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;lt;!-- constructor injection using the nested &amp;lt;ref/&amp;gt; element --&amp;gt;&lt;br /&gt;
 		 &amp;lt;constructor-arg&amp;gt;&lt;br /&gt;
                 &amp;lt;ref bean=&amp;quot; prescriptionDAOId &amp;quot;/&amp;gt;&lt;br /&gt;
                 &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;
          &amp;lt;/bean&amp;gt;&lt;br /&gt;
          &amp;lt;bean id=&amp;quot; prescriptionDAOId&amp;quot;  class=&amp;quot; myPackage.PrescriptionDAO &amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;prescription&amp;quot; value=&amp;quot;Take medicine regularly.&amp;quot;/&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;dose&amp;quot; value=&amp;quot;3&amp;quot;/&amp;gt;&lt;br /&gt;
          &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Definitions for PrescriptionDAO.java and MyClient.java will remain the same.&lt;br /&gt;
The advantage of using Constructor Injection is that it can create the objects at the time of instantiation itself. Hence it guarantees the developer, that the objects will definitely get created and no exception will be raised. &lt;br /&gt;
&lt;br /&gt;
However, unlike [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch5_5e_dr#Type_2-_Setter_Injection Setter injection] it won’t allow changes to the dependency, once it is created.&lt;br /&gt;
&lt;br /&gt;
=Advantages and Disadvantages=&lt;br /&gt;
&lt;br /&gt;
Advantage of using Dependency injection are &lt;br /&gt;
* Clean code which helps to separate out the logic and the instantiation modules. &lt;br /&gt;
* It is also easy to maintain the code with the use of configuration files where we can make changes in future whenever required. &lt;br /&gt;
* It is very easy to test the code using Dependency Injection.&lt;br /&gt;
* It makes the code more readable.&lt;br /&gt;
&lt;br /&gt;
But the down side of Dependency Injection are that, &lt;br /&gt;
* It is not quite easy to understand the code for developers as there seems to be an abstraction layer which is performing initializing and instantiation of objects. &lt;br /&gt;
* Moreover, developers should have an expertise in coding such design patterns.&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
Hence, Dependency Injection design pattern is good enough to implement in the enterprise applications of large scale, as it helps in reusability, maintainability and testing.&lt;br /&gt;
&lt;br /&gt;
= References and Notes =&lt;br /&gt;
[1] [Spring in Action by Craig Walls, Ryan Briedenbach]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [Java Development with Spring Framework,  by Rod Johnson, Juergen Hoeller, Alef Arendsen, Thomas Risberg, Colin Sampaleanu]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://www.springsource.org/ Spring Framework]&amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://www.opensymphony.com/xwork/ Xwork]&amp;lt;br&amp;gt;&lt;br /&gt;
[8] [http://static.springsource.org/spring/docs/2.5.x/reference/aop.html Aspect Oriented Programming]&amp;lt;br&amp;gt;&lt;br /&gt;
[9] [http://en.wikipedia.org/wiki/Circular_dependency Circular Dependency]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
External Links&lt;br /&gt;
[1] [http://www.codeproject.com/KB/architecture/DependencyInjection.aspx Dependency Injection for Loose Coupling]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [http://www.springframework.net/doc-latest/reference/html/objects.html#objects-factory-collaborators Dependency injection]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://excalibur.apache.org/framework/index.html Excalibur Apache Avalon]&amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://www.picocontainer.org/ PicoContainer]&amp;lt;br&amp;gt;&lt;br /&gt;
[5] [http://hivelogic.com/ Hivelogic]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Further Reading =&lt;br /&gt;
[1] [Dependency Injection in .NET by Mark Seemann]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [Dependency Injection by Dhanji R Prassanna]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://www.developer.com/net/csharp/article.php/3722931/Dependency-Injection-with-SpringNet.htm Dependency Injection with Spring .NET] &amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://needle.rubyforge.org/api/ Dependency Injection in Ruby]&lt;br /&gt;
[5] [http://onestepback.org/index.cgi/Tech/Ruby/DependencyInjectionInRuby.rdoc ]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5e_dr&amp;diff=40008</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5e dr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5e_dr&amp;diff=40008"/>
		<updated>2010-11-03T22:10:29Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Dependency Injection'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
Every enterprise application involves handful number of objects that work together to achieve some purpose. These objects are coupled with each other and work in collaboration, making the classes highly dependent. However, creating such code involving highly coupled classes defeats an important tenet of Object oriented design- ‘loose coupling’. Loose coupling means that objects should have the minimum number of dependencies, which makes the code easy to understand, modify and debug. It also allows for greater code reusability and improves the maintainability.[http://www.codeproject.com/KB/architecture/DependencyInjection.aspx] This drive to decouple the code from its highly dependent objects leads to the concept of Dependency Injection.&lt;br /&gt;
&lt;br /&gt;
= Definition =&lt;br /&gt;
The basic concept of Dependency Injection(DI) is that you do not create the objects themselves, but describe how they should be created. It is one of the more popular design paradigms known today, by which the objects define their dependencies, i.e. the objects or classes they work with. DI pattern provides better a software design that makes the code cleaner, since the object doesn’t need to look for other components it works with, or know their location and class.[http://www.springframework.net/doc-latest/reference/html/objects.html#objects-factory-collaborators]&lt;br /&gt;
It facilitates the design of applications, using a framework that links the components, instead of the components linking themselves.  &lt;br /&gt;
&lt;br /&gt;
In other words, Dependency Injection, also known as Inversion Of Control(IoC), transfers the responsibility to locate and create the objects to the framework or the container which supports plug-n-play implementation, by injecting the dependencies into your code.&lt;br /&gt;
&lt;br /&gt;
= Features of Dependency Injection =&lt;br /&gt;
Main features of Dependency Injection Framework are:&lt;br /&gt;
* Better Design Pattern - Supports good Object-Oriented Design.&lt;br /&gt;
* Clean Code- Eliminates the need of looking up code from the application.&lt;br /&gt;
* Reuse - Promotes better code reusability.&lt;br /&gt;
* Loose Coupling- Objects are loosely coupled using DI&lt;br /&gt;
* Simple- It is very simple to implement, just need to inject the dependencies of any object.&lt;br /&gt;
* Maintainable- It is very easy to reconfigure and maintain in case of any future changes.&lt;br /&gt;
* More Testable- It makes it very easy to test the code, as objects get instantiated with values using configuration files.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Dependency Injection Frameworks =&lt;br /&gt;
Dependency Injection requires a framework that helps the developer to declare the dependencies, to locate, instantiate, and initialize the components or the objects. A developer has many available frameworks to him:&lt;br /&gt;
* '''Spring Framework''' – A light weight container, most widely used for DI and very large framework, which includes a lot many other features like Aspect Oriented, framework, container, etc. along with Dependency Injection.[http://www.springsource.org/]&lt;br /&gt;
* '''XWork''' -  It is a standalone framework and mostly works in conjunction with Webworks. It is a highly effective command pattern framework that provides a lot of features for DI.[http://www.opensymphony.com/xwork/]&lt;br /&gt;
* '''Apache Avalon'''- This is also a container framework which supports the dependency injection design pattern. This frameworks is now divided into sub-frameworks.[http://excalibur.apache.org/framework/index.html]&lt;br /&gt;
* '''PicoContainer''' - It is a highly focused DI framework available.[http://www.picocontainer.org/]&lt;br /&gt;
* '''Hivelogic''' – Another DI framework to inject dependencies.[http://hivelogic.com/]&lt;br /&gt;
&lt;br /&gt;
== Example of Dependency Injection Framework ==&lt;br /&gt;
&lt;br /&gt;
Let us consider a simple example to understand the basic idea of DI.&lt;br /&gt;
Suppose we have an Employee class which depends on the Department object. We need some Assembler (DI Framework) to instantiate the Department field of Employee class. Rather than Employee class creating this object for itself, it will delegate this task of instantiation to any framework selected from above. To do this, it uses configuration files, which are mostly .xml files. We will see comprehensive example using the framework in the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch5_5e_dr#Types_of_Dependency_Injection section 4]. &lt;br /&gt;
&lt;br /&gt;
 '''''Employee.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class Employee&lt;br /&gt;
  {&lt;br /&gt;
         //dependent object ‘dept'&lt;br /&gt;
         private Department dept;&lt;br /&gt;
         public void Employee( ){ }  &lt;br /&gt;
         &lt;br /&gt;
         setDepartment(dept){&lt;br /&gt;
             this.dept=dept;&lt;br /&gt;
         }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
 '''''Department.java'''''&lt;br /&gt;
  package myPackage;&lt;br /&gt;
  public class Department&lt;br /&gt;
   {&lt;br /&gt;
      private String name; &lt;br /&gt;
      public String getName(){&lt;br /&gt;
          return name;&lt;br /&gt;
       }&lt;br /&gt;
      public void setName(String name){&lt;br /&gt;
          this.name=name;&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
The framework will instantiate the Department object by looking into the configuration file for any existing dependencies of Employee object. It will form an Employee object with a Department instance. For example, in Spring Framework, the configuration file will be ApplicationContext.xml, where the binding of beans is done as follows:&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationContext.xml'''''&lt;br /&gt;
 &amp;lt;beans&amp;gt;&lt;br /&gt;
      &amp;lt;bean id=&amp;quot;employee&amp;quot; class=&amp;quot; myPackage .Employee.java&amp;quot;&amp;gt;&lt;br /&gt;
     	   &amp;lt;property name=&amp;quot;name &amp;quot; ref=&amp;quot;yetAnotherBean&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/bean&amp;gt;&lt;br /&gt;
      &amp;lt;bean id=&amp;quot;department&amp;quot; class=&amp;quot; myPackage .Department.java&amp;quot;&amp;gt;     	&lt;br /&gt;
  	   &amp;lt;property name=&amp;quot;name&amp;quot; value=&amp;quot;Java&amp;quot;/&amp;gt;      &lt;br /&gt;
      &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
thereby creating the dependency diagram as: &amp;lt;br&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
[[Image:Di_image1.png]]&lt;br /&gt;
&lt;br /&gt;
Here we can see that, the classes themselves do not create their own instances, but it is the framework that does this job for them, making the code cleaner, reusable and loosely coupled. In future if one wants to add on, delete or modify any of the dependent objects, one only needs to update the configuration file. There is no need to look up the code all over again to find the class’s dependent objects. One can make modifications to the lines of code creating instances, which may be,&lt;br /&gt;
		&lt;br /&gt;
  // used everywhere in code without Dependency Injection.&lt;br /&gt;
  Department dept=new Department ();  &lt;br /&gt;
&lt;br /&gt;
Thus it makes our code configurable and maintainable. &lt;br /&gt;
Let us now move on and see some more examples to understand the different types of injections available within different frameworks.&lt;br /&gt;
&lt;br /&gt;
= Types of Dependency Injection =&lt;br /&gt;
&lt;br /&gt;
There are a number of Dependency Injection variants that exists to allow the developer to implement and write loosely coupled code. The dependencies can be injected in various forms like: &lt;br /&gt;
* Type 1- Interface Injection&lt;br /&gt;
* Type 2- Setter Injection&lt;br /&gt;
* Type 3- Constructor Injection&lt;br /&gt;
&lt;br /&gt;
== Type 1- Interface Injection ==&lt;br /&gt;
&lt;br /&gt;
Interface injection is a technique to add the dependency for interfaces in components at run time. The components implement these interfaces based on the injected dependency. Spring framework does not support interface injection, so let us see this injection by using the Avalon framework.&lt;br /&gt;
&lt;br /&gt;
For example, we have an ApplicationDAO interface, while AccountApplicationDAO and  CustomerApplicationDAO are the classes implementing ApplicationDAO, &lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public interface ApplicationDAO&lt;br /&gt;
   {&lt;br /&gt;
       void getEntity();&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
 '''''AccountApplicationDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class AccountApplicationDAO implements ApplicationDAO&lt;br /&gt;
 {&lt;br /&gt;
        void getEntity(){&lt;br /&gt;
             //get all accounts.&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
 '''''CustomerApplicationDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class CustomerApplicationDAO implements ApplicationDAO&lt;br /&gt;
 {&lt;br /&gt;
        void getEntity()&lt;br /&gt;
        {&lt;br /&gt;
               //get all customers.&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We also have ApplicationService interface, which depends on the ApplicationDAO interface. The ApplicationServiceImpl class implements the ApplicationService inteface, which in turn implements the ApplicationDAO interface, provided by the container.&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationService.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public interface ApplicationService&lt;br /&gt;
 {&lt;br /&gt;
       getEntity(ApplicationDAO applicationDAO);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationServiceImpl.java'''''&lt;br /&gt;
  package myPackage;&lt;br /&gt;
 public class ApplicationServiceImpl implements ApplicationService &lt;br /&gt;
  {&lt;br /&gt;
        ApplicationDAO applicationDAO;&lt;br /&gt;
        validateEntity (ApplicationDAO applicationDAO)&lt;br /&gt;
         {&lt;br /&gt;
                this. applicationDAO= applicationDAO;&lt;br /&gt;
                applicationDAO.getEntity();&lt;br /&gt;
                //code to validate the Entity (Account/Customer),as per the configuration in xml file.&lt;br /&gt;
          }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
Now, our main program will get the interface dependency from the container, which uses configuration file for look up, &lt;br /&gt;
&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class MyClass&lt;br /&gt;
 {&lt;br /&gt;
        public static void main(string[] args)&lt;br /&gt;
        {&lt;br /&gt;
            // Get the correct dependency based on configuration file&lt;br /&gt;
            ApplicationDAO dependencyDAO = getDependecny();&lt;br /&gt;
 &lt;br /&gt;
            // Create our applicationServiceImpl class and inject the dependency&lt;br /&gt;
 	    ApplicationServiceImpl applicationServiceImpl = new ApplicationServiceImpl();&lt;br /&gt;
            // call validateEntity()&lt;br /&gt;
            ((ApplicationService)applicationServiceImpl).validateEntity(dependencyDAO);&lt;br /&gt;
 &lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        public static ApplicationDAO getDependency()&lt;br /&gt;
        {&lt;br /&gt;
            string implementClass =  &lt;br /&gt;
                                    System.Configuration.ConfigurationManager.AppSettings[&amp;quot;selectedClass&amp;quot;];&lt;br /&gt;
            Type type = System.Type.GetType(implementClass);&lt;br /&gt;
            ApplicationDAO applicationDAO = (ApplicationDAO)Activator.CreateInstance(type);&lt;br /&gt;
             &lt;br /&gt;
            return applicationDAO;&lt;br /&gt;
        }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
The Configuration File that will be used by MyClass file to lookup the dependency configurations will be of type:&lt;br /&gt;
&lt;br /&gt;
 '''''App.Config'''''&lt;br /&gt;
 &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
 &amp;lt;configuration&amp;gt;&lt;br /&gt;
      &amp;lt;appSettings&amp;gt;&lt;br /&gt;
            &amp;lt;add key=&amp;quot; selectedClass &amp;quot; value=&amp;quot;myPackage. AccountApplicationDAO &amp;quot; /&amp;gt;&lt;br /&gt;
       &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
 &amp;lt;/configuration&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
In this example, validateEntity() in ApplicationServiceImpl will call getEntity() using  &lt;br /&gt;
ApplicationDAO reference. The getEntity() that is invoked will actually depend on the dependency that is injected via the configuration file.&lt;br /&gt;
&lt;br /&gt;
==Type 2- Setter Injection==&lt;br /&gt;
&lt;br /&gt;
Dependency can be injected using the setter method of a class. If a class is dependent on another class or object instances, then the dependency should be declared as a state(variable) of the class and the class should have a setter method for it. The dependencies are set onto public attributes of the object in need. One of the primary motive for using setters, is supporting dependency injection without having to modify the constructor of a legacy class. Another use is to allow the creation of expensive resources or services as late as possible and only when needed, which is an edge over the Constructor Injection, which we will see in few moments.&lt;br /&gt;
&lt;br /&gt;
Let us consider an example of Setter injection by using Spring Framework.[3] Before using Spring, let us study some basic features of Spring. We will cover only a brief overview of the Spring Framework. &lt;br /&gt;
&lt;br /&gt;
* Spring is a lightweight container which along with supporting features like Dependency Injection, also include other ones as:  Container, Framework, AOP[http://static.springsource.org/spring/docs/2.5.x/reference/aop.html], MVC, etc. &lt;br /&gt;
* Spring Framework supports both Setter Injection and Constructor Injection, but not Interface Injection. Spring jars that can be included are : &lt;br /&gt;
** spring-beans.jar&lt;br /&gt;
** spring-core.jar&lt;br /&gt;
* Packages that provide Spring Frameworks’s IoC container are:&lt;br /&gt;
** org.springframeworks.beans&lt;br /&gt;
** org.springframeworks.context&lt;br /&gt;
&lt;br /&gt;
Now let us see Setter injection using the Spring framework.&lt;br /&gt;
The example below includes a class, DoctorService. The DoctorService class needs a data-access object for communicating with the database. Assume, the PrescriptionDAO (&amp;quot;order data-access object&amp;quot;) is the class on which DoctorService depends. &amp;lt;br&amp;gt;[[image:di_image2.png]] &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 '''''DoctorService.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class DoctorService&lt;br /&gt;
 {&lt;br /&gt;
       private PrescriptionDAO prescriptionDAO;&lt;br /&gt;
       //empty constructor&lt;br /&gt;
       public DoctorService () {}&lt;br /&gt;
       public PrescriptionDAO getPrescriptionDAO() &lt;br /&gt;
       { &lt;br /&gt;
              return this.prescriptionDAO;&lt;br /&gt;
       }&lt;br /&gt;
       //setter for prescriptionDAO&lt;br /&gt;
       public setPrescriptionDAO(prescriptionDAO) &lt;br /&gt;
       { &lt;br /&gt;
              this.prescriptionDAO = prescriptionDAO; &lt;br /&gt;
       }&lt;br /&gt;
       //business logic that actually uses prescriptionDAOto access its variables and methods.&lt;br /&gt;
       public void print()&lt;br /&gt;
       {&lt;br /&gt;
              System.out.println(“prescription: “+prescriptionDAO.prescription);&lt;br /&gt;
              System.out.println(“dose: “+prescriptionDAO.dose);&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
 '''''PrescriptionDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class PrescriptionDAO&lt;br /&gt;
 {&lt;br /&gt;
        private String prescription;&lt;br /&gt;
        private int dose;&lt;br /&gt;
        public PrescriptionDAO(){}&lt;br /&gt;
        public String getPrescription () &lt;br /&gt;
        {&lt;br /&gt;
                return  this.prescription;&lt;br /&gt;
        }&lt;br /&gt;
        public void setPrescription(String prescription) &lt;br /&gt;
        {&lt;br /&gt;
           this. prescription = prescription;&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, the invoking object is responsible for setting the PrescriptionDAO dependency. There is no code inside the class that is creating new instance of PrescriptionDAO. This is because this task will be performed by the Spring container, by looking for dependencies of DoctorService inside applicationContext.xml file.&lt;br /&gt;
&lt;br /&gt;
The Spring framework uses a setter method to create this dependent object. Note the &amp;lt;property&amp;gt; tag which is used inside ApplicationContext.xml file for setter injection. &lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationContext.xml'''''&lt;br /&gt;
 &amp;lt;beans xmlns=&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;br /&gt;
    xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;br /&gt;
    xmlns:p=&amp;quot;http://www.springframework.org/schema/p&amp;quot;&lt;br /&gt;
    xsi:schemaLocation=&amp;quot;http://www.springframework.org/schema/beans&lt;br /&gt;
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&amp;quot;&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
       &amp;lt;bean id=&amp;quot;doctorServiceId &amp;quot; class=&amp;quot;myPackage.DoctorService&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;!-- setter injection using the nested &amp;lt;ref/&amp;gt; element --&amp;gt;&lt;br /&gt;
                  &amp;lt;property name=&amp;quot; prescriptionDAO &amp;quot;&amp;gt;&amp;lt;ref bean=&amp;quot; prescriptionDAOId &amp;quot;/&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
       &amp;lt;/bean&amp;gt;&lt;br /&gt;
       &amp;lt;bean id=&amp;quot; prescriptionDAOId&amp;quot;  class=&amp;quot; myPackage.PrescriptionDAO &amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;prescription&amp;quot; value=&amp;quot;Take medicine regularly.&amp;quot;/&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;dose&amp;quot; value=&amp;quot;3&amp;quot;/&amp;gt;&lt;br /&gt;
       &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, Client is a class that is used to instantiate the Spring Container and retrieve the bean definitions from inside.&lt;br /&gt;
&lt;br /&gt;
 '''''MyClient.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 import java.io;&lt;br /&gt;
 import org.springframework.beans.factory.*;&lt;br /&gt;
 import org.springframework.beans.factory.xml.*;&lt;br /&gt;
 import org.springframework.core.io;&lt;br /&gt;
 public class MyClient&lt;br /&gt;
 {&lt;br /&gt;
    public static void main(String args[])&lt;br /&gt;
        {&lt;br /&gt;
                Resource res=new ClassPathResource(“./myPackage/ ApplicationContext.xml”);&lt;br /&gt;
                BeanFactory factory =new XmlBeanFactory(res); &lt;br /&gt;
                //” doctorServiceId” is the same id defined in ApplicationContext.xml&lt;br /&gt;
                DoctorService doctorService= (DoctorService) factory.getBean(“doctorServiceId”);&lt;br /&gt;
         }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Here, first the path for the ApplicationContext is specified, and then this file is used as a resource by the container. The BeanFactory container uses the xml file to access the bean defined inside the configuration file.&lt;br /&gt;
&lt;br /&gt;
However, Setter Injection unnecessarily adds to the abstraction. The developer needs to know which dependencies are needed when. On the other hand, it can save on modifying a lot of legacy code when introducing new methods, and can provide a performance boost if the dependency is expensive or not easily accessible.&lt;br /&gt;
&lt;br /&gt;
==Type 3- Constructor Injection==&lt;br /&gt;
&lt;br /&gt;
Constructor Injection is the DI technique of passing an object's dependencies to its constructor. It addresses the most common scenario where a class requires one or more Dependencies, and no reasonable local defaults are available.&lt;br /&gt;
&lt;br /&gt;
Constructor Injection addresses this scenario very well, because it guarantees that the Dependency is always present. If the depending class absolutely cannot function without the Dependency, such a guarantee is valuable. Constructor-injection enforces the order of initialization and prevents circular dependencies [http://en.wikipedia.org/wiki/Circular_dependency]. &lt;br /&gt;
On the other hand, with Setter injection, it is not clear, in which order things need to be instantiated. Apart from the guaranteed injection, this pattern is also very easy to implement. &lt;br /&gt;
&lt;br /&gt;
Continuing with the example mentioned above, we can implement the same using constructor injection as follows, &amp;lt;br&amp;gt; [[image:di_image3.png]] &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 '''''DoctorService.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class DoctorService&lt;br /&gt;
 {&lt;br /&gt;
      private PrescriptionDAO prescriptionDAO;&lt;br /&gt;
      // constructor for instantiatng prescriptionDAO&lt;br /&gt;
      public DoctorService (prescriptionDAO)&lt;br /&gt;
         { &lt;br /&gt;
            this.prescriptionDAO = prescriptionDAO; &lt;br /&gt;
         }&lt;br /&gt;
         //business logic that actually uses prescriptionDAOto access its variables and methods.&lt;br /&gt;
          public void print()&lt;br /&gt;
          {	&lt;br /&gt;
               System.out.println(&amp;quot;prescription:&amp;quot; +prescriptionDAO.prescription);&lt;br /&gt;
               System.out.println(&amp;quot;dose: &amp;quot;+prescriptionDAO.dose); &lt;br /&gt;
          }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
In the example, you must have noticed the parametrized constructor which Spring framework uses to instantiate the value of prescriptionDAO. &lt;br /&gt;
Now, the question is- how Spring container will come to know whether it has to use Constructor injection or Setter Injection? Tags inside the &amp;lt;bean&amp;gt; tag will specify this:&lt;br /&gt;
* &amp;lt;property&amp;gt; tag   is used for Setter Injection&lt;br /&gt;
* &amp;lt;constructor-arg&amp;gt; is used for Constructor Injection.&lt;br /&gt;
&lt;br /&gt;
ApplicationContect.xml for Constructor injection will be:&lt;br /&gt;
 '''''ApplicationContect.xml'''''&lt;br /&gt;
 &amp;lt;beans xmlns=&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;br /&gt;
    xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;br /&gt;
    xmlns:p=&amp;quot;http://www.springframework.org/schema/p&amp;quot;&lt;br /&gt;
    xsi:schemaLocation=&amp;quot;http://www.springframework.org/schema/beans&lt;br /&gt;
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;bean id=&amp;quot;doctorServiceId &amp;quot; class=&amp;quot;myPackage.DoctorService&amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;lt;!-- constructor injection using the nested &amp;lt;ref/&amp;gt; element --&amp;gt;&lt;br /&gt;
 		 &amp;lt;constructor-arg&amp;gt;&lt;br /&gt;
                 &amp;lt;ref bean=&amp;quot; prescriptionDAOId &amp;quot;/&amp;gt;&lt;br /&gt;
                 &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;
          &amp;lt;/bean&amp;gt;&lt;br /&gt;
          &amp;lt;bean id=&amp;quot; prescriptionDAOId&amp;quot;  class=&amp;quot; myPackage.PrescriptionDAO &amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;prescription&amp;quot; value=&amp;quot;Take medicine regularly.&amp;quot;/&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;dose&amp;quot; value=&amp;quot;3&amp;quot;/&amp;gt;&lt;br /&gt;
          &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Definitions for PrescriptionDAO.java and MyClient.java will remain the same.&lt;br /&gt;
The advantage of using Constructor Injection is that it can create the objects at the time of instantiation itself. Hence it guarantees the developer, that the objects will definitely get created and no exception will be raised. &lt;br /&gt;
&lt;br /&gt;
However, unlike [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch5_5e_dr#Type_2-_Setter_Injection Setter injection] it won’t allow changes to the dependency, once it is created.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Advantages and Disadvantages=&lt;br /&gt;
&lt;br /&gt;
Advantage of using Dependency injection are &lt;br /&gt;
* Clean code which helps to separate out the logic and the instantiation modules. &lt;br /&gt;
* It is also easy to maintain the code with the use of configuration files where we can make changes in future whenever required. &lt;br /&gt;
* It is very easy to test the code using Dependency Injection.&lt;br /&gt;
* It makes the code more readable.&lt;br /&gt;
&lt;br /&gt;
But the down side of Dependency Injection are that, &lt;br /&gt;
* It is not quite easy to understand the code for developers as there seems to be an abstraction layer which is performing initializing and instantiation of objects. &lt;br /&gt;
* Moreover, developers should have an expertise in coding such design patterns.&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
Hence, Dependency Injection design pattern is good enough to implement in the enterprise applications of large scale, as it helps in reusability, maintainability and testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References and Notes =&lt;br /&gt;
[1] [Spring in Action by Craig Walls, Ryan Briedenbach]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [Java Development with Spring Framework,  by Rod Johnson, Juergen Hoeller, Alef Arendsen, Thomas Risberg, Colin Sampaleanu]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://www.springsource.org/ Spring Framework]&amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://www.opensymphony.com/xwork/ Xwork]&amp;lt;br&amp;gt;&lt;br /&gt;
[8] [http://static.springsource.org/spring/docs/2.5.x/reference/aop.html Aspect Oriented Programming]&amp;lt;br&amp;gt;&lt;br /&gt;
[9] [http://en.wikipedia.org/wiki/Circular_dependency Circular Dependency]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
External Links&lt;br /&gt;
[1] [http://www.codeproject.com/KB/architecture/DependencyInjection.aspx Dependency Injection for Loose Coupling]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [http://www.springframework.net/doc-latest/reference/html/objects.html#objects-factory-collaborators Dependency injection]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://excalibur.apache.org/framework/index.html Excalibur Apache Avalon]&amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://www.picocontainer.org/ PicoContainer]&amp;lt;br&amp;gt;&lt;br /&gt;
[5] [http://hivelogic.com/ Hivelogic]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Further Reading =&lt;br /&gt;
[1] [Dependency Injection in .NET by Mark Seemann]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [Dependency Injection by Dhanji R Prassanna]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://www.developer.com/net/csharp/article.php/3722931/Dependency-Injection-with-SpringNet.htm Dependency Injection with Spring .NET] &amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://needle.rubyforge.org/api/ Dependency Injection in Ruby]&lt;br /&gt;
[5] [http://onestepback.org/index.cgi/Tech/Ruby/DependencyInjectionInRuby.rdoc ]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5e_dr&amp;diff=40002</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5e dr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5e_dr&amp;diff=40002"/>
		<updated>2010-11-03T22:05:22Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Dependency Injection'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
Every enterprise application involves handful number of objects that work together to achieve some purpose. These objects are coupled with each other and work in collaboration, making the classes highly dependent. However, creating such code involving highly coupled classes defeats an important tenet of Object oriented design- ‘loose coupling’. Loose coupling means that objects should have the minimum number of dependencies, which makes the code easy to understand, modify and debug. It also allows for greater code reusability and improves the maintainability.[http://www.codeproject.com/KB/architecture/DependencyInjection.aspx] This drive to decouple the code from its highly dependent objects leads to the concept of Dependency Injection.&lt;br /&gt;
&lt;br /&gt;
= Definition =&lt;br /&gt;
The basic concept of Dependency Injection(DI) is that you do not create the objects themselves, but describe how they should be created. It is one of the more popular design paradigms known today, by which the objects define their dependencies, i.e. the objects or classes they work with. DI pattern provides better a software design that makes the code cleaner, since the object doesn’t need to look for other components it works with, or know their location and class.[http://www.springframework.net/doc-latest/reference/html/objects.html#objects-factory-collaborators]&lt;br /&gt;
It facilitates the design of applications, using a framework that links the components, instead of the components linking themselves.  &lt;br /&gt;
&lt;br /&gt;
In other words, Dependency Injection, also known as Inversion Of Control(IoC), transfers the responsibility to locate and create the objects to the framework or the container which supports plug-n-play implementation, by injecting the dependencies into your code.&lt;br /&gt;
&lt;br /&gt;
= Features of Dependency Injection =&lt;br /&gt;
Main features of Dependency Injection Framework are:&lt;br /&gt;
* Better Design Pattern - Supports good Object-Oriented Design.&lt;br /&gt;
* Clean Code- Eliminates the need of looking up code from the application.&lt;br /&gt;
* Reuse - Promotes better code reusability.&lt;br /&gt;
* Loose Coupling- Objects are loosely coupled using DI&lt;br /&gt;
* Simple- It is very simple to implement, just need to inject the dependencies of any object.&lt;br /&gt;
* Maintainable- It is very easy to reconfigure and maintain in case of any future changes.&lt;br /&gt;
* More Testable- It makes it very easy to test the code, as objects get instantiated with values using configuration files.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Dependency Injection Frameworks =&lt;br /&gt;
Dependency Injection requires a framework that helps the developer to declare the dependencies, to locate, instantiate, and initialize the components or the objects. A developer has many available frameworks to him:&lt;br /&gt;
* '''Spring Framework''' – A light weight container, most widely used for DI and very large framework, which includes a lot many other features like Aspect Oriented, framework, container, etc. along with Dependency Injection.[http://www.springsource.org/]&lt;br /&gt;
* '''XWork''' -  It is a standalone framework and mostly works in conjunction with Webworks. It is a highly effective command pattern framework that provides a lot of features for DI.[http://www.opensymphony.com/xwork/]&lt;br /&gt;
* '''Apache Avalon'''- This is also a container framework which supports the dependency injection design pattern. This frameworks is now divided into sub-frameworks.[http://excalibur.apache.org/framework/index.html]&lt;br /&gt;
* '''PicoContainer''' - It is a highly focused DI framework available.[http://www.picocontainer.org/]&lt;br /&gt;
* '''Hivelogic''' – Another DI framework to inject dependencies.[http://hivelogic.com/]&lt;br /&gt;
&lt;br /&gt;
== Example of Dependency Injection Framework ==&lt;br /&gt;
&lt;br /&gt;
Let us consider a simple example to understand the basic idea of DI.&lt;br /&gt;
Suppose we have an Employee class which depends on the Department object. We need some Assembler (DI Framework) to instantiate the Department field of Employee class. Rather than Employee class creating this object for itself, it will delegate this task of instantiation to any framework selected from above. To do this, it uses configuration files, which are mostly .xml files. We will see comprehensive example using the framework in the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch5_5e_dr#Types_of_Dependency_Injection section 4]. &lt;br /&gt;
&lt;br /&gt;
 '''''Employee.java'''''&lt;br /&gt;
&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class Employee&lt;br /&gt;
  {&lt;br /&gt;
         //dependent object ‘dept'&lt;br /&gt;
         private Department dept;&lt;br /&gt;
         public void Employee( ){ }  &lt;br /&gt;
         &lt;br /&gt;
         setDepartment(dept){&lt;br /&gt;
             this.dept=dept;&lt;br /&gt;
         }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
 '''''Department.java'''''&lt;br /&gt;
&lt;br /&gt;
  package myPackage;&lt;br /&gt;
  public class Department&lt;br /&gt;
   {&lt;br /&gt;
      private String name; &lt;br /&gt;
      public String getName(){&lt;br /&gt;
          return name;&lt;br /&gt;
       }&lt;br /&gt;
      public void setName(String name){&lt;br /&gt;
          this.name=name;&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
The framework will instantiate the Department object by looking into the configuration file for any existing dependencies of Employee object. It will form an Employee object with a Department instance. For example, in Spring Framework, the configuration file will be ApplicationContext.xml, where the binding of beans is done as follows:&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationContext.xml'''''&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;beans&amp;gt;&lt;br /&gt;
      &amp;lt;bean id=&amp;quot;employee&amp;quot; class=&amp;quot; myPackage .Employee.java&amp;quot;&amp;gt;&lt;br /&gt;
     	   &amp;lt;property name=&amp;quot;name &amp;quot; ref=&amp;quot;yetAnotherBean&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/bean&amp;gt;&lt;br /&gt;
      &amp;lt;bean id=&amp;quot;department&amp;quot; class=&amp;quot; myPackage .Department.java&amp;quot;&amp;gt;     	&lt;br /&gt;
  	   &amp;lt;property name=&amp;quot;name&amp;quot; value=&amp;quot;Java&amp;quot;/&amp;gt;      &lt;br /&gt;
      &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
thereby creating the dependency diagram as: &amp;lt;br&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
[[Image:Di_image1.png]]&lt;br /&gt;
&lt;br /&gt;
Here we can see that, the classes themselves do not create their own instances, but it is the framework that does this job for them, making the code cleaner, reusable and loosely coupled. In future if one wants to add on, delete or modify any of the dependent objects, one only needs to update the configuration file. There is no need to look up the code all over again to find the class’s dependent objects. One can make modifications to the lines of code creating instances, which may be,&lt;br /&gt;
		&lt;br /&gt;
  // used everywhere in code without Dependency Injection.&lt;br /&gt;
  Department dept=new Department ();  &lt;br /&gt;
&lt;br /&gt;
Thus it makes our code configurable and maintainable. &lt;br /&gt;
Let us now move on and see some more examples to understand the different types of injections available within different frameworks.&lt;br /&gt;
&lt;br /&gt;
= Types of Dependency Injection =&lt;br /&gt;
&lt;br /&gt;
There are a number of Dependency Injection variants that exists to allow the developer to implement and write loosely coupled code. The dependencies can be injected in various forms like: &lt;br /&gt;
* Type 1- Interface Injection&lt;br /&gt;
* Type 2- Setter Injection&lt;br /&gt;
* Type 3- Constructor Injection&lt;br /&gt;
&lt;br /&gt;
== Type 1- Interface Injection ==&lt;br /&gt;
&lt;br /&gt;
Interface injection is a technique to add the dependency for interfaces in components at run time. The components implement these interfaces based on the injected dependency. Spring framework does not support interface injection, so let us see this injection by using the Avalon framework.&lt;br /&gt;
&lt;br /&gt;
For example, we have an ApplicationDAO interface, while AccountApplicationDAO and  CustomerApplicationDAO are the classes implementing ApplicationDAO, &lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationDAO.java'''''&lt;br /&gt;
&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public interface ApplicationDAO&lt;br /&gt;
   {&lt;br /&gt;
       void getEntity();&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
 '''''AccountApplicationDAO.java'''''&lt;br /&gt;
&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class AccountApplicationDAO implements ApplicationDAO&lt;br /&gt;
 {&lt;br /&gt;
        void getEntity(){&lt;br /&gt;
             //get all accounts.&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
 '''''CustomerApplicationDAO.java'''''&lt;br /&gt;
&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class CustomerApplicationDAO implements ApplicationDAO&lt;br /&gt;
 {&lt;br /&gt;
        void getEntity()&lt;br /&gt;
        {&lt;br /&gt;
               //get all customers.&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
We also have ApplicationService interface, which depends on the ApplicationDAO interface. The ApplicationServiceImpl class implements the ApplicationService inteface, which in turn implements the ApplicationDAO interface, provided by the container.&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationService.java'''''&lt;br /&gt;
&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public interface ApplicationService&lt;br /&gt;
 {&lt;br /&gt;
       getEntity(ApplicationDAO applicationDAO);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationServiceImpl.java'''''&lt;br /&gt;
 &lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class ApplicationServiceImpl implements ApplicationService &lt;br /&gt;
  {&lt;br /&gt;
        ApplicationDAO applicationDAO;&lt;br /&gt;
        validateEntity (ApplicationDAO applicationDAO)&lt;br /&gt;
         {&lt;br /&gt;
                this. applicationDAO= applicationDAO;&lt;br /&gt;
                applicationDAO.getEntity();&lt;br /&gt;
                //code to validate the Entity (Account/Customer),as per the configuration in xml file.&lt;br /&gt;
          }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
Now, our main program will get the interface dependency from the container, which uses configuration file for look up, &lt;br /&gt;
&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class MyClass&lt;br /&gt;
 {&lt;br /&gt;
        public static void main(string[] args)&lt;br /&gt;
        {&lt;br /&gt;
            // Get the correct dependency based on configuration file&lt;br /&gt;
            ApplicationDAO dependencyDAO = getDependecny();&lt;br /&gt;
 &lt;br /&gt;
            // Create our applicationServiceImpl class and inject the dependency&lt;br /&gt;
 	    ApplicationServiceImpl applicationServiceImpl = new ApplicationServiceImpl();&lt;br /&gt;
            // call validateEntity()&lt;br /&gt;
            ((ApplicationService)applicationServiceImpl).validateEntity(dependencyDAO);&lt;br /&gt;
 &lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        public static ApplicationDAO getDependency()&lt;br /&gt;
        {&lt;br /&gt;
            string implementClass =  &lt;br /&gt;
                                    System.Configuration.ConfigurationManager.AppSettings[&amp;quot;selectedClass&amp;quot;];&lt;br /&gt;
            Type type = System.Type.GetType(implementClass);&lt;br /&gt;
            ApplicationDAO applicationDAO = (ApplicationDAO)Activator.CreateInstance(type);&lt;br /&gt;
             &lt;br /&gt;
            return applicationDAO;&lt;br /&gt;
        }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
The Configuration File that will be used by MyClass file to lookup the dependency configurations will be of type:&lt;br /&gt;
&lt;br /&gt;
 '''''App.Config'''''&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
 &amp;lt;configuration&amp;gt;&lt;br /&gt;
      &amp;lt;appSettings&amp;gt;&lt;br /&gt;
            &amp;lt;add key=&amp;quot; selectedClass &amp;quot; value=&amp;quot;myPackage. AccountApplicationDAO &amp;quot; /&amp;gt;&lt;br /&gt;
       &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
 &amp;lt;/configuration&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
In this example, validateEntity() in ApplicationServiceImpl will call getEntity() using  &lt;br /&gt;
ApplicationDAO reference. The getEntity() that is invoked will actually depend on the dependency that is injected via the configuration file.&lt;br /&gt;
&lt;br /&gt;
==Type 2- Setter Injection==&lt;br /&gt;
&lt;br /&gt;
Dependency can be injected using the setter method of a class. If a class is dependent on another class or object instances, then the dependency should be declared as a state(variable) of the class and the class should have a setter method for it. The dependencies are set onto public attributes of the object in need. One of the primary motive for using setters, is supporting dependency injection without having to modify the constructor of a legacy class. Another use is to allow the creation of expensive resources or services as late as possible and only when needed, which is an edge over the Constructor Injection, which we will see in few moments.&lt;br /&gt;
&lt;br /&gt;
Let us consider an example of Setter injection by using Spring Framework.[3] Before using Spring, let us study some basic features of Spring. We will cover only a brief overview of the Spring Framework. &lt;br /&gt;
&lt;br /&gt;
* Spring is a lightweight container which along with supporting features like Dependency Injection, also include other ones as:  Container, Framework, AOP[http://static.springsource.org/spring/docs/2.5.x/reference/aop.html], MVC, etc. &lt;br /&gt;
* Spring Framework supports both Setter Injection and Constructor Injection, but not Interface Injection. Spring jars that can be included are : &lt;br /&gt;
** spring-beans.jar&lt;br /&gt;
** spring-core.jar&lt;br /&gt;
* Packages that provide Spring Frameworks’s IoC container are:&lt;br /&gt;
** org.springframeworks.beans&lt;br /&gt;
** org.springframeworks.context&lt;br /&gt;
&lt;br /&gt;
Now let us see Setter injection using the Spring framework.&lt;br /&gt;
The example below includes a class, DoctorService. The DoctorService class needs a data-access object for communicating with the database. Assume, the PrescriptionDAO (&amp;quot;order data-access object&amp;quot;) is the class on which DoctorService depends. &amp;lt;br&amp;gt;[[image:di_image2.png]] &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 '''''DoctorService.java'''''&lt;br /&gt;
&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class DoctorService&lt;br /&gt;
 {&lt;br /&gt;
       private PrescriptionDAO prescriptionDAO;&lt;br /&gt;
       //empty constructor&lt;br /&gt;
       public DoctorService () {}&lt;br /&gt;
       public PrescriptionDAO getPrescriptionDAO() &lt;br /&gt;
       { &lt;br /&gt;
              return this.prescriptionDAO;&lt;br /&gt;
       }&lt;br /&gt;
       //setter for prescriptionDAO&lt;br /&gt;
       public setPrescriptionDAO(prescriptionDAO) &lt;br /&gt;
       { &lt;br /&gt;
              this.prescriptionDAO = prescriptionDAO; &lt;br /&gt;
        }&lt;br /&gt;
       //business logic that actually uses prescriptionDAOto access its variables and methods.&lt;br /&gt;
       public void print()&lt;br /&gt;
       {&lt;br /&gt;
              System.out.println(“prescription: “+prescriptionDAO.prescription);&lt;br /&gt;
              System.out.println(“dose: “+prescriptionDAO.dose);&lt;br /&gt;
        }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
 '''''PrescriptionDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class PrescriptionDAO&lt;br /&gt;
 {&lt;br /&gt;
        private String prescription;&lt;br /&gt;
        private int dose;&lt;br /&gt;
        public PrescriptionDAO(){}&lt;br /&gt;
        public String getPrescription () &lt;br /&gt;
        {&lt;br /&gt;
                return  this.prescription;&lt;br /&gt;
        }&lt;br /&gt;
        public void setPrescription(String prescription) &lt;br /&gt;
        {&lt;br /&gt;
           this. prescription = prescription;&lt;br /&gt;
         }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, the invoking object is responsible for setting the PrescriptionDAO dependency. There is no code inside the class that is creating new instance of PrescriptionDAO. This is because this task will be performed by the Spring container, by looking for dependencies of DoctorService inside applicationContext.xml file.&lt;br /&gt;
&lt;br /&gt;
The Spring framework uses a setter method to create this dependent object. Note the &amp;lt;property&amp;gt; tag which is used inside ApplicationContext.xml file for setter injection. &lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationContext.xml'''''&lt;br /&gt;
 &amp;lt;beans xmlns=&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;br /&gt;
    xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;br /&gt;
    xmlns:p=&amp;quot;http://www.springframework.org/schema/p&amp;quot;&lt;br /&gt;
    xsi:schemaLocation=&amp;quot;http://www.springframework.org/schema/beans&lt;br /&gt;
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&amp;quot;&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
       &amp;lt;bean id=&amp;quot;doctorServiceId &amp;quot; class=&amp;quot;myPackage.DoctorService&amp;quot;&amp;gt;&lt;br /&gt;
                  &amp;lt;!-- setter injection using the nested &amp;lt;ref/&amp;gt; element --&amp;gt;&lt;br /&gt;
                  &amp;lt;property name=&amp;quot; prescriptionDAO &amp;quot;&amp;gt;&amp;lt;ref bean=&amp;quot; prescriptionDAOId &amp;quot;/&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
       &amp;lt;/bean&amp;gt;&lt;br /&gt;
      &amp;lt;bean id=&amp;quot; prescriptionDAOId&amp;quot;  class=&amp;quot; myPackage.PrescriptionDAO &amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;prescription&amp;quot; value=&amp;quot;Take medicine regularly.&amp;quot;/&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;dose&amp;quot; value=&amp;quot;3&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, Client is a class that is used to instantiate the Spring Container and retrieve the bean definitions from inside.&lt;br /&gt;
&lt;br /&gt;
 '''''MyClient.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 import java.io;&lt;br /&gt;
 import org.springframework.beans.factory.*;&lt;br /&gt;
 import org.springframework.beans.factory.xml.*;&lt;br /&gt;
 import org.springframework.core.io;&lt;br /&gt;
 public class MyClient&lt;br /&gt;
 {&lt;br /&gt;
    public static void main(String args[])&lt;br /&gt;
        {&lt;br /&gt;
                Resource res=new ClassPathResource(“./myPackage/ ApplicationContext.xml”);&lt;br /&gt;
                BeanFactory factory =new XmlBeanFactory(res); &lt;br /&gt;
                //” doctorServiceId” is the same id defined in ApplicationContext.xml&lt;br /&gt;
                DoctorService doctorService= (DoctorService) factory.getBean(“doctorServiceId”);&lt;br /&gt;
         }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Here, first the path for the ApplicationContext is specified, and then this file is used as a resource by the container. The BeanFactory container uses the xml file to access the bean defined inside the configuration file.&lt;br /&gt;
&lt;br /&gt;
However, Setter Injection unnecessarily adds to the abstraction. The developer needs to know which dependencies are needed when. On the other hand, it can save on modifying a lot of legacy code when introducing new methods, and can provide a performance boost if the dependency is expensive or not easily accessible.&lt;br /&gt;
&lt;br /&gt;
==Type 3- Constructor Injection==&lt;br /&gt;
&lt;br /&gt;
Constructor Injection is the DI technique of passing an object's dependencies to its constructor. It addresses the most common scenario where a class requires one or more Dependencies, and no reasonable local defaults are available.&lt;br /&gt;
&lt;br /&gt;
Constructor Injection addresses this scenario very well, because it guarantees that the Dependency is always present. If the depending class absolutely cannot function without the Dependency, such a guarantee is valuable. Constructor-injection enforces the order of initialization and prevents circular dependencies [http://en.wikipedia.org/wiki/Circular_dependency]. &lt;br /&gt;
On the other hand, with Setter injection, it is not clear, in which order things need to be instantiated. Apart from the guaranteed injection, this pattern is also very easy to implement. &lt;br /&gt;
&lt;br /&gt;
Continuing with the example mentioned above, we can implement the same using constructor injection as follows, &amp;lt;br&amp;gt; [[image:di_image3.png]] &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 '''''DoctorService.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class DoctorService&lt;br /&gt;
 {&lt;br /&gt;
      private PrescriptionDAO prescriptionDAO;&lt;br /&gt;
    // constructor for instantiatng prescriptionDAO&lt;br /&gt;
      public DoctorService (prescriptionDAO)&lt;br /&gt;
         { &lt;br /&gt;
            this.prescriptionDAO = prescriptionDAO; &lt;br /&gt;
         }&lt;br /&gt;
         //business logic that actually uses prescriptionDAOto access its variables and methods.&lt;br /&gt;
         public void print()&lt;br /&gt;
         {	&lt;br /&gt;
               System.out.println(&amp;quot;prescription:&amp;quot; +prescriptionDAO.prescription);&lt;br /&gt;
               System.out.println(&amp;quot;dose: &amp;quot;+prescriptionDAO.dose); &lt;br /&gt;
         }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
In the example, you must have noticed the parametrized constructor which Spring framework uses to instantiate the value of prescriptionDAO. &lt;br /&gt;
Now, the question is- how Spring container will come to know whether it has to use Constructor injection or Setter Injection? Tags inside the &amp;lt;bean&amp;gt; tag will specify this:&lt;br /&gt;
* &amp;lt;property&amp;gt; tag   is used for Setter Injection&lt;br /&gt;
* &amp;lt;constructor-arg&amp;gt; is used for Constructor Injection.&lt;br /&gt;
&lt;br /&gt;
ApplicationContect.xml for Constructor injection will be:&lt;br /&gt;
 '''''ApplicationContect.xml'''''&lt;br /&gt;
 &amp;lt;beans xmlns=&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;br /&gt;
    xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;br /&gt;
    xmlns:p=&amp;quot;http://www.springframework.org/schema/p&amp;quot;&lt;br /&gt;
    xsi:schemaLocation=&amp;quot;http://www.springframework.org/schema/beans&lt;br /&gt;
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;bean id=&amp;quot;doctorServiceId &amp;quot; class=&amp;quot;myPackage.DoctorService&amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;lt;!-- constructor injection using the nested &amp;lt;ref/&amp;gt; element --&amp;gt;&lt;br /&gt;
 		 &amp;lt;constructor-arg&amp;gt;&lt;br /&gt;
                 &amp;lt;ref bean=&amp;quot; prescriptionDAOId &amp;quot;/&amp;gt;&lt;br /&gt;
                 &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;
         &amp;lt;/bean&amp;gt;&lt;br /&gt;
         &amp;lt;bean id=&amp;quot; prescriptionDAOId&amp;quot;  class=&amp;quot; myPackage.PrescriptionDAO &amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;prescription&amp;quot; value=&amp;quot;Take medicine regularly.&amp;quot;/&amp;gt;&lt;br /&gt;
                 &amp;lt;property name=&amp;quot;dose&amp;quot; value=&amp;quot;3&amp;quot;/&amp;gt;&lt;br /&gt;
          &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Definitions for PrescriptionDAO.java and MyClient.java will remain the same.&lt;br /&gt;
The advantage of using Constructor Injection is that it can create the objects at the time of instantiation itself. Hence it guarantees the developer, that the objects will definitely get created and no exception will be raised. &lt;br /&gt;
&lt;br /&gt;
However, unlike [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch5_5e_dr#Type_2-_Setter_Injection Setter injection] it won’t allow changes to the dependency, once it is created.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Advantages and Disadvantages=&lt;br /&gt;
&lt;br /&gt;
Advantage of using Dependency injection are &lt;br /&gt;
* Clean code which helps to separate out the logic and the instantiation modules. &lt;br /&gt;
* It is also easy to maintain the code with the use of configuration files where we can make changes in future whenever required. &lt;br /&gt;
* It is very easy to test the code using Dependency Injection.&lt;br /&gt;
* It makes the code more readable.&lt;br /&gt;
&lt;br /&gt;
But the down side of Dependency Injection are that, &lt;br /&gt;
* It is not quite easy to understand the code for developers as there seems to be an abstraction layer which is performing initializing and instantiation of objects. &lt;br /&gt;
* Moreover, developers should have an expertise in coding such design patterns.&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
Hence, Dependency Injection design pattern is good enough to implement in the enterprise applications of large scale, as it helps in reusability, maintainability and testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References and Notes =&lt;br /&gt;
[1] [Spring in Action by Craig Walls, Ryan Briedenbach]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [Java Development with Spring Framework,  by Rod Johnson, Juergen Hoeller, Alef Arendsen, Thomas Risberg, Colin Sampaleanu]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://www.springsource.org/ Spring Framework]&amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://www.opensymphony.com/xwork/ Xwork]&amp;lt;br&amp;gt;&lt;br /&gt;
[8] [http://static.springsource.org/spring/docs/2.5.x/reference/aop.html Aspect Oriented Programming]&amp;lt;br&amp;gt;&lt;br /&gt;
[9] [http://en.wikipedia.org/wiki/Circular_dependency Circular Dependency]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
External Links&lt;br /&gt;
[1] [http://www.codeproject.com/KB/architecture/DependencyInjection.aspx Dependency Injection for Loose Coupling]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [http://www.springframework.net/doc-latest/reference/html/objects.html#objects-factory-collaborators Dependency injection]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://excalibur.apache.org/framework/index.html Excalibur Apache Avalon]&amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://www.picocontainer.org/ PicoContainer]&amp;lt;br&amp;gt;&lt;br /&gt;
[5] [http://hivelogic.com/ Hivelogic]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Further Reading =&lt;br /&gt;
[1] [Dependency Injection in .NET by Mark Seemann]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [Dependency Injection by Dhanji R Prassanna]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://www.developer.com/net/csharp/article.php/3722931/Dependency-Injection-with-SpringNet.htm Dependency Injection with Spring .NET] &amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://needle.rubyforge.org/api/ Dependency Injection in Ruby]&lt;br /&gt;
[5] [http://onestepback.org/index.cgi/Tech/Ruby/DependencyInjectionInRuby.rdoc ]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5e_dr&amp;diff=39999</id>
		<title>CSC/ECE 517 Fall 2010/ch5 5e dr</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch5_5e_dr&amp;diff=39999"/>
		<updated>2010-11-03T21:55:16Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;font-size: 24px&amp;quot;&amp;gt;'''Dependency Injection'''&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Overview =&lt;br /&gt;
&lt;br /&gt;
Every enterprise application involves handful number of objects that work together to achieve some purpose. These objects are coupled with each other and work in collaboration, making the classes highly dependent. However, creating such code involving highly coupled classes defeats an important tenet of Object oriented design- ‘loose coupling’. Loose coupling means that objects should have the minimum number of dependencies, which makes the code easy to understand, modify and debug. It also allows for greater code reusability and improves the maintainability.[http://www.codeproject.com/KB/architecture/DependencyInjection.aspx] This drive to decouple the code from its highly dependent objects leads to the concept of Dependency Injection.&lt;br /&gt;
&lt;br /&gt;
= Definition =&lt;br /&gt;
The basic concept of Dependency Injection(DI) is that you do not create the objects themselves, but describe how they should be created. It is one of the more popular design paradigms known today, by which the objects define their dependencies, i.e. the objects or classes they work with. DI pattern provides better a software design that makes the code cleaner, since the object doesn’t need to look for other components it works with, or know their location and class.[http://www.springframework.net/doc-latest/reference/html/objects.html#objects-factory-collaborators]&lt;br /&gt;
It facilitates the design of applications, using a framework that links the components, instead of the components linking themselves.  &lt;br /&gt;
&lt;br /&gt;
In other words, Dependency Injection, also known as Inversion Of Control(IoC), transfers the responsibility to locate and create the objects to the framework or the container which supports plug-n-play implementation, by injecting the dependencies into your code.&lt;br /&gt;
&lt;br /&gt;
= Features of Dependency Injection =&lt;br /&gt;
Main features of Dependency Injection Framework are:&lt;br /&gt;
* Better Design Pattern - Supports good Object-Oriented Design.&lt;br /&gt;
* Clean Code- Eliminates the need of looking up code from the application.&lt;br /&gt;
* Reuse - Promotes better code reusability.&lt;br /&gt;
* Loose Coupling- Objects are loosely coupled using DI&lt;br /&gt;
* Simple- It is very simple to implement, just need to inject the dependencies of any object.&lt;br /&gt;
* Maintainable- It is very easy to reconfigure and maintain in case of any future changes.&lt;br /&gt;
* More Testable- It makes it very easy to test the code, as objects get instantiated with values using configuration files.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Dependency Injection Frameworks =&lt;br /&gt;
Dependency Injection requires a framework that helps the developer to declare the dependencies, to locate, instantiate, and initialize the components or the objects. A developer has many available frameworks to him:&lt;br /&gt;
* '''Spring Framework''' – A light weight container, most widely used for DI and very large framework, which includes a lot many other features like Aspect Oriented, framework, container, etc. along with Dependency Injection.[http://www.springsource.org/]&lt;br /&gt;
* '''XWork''' -  It is a standalone framework and mostly works in conjunction with Webworks. It is a highly effective command pattern framework that provides a lot of features for DI.[http://www.opensymphony.com/xwork/]&lt;br /&gt;
* '''Apache Avalon'''- This is also a container framework which supports the dependency injection design pattern. This frameworks is now divided into sub-frameworks.[http://excalibur.apache.org/framework/index.html]&lt;br /&gt;
* '''PicoContainer''' - It is a highly focused DI framework available.[http://www.picocontainer.org/]&lt;br /&gt;
* '''Hivelogic''' – Another DI framework to inject dependencies.[http://hivelogic.com/]&lt;br /&gt;
&lt;br /&gt;
== Example of Dependency Injection Framework ==&lt;br /&gt;
&lt;br /&gt;
Let us consider a simple example to understand the basic idea of DI.&lt;br /&gt;
Suppose we have an Employee class which depends on the Department object. We need some Assembler (DI Framework) to instantiate the Department field of Employee class. Rather than Employee class creating this object for itself, it will delegate this task of instantiation to any framework selected from above. To do this, it uses configuration files, which are mostly .xml files. We will see comprehensive example using the framework in the [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch5_5e_dr#Types_of_Dependency_Injection section 4]. &lt;br /&gt;
&lt;br /&gt;
 '''''Employee.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class Employee&lt;br /&gt;
  {&lt;br /&gt;
         //dependent object ‘dept'&lt;br /&gt;
         private Department dept;&lt;br /&gt;
         public void Employee( )&lt;br /&gt;
           {  &lt;br /&gt;
           }&lt;br /&gt;
         setDepartment(dept)&lt;br /&gt;
           {&lt;br /&gt;
             this.dept=dept;&lt;br /&gt;
           }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
 '''''Department.java'''''&lt;br /&gt;
  package myPackage;&lt;br /&gt;
  public class Department&lt;br /&gt;
   {&lt;br /&gt;
      private String name; &lt;br /&gt;
      public String getName()&lt;br /&gt;
       {&lt;br /&gt;
          return name;&lt;br /&gt;
       }&lt;br /&gt;
      public void setName(String name)&lt;br /&gt;
       {&lt;br /&gt;
          this.name=name;&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
The framework will instantiate the Department object by looking into the configuration file for any existing dependencies of Employee object. It will form an Employee object with a Department instance. For example, in Spring Framework, the configuration file will be ApplicationContext.xml, where the binding of beans is done as follows:&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationContext.xml'''''&lt;br /&gt;
 &amp;lt;beans&amp;gt;&lt;br /&gt;
    &amp;lt;bean id=&amp;quot;employee&amp;quot; class=&amp;quot; myPackage .Employee.java&amp;quot;&amp;gt;&lt;br /&gt;
     	   &amp;lt;property name=&amp;quot;name &amp;quot; ref=&amp;quot;yetAnotherBean&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/bean&amp;gt;&lt;br /&gt;
     &amp;lt;bean id=&amp;quot;department&amp;quot; class=&amp;quot; myPackage .Department.java&amp;quot;&amp;gt;     	&lt;br /&gt;
  	&amp;lt;property name=&amp;quot;name&amp;quot; value=&amp;quot;Java&amp;quot;/&amp;gt;      &lt;br /&gt;
      &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
thereby creating the dependency diagram as: &amp;lt;br&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
[[Image:Di_image1.png]]&lt;br /&gt;
&lt;br /&gt;
Here we can see that, the classes themselves do not create their own instances, but it is the framework that does this job for them, making the code cleaner, reusable and loosely coupled. In future if one wants to add on, delete or modify any of the dependent objects, one only needs to update the configuration file. There is no need to look up the code all over again to find the class’s dependent objects. One can make modifications to the lines of code creating instances, which may be,&lt;br /&gt;
		&lt;br /&gt;
  // used everywhere in code without Dependency Injection.&lt;br /&gt;
  Department dept=new Department ();  &lt;br /&gt;
&lt;br /&gt;
Thus it makes our code configurable and maintainable. &lt;br /&gt;
Let us now move on and see some more examples to understand the different types of injections available within different frameworks.&lt;br /&gt;
&lt;br /&gt;
= Types of Dependency Injection =&lt;br /&gt;
&lt;br /&gt;
There are a number of Dependency Injection variants that exists to allow the developer to implement and write loosely coupled code. The dependencies can be injected in various forms like: &lt;br /&gt;
* Type 1- Interface Injection&lt;br /&gt;
* Type 2- Setter Injection&lt;br /&gt;
* Type 3- Constructor Injection&lt;br /&gt;
&lt;br /&gt;
== Type 1- Interface Injection ==&lt;br /&gt;
&lt;br /&gt;
Interface injection is a technique to add the dependency for interfaces in components at run time. The components implement these interfaces based on the injected dependency. Spring framework does not support interface injection, so let us see this injection by using the Avalon framework.&lt;br /&gt;
&lt;br /&gt;
For example, we have an ApplicationDAO interface, while AccountApplicationDAO and  CustomerApplicationDAO are the classes implementing ApplicationDAO, &lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public interface ApplicationDAO&lt;br /&gt;
   {&lt;br /&gt;
       void getEntity();&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
 '''''AccountApplicationDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class AccountApplicationDAO implements ApplicationDAO&lt;br /&gt;
     {&lt;br /&gt;
        void getEntity()&lt;br /&gt;
           {&lt;br /&gt;
             //get all accounts.&lt;br /&gt;
           }&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
 '''''CustomerApplicationDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class CustomerApplicationDAO implements ApplicationDAO&lt;br /&gt;
     {&lt;br /&gt;
        void getEntity()&lt;br /&gt;
             {&lt;br /&gt;
               //get all customers.&lt;br /&gt;
             }&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
We also have ApplicationService interface, which depends on the ApplicationDAO interface. The ApplicationServiceImpl class implements the ApplicationService inteface, which in turn implements the ApplicationDAO interface, provided by the container.&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationService.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public interface ApplicationService&lt;br /&gt;
     {&lt;br /&gt;
       getEntity(ApplicationDAO applicationDAO);&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationServiceImpl.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class ApplicationServiceImpl implements ApplicationService &lt;br /&gt;
     {&lt;br /&gt;
        ApplicationDAO applicationDAO;&lt;br /&gt;
        validateEntity (ApplicationDAO applicationDAO)&lt;br /&gt;
             {&lt;br /&gt;
                this. applicationDAO= applicationDAO;&lt;br /&gt;
                applicationDAO.getEntity();&lt;br /&gt;
                //code to validate the Entity (Account/Customer),as per the configuration in xml file.&lt;br /&gt;
             }&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
Now, our main program will get the interface dependency from the container, which uses configuration file for look up, &lt;br /&gt;
&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class MyClass&lt;br /&gt;
 {&lt;br /&gt;
        public static void main(string[] args)&lt;br /&gt;
        {&lt;br /&gt;
            // Get the correct dependency based on configuration file&lt;br /&gt;
            ApplicationDAO dependencyDAO = getDependecny();&lt;br /&gt;
 &lt;br /&gt;
            // Create our applicationServiceImpl class and inject the dependency&lt;br /&gt;
 	    ApplicationServiceImpl applicationServiceImpl = new ApplicationServiceImpl();&lt;br /&gt;
            // call validateEntity()&lt;br /&gt;
            ((ApplicationService)applicationServiceImpl).validateEntity(dependencyDAO);&lt;br /&gt;
 &lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        public static ApplicationDAO getDependency()&lt;br /&gt;
        {&lt;br /&gt;
  string implementClass =  &lt;br /&gt;
         System.Configuration.ConfigurationManager.AppSettings[&amp;quot;selectedClass&amp;quot;];&lt;br /&gt;
            Type type = System.Type.GetType(implementClass);&lt;br /&gt;
  ApplicationDAO applicationDAO = (ApplicationDAO)Activator.CreateInstance(type);&lt;br /&gt;
            return applicationDAO;&lt;br /&gt;
        }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
The Configuration File that will be used by MyClass file to lookup the dependency configurations will be of type:&lt;br /&gt;
&lt;br /&gt;
 '''''App.Config'''''&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
 &amp;lt;configuration&amp;gt;&lt;br /&gt;
   &amp;lt;appSettings&amp;gt;&lt;br /&gt;
     &amp;lt;add key=&amp;quot; selectedClass &amp;quot; value=&amp;quot;myPackage. AccountApplicationDAO &amp;quot; /&amp;gt;&lt;br /&gt;
   &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
 &amp;lt;/configuration&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
In this example, validateEntity() in ApplicationServiceImpl will call getEntity() using  &lt;br /&gt;
ApplicationDAO reference. The getEntity() that is invoked will actually depend on the dependency that is injected via the configuration file.&lt;br /&gt;
&lt;br /&gt;
==Type 2- Setter Injection==&lt;br /&gt;
&lt;br /&gt;
Dependency can be injected using the setter method of a class. If a class is dependent on another class or object instances, then the dependency should be declared as a state(variable) of the class and the class should have a setter method for it. The dependencies are set onto public attributes of the object in need. One of the primary motive for using setters, is supporting dependency injection without having to modify the constructor of a legacy class. Another use is to allow the creation of expensive resources or services as late as possible and only when needed, which is an edge over the Constructor Injection, which we will see in few moments.&lt;br /&gt;
&lt;br /&gt;
Let us consider an example of Setter injection by using Spring Framework.[3] Before using Spring, let us study some basic features of Spring. We will cover only a brief overview of the Spring Framework. &lt;br /&gt;
&lt;br /&gt;
* Spring is a lightweight container which along with supporting features like Dependency Injection, also include other ones as:  Container, Framework, AOP[http://static.springsource.org/spring/docs/2.5.x/reference/aop.html], MVC, etc. &lt;br /&gt;
* Spring Framework supports both Setter Injection and Constructor Injection, but not Interface Injection. Spring jars that can be included are : &lt;br /&gt;
** spring-beans.jar&lt;br /&gt;
** spring-core.jar&lt;br /&gt;
* Packages that provide Spring Frameworks’s IoC container are:&lt;br /&gt;
** org.springframeworks.beans&lt;br /&gt;
** org.springframeworks.context&lt;br /&gt;
&lt;br /&gt;
Now let us see Setter injection using the Spring framework.&lt;br /&gt;
The example below includes a class, DoctorService. The DoctorService class needs a data-access object for communicating with the database. Assume, the PrescriptionDAO (&amp;quot;order data-access object&amp;quot;) is the class on which DoctorService depends. &amp;lt;br&amp;gt;[[image:di_image2.png]] &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 '''''DoctorService.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class DoctorService&lt;br /&gt;
 {&lt;br /&gt;
       private PrescriptionDAO prescriptionDAO;&lt;br /&gt;
       //empty constructor&lt;br /&gt;
       public DoctorService () {}&lt;br /&gt;
       public PrescriptionDAO getPrescriptionDAO() &lt;br /&gt;
           { &lt;br /&gt;
              return this.prescriptionDAO;&lt;br /&gt;
           }&lt;br /&gt;
       //setter for prescriptionDAO&lt;br /&gt;
       public setPrescriptionDAO(prescriptionDAO) &lt;br /&gt;
           { &lt;br /&gt;
              this.prescriptionDAO = prescriptionDAO; &lt;br /&gt;
            }&lt;br /&gt;
       //business logic that actually uses prescriptionDAOto access its variables and methods.&lt;br /&gt;
       public void print()&lt;br /&gt;
            {&lt;br /&gt;
              System.out.println(“prescription: “+prescriptionDAO.prescription);&lt;br /&gt;
              System.out.println(“dose: “+prescriptionDAO.dose);&lt;br /&gt;
             }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
 '''''PrescriptionDAO.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class PrescriptionDAO&lt;br /&gt;
 {&lt;br /&gt;
        private String prescription;&lt;br /&gt;
        private int dose;&lt;br /&gt;
        public PrescriptionDAO(){}&lt;br /&gt;
        public String getPrescription () &lt;br /&gt;
        {&lt;br /&gt;
                return  this.prescription;&lt;br /&gt;
        }&lt;br /&gt;
        public void setPrescription(String prescription) &lt;br /&gt;
        {&lt;br /&gt;
           this. prescription = prescription;&lt;br /&gt;
         }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, the invoking object is responsible for setting the PrescriptionDAO dependency. There is no code inside the class that is creating new instance of PrescriptionDAO. This is because this task will be performed by the Spring container, by looking for dependencies of DoctorService inside applicationContext.xml file.&lt;br /&gt;
&lt;br /&gt;
The Spring framework uses a setter method to create this dependent object. Note the &amp;lt;property&amp;gt; tag which is used inside ApplicationContext.xml file for setter injection. &lt;br /&gt;
&lt;br /&gt;
 '''''ApplicationContext.xml'''''&lt;br /&gt;
 &amp;lt;beans xmlns=&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;br /&gt;
    xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;br /&gt;
    xmlns:p=&amp;quot;http://www.springframework.org/schema/p&amp;quot;&lt;br /&gt;
    xsi:schemaLocation=&amp;quot;http://www.springframework.org/schema/beans&lt;br /&gt;
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;bean id=&amp;quot;doctorServiceId &amp;quot; class=&amp;quot;myPackage.DoctorService&amp;quot;&amp;gt;&lt;br /&gt;
       &amp;lt;!-- setter injection using the nested &amp;lt;ref/&amp;gt; element --&amp;gt;&lt;br /&gt;
       &amp;lt;property name=&amp;quot; prescriptionDAO &amp;quot;&amp;gt;&amp;lt;ref bean=&amp;quot; prescriptionDAOId &amp;quot;/&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
    &amp;lt;/bean&amp;gt;&lt;br /&gt;
   &amp;lt;bean id=&amp;quot; prescriptionDAOId&amp;quot;  class=&amp;quot; myPackage.PrescriptionDAO &amp;quot;&amp;gt;&lt;br /&gt;
       &amp;lt;property name=&amp;quot;prescription&amp;quot; value=&amp;quot;Take medicine regularly.&amp;quot;/&amp;gt;&lt;br /&gt;
       &amp;lt;property name=&amp;quot;dose&amp;quot; value=&amp;quot;3&amp;quot;/&amp;gt;&lt;br /&gt;
   &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, Client is a class that is used to instantiate the Spring Container and retrieve the bean definitions from inside.&lt;br /&gt;
&lt;br /&gt;
 '''''MyClient.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 import java.io;&lt;br /&gt;
 import org.springframework.beans.factory.*;&lt;br /&gt;
 import org.springframework.beans.factory.xml.*;&lt;br /&gt;
 import org.springframework.core.io;&lt;br /&gt;
 public class MyClient&lt;br /&gt;
 {&lt;br /&gt;
    public static void main(String args[])&lt;br /&gt;
        {&lt;br /&gt;
                Resource res=new ClassPathResource(“./myPackage/ ApplicationContext.xml”);&lt;br /&gt;
                BeanFactory factory =new XmlBeanFactory(res); &lt;br /&gt;
                //” doctorServiceId” is the same id defined in ApplicationContext.xml&lt;br /&gt;
                DoctorService doctorService= (DoctorService) factory.getBean(“doctorServiceId”);&lt;br /&gt;
         }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Here, first the path for the ApplicationContext is specified, and then this file is used as a resource by the container. The BeanFactory container uses the xml file to access the bean defined inside the configuration file.&lt;br /&gt;
&lt;br /&gt;
However, Setter Injection unnecessarily adds to the abstraction. The developer needs to know which dependencies are needed when. On the other hand, it can save on modifying a lot of legacy code when introducing new methods, and can provide a performance boost if the dependency is expensive or not easily accessible.&lt;br /&gt;
&lt;br /&gt;
==Type 3- Constructor Injection==&lt;br /&gt;
&lt;br /&gt;
Constructor Injection is the DI technique of passing an object's dependencies to its constructor. It addresses the most common scenario where a class requires one or more Dependencies, and no reasonable local defaults are available.&lt;br /&gt;
&lt;br /&gt;
Constructor Injection addresses this scenario very well, because it guarantees that the Dependency is always present. If the depending class absolutely cannot function without the Dependency, such a guarantee is valuable. Constructor-injection enforces the order of initialization and prevents circular dependencies [http://en.wikipedia.org/wiki/Circular_dependency]. &lt;br /&gt;
On the other hand, with Setter injection, it is not clear, in which order things need to be instantiated. Apart from the guaranteed injection, this pattern is also very easy to implement. &lt;br /&gt;
&lt;br /&gt;
Continuing with the example mentioned above, we can implement the same using constructor injection as follows, &amp;lt;br&amp;gt; [[image:di_image3.png]] &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 '''''DoctorService.java'''''&lt;br /&gt;
 package myPackage;&lt;br /&gt;
 public class DoctorService&lt;br /&gt;
 {&lt;br /&gt;
      private PrescriptionDAO prescriptionDAO;&lt;br /&gt;
    // constructor for instantiatng prescriptionDAO&lt;br /&gt;
      public DoctorService (prescriptionDAO)&lt;br /&gt;
         { &lt;br /&gt;
            this.prescriptionDAO = prescriptionDAO; &lt;br /&gt;
         }&lt;br /&gt;
 //business logic that actually uses prescriptionDAOto access its variables and methods.&lt;br /&gt;
 public void print()&lt;br /&gt;
         {	&lt;br /&gt;
               System.out.println(&amp;quot;prescription:&amp;quot; +prescriptionDAO.prescription);&lt;br /&gt;
               System.out.println(&amp;quot;dose: &amp;quot;+prescriptionDAO.dose); &lt;br /&gt;
         }&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
In the example, you must have noticed the parametrized constructor which Spring framework uses to instantiate the value of prescriptionDAO. &lt;br /&gt;
Now, the question is- how Spring container will come to know whether it has to use Constructor injection or Setter Injection? Tags inside the &amp;lt;bean&amp;gt; tag will specify this:&lt;br /&gt;
* &amp;lt;property&amp;gt; tag   is used for Setter Injection&lt;br /&gt;
* &amp;lt;constructor-arg&amp;gt; is used for Constructor Injection.&lt;br /&gt;
&lt;br /&gt;
ApplicationContect.xml for Constructor injection will be:&lt;br /&gt;
 '''''ApplicationContect.xml'''''&lt;br /&gt;
 &amp;lt;beans xmlns=&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;br /&gt;
    xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;br /&gt;
    xmlns:p=&amp;quot;http://www.springframework.org/schema/p&amp;quot;&lt;br /&gt;
    xsi:schemaLocation=&amp;quot;http://www.springframework.org/schema/beans&lt;br /&gt;
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;bean id=&amp;quot;doctorServiceId &amp;quot; class=&amp;quot;myPackage.DoctorService&amp;quot;&amp;gt;&lt;br /&gt;
                 &amp;lt;!-- constructor injection using the nested &amp;lt;ref/&amp;gt; element --&amp;gt;&lt;br /&gt;
 		 &amp;lt;constructor-arg&amp;gt;&lt;br /&gt;
                 &amp;lt;ref bean=&amp;quot; prescriptionDAOId &amp;quot;/&amp;gt;&lt;br /&gt;
                 &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;
   &amp;lt;/bean&amp;gt;&lt;br /&gt;
   &amp;lt;bean id=&amp;quot; prescriptionDAOId&amp;quot;  class=&amp;quot; myPackage.PrescriptionDAO &amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;property name=&amp;quot;prescription&amp;quot; value=&amp;quot;Take medicine regularly.&amp;quot;/&amp;gt;&lt;br /&gt;
         &amp;lt;property name=&amp;quot;dose&amp;quot; value=&amp;quot;3&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/bean&amp;gt;&lt;br /&gt;
 &amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Definitions for PrescriptionDAO.java and MyClient.java will remain the same.&lt;br /&gt;
The advantage of using Constructor Injection is that it can create the objects at the time of instantiation itself. Hence it guarantees the developer, that the objects will definitely get created and no exception will be raised. &lt;br /&gt;
&lt;br /&gt;
However, unlike [http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2010/ch5_5e_dr#Type_2-_Setter_Injection Setter injection] it won’t allow changes to the dependency, once it is created.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Advantages and Disadvantages=&lt;br /&gt;
&lt;br /&gt;
Advantage of using Dependency injection are &lt;br /&gt;
* Clean code which helps to separate out the logic and the instantiation modules. &lt;br /&gt;
* It is also easy to maintain the code with the use of configuration files where we can make changes in future whenever required. &lt;br /&gt;
* It is very easy to test the code using Dependency Injection.&lt;br /&gt;
* It makes the code more readable.&lt;br /&gt;
&lt;br /&gt;
But the down side of Dependency Injection are that, &lt;br /&gt;
* It is not quite easy to understand the code for developers as there seems to be an abstraction layer which is performing initializing and instantiation of objects. &lt;br /&gt;
* Moreover, developers should have an expertise in coding such design patterns.&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
Hence, Dependency Injection design pattern is good enough to implement in the enterprise applications of large scale, as it helps in reusability, maintainability and testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References and Notes =&lt;br /&gt;
[1] [Spring in Action by Craig Walls, Ryan Briedenbach]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [Java Development with Spring Framework,  by Rod Johnson, Juergen Hoeller, Alef Arendsen, Thomas Risberg, Colin Sampaleanu]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://www.springsource.org/ Spring Framework]&amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://www.opensymphony.com/xwork/ Xwork]&amp;lt;br&amp;gt;&lt;br /&gt;
[8] [http://static.springsource.org/spring/docs/2.5.x/reference/aop.html Aspect Oriented Programming]&amp;lt;br&amp;gt;&lt;br /&gt;
[9] [http://en.wikipedia.org/wiki/Circular_dependency Circular Dependency]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
External Links&lt;br /&gt;
[1] [http://www.codeproject.com/KB/architecture/DependencyInjection.aspx Dependency Injection for Loose Coupling]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [http://www.springframework.net/doc-latest/reference/html/objects.html#objects-factory-collaborators Dependency injection]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://excalibur.apache.org/framework/index.html Excalibur Apache Avalon]&amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://www.picocontainer.org/ PicoContainer]&amp;lt;br&amp;gt;&lt;br /&gt;
[5] [http://hivelogic.com/ Hivelogic]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Further Reading =&lt;br /&gt;
[1] [Dependency Injection in .NET by Mark Seemann]&amp;lt;br&amp;gt;&lt;br /&gt;
[2] [Dependency Injection by Dhanji R Prassanna]&amp;lt;br&amp;gt;&lt;br /&gt;
[3] [http://www.developer.com/net/csharp/article.php/3722931/Dependency-Injection-with-SpringNet.htm Dependency Injection with Spring .NET] &amp;lt;br&amp;gt;&lt;br /&gt;
[4] [http://needle.rubyforge.org/api/ Dependency Injection in Ruby]&lt;br /&gt;
[5] [http://onestepback.org/index.cgi/Tech/Ruby/DependencyInjectionInRuby.rdoc ]&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_2d_dg&amp;diff=36719</id>
		<title>CSC/ECE 517 Fall 2010/ch2 2d dg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_2d_dg&amp;diff=36719"/>
		<updated>2010-10-05T04:12:13Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for developing an application.&lt;br /&gt;
Scaffolding is nothing but a basic structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as [http://en.wikipedia.org/wiki/Boilerplate_(text) boilerplate code]. In a [http://en.wikipedia.org/wiki/Model–View–Controller MVC] framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and Evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should develop the base or a temporary framework for their children to walk in the new world. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators which offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or writing a template generator script, which created these templates for a project. But these generators and scripts were non-standardized and often viewed as taking time away from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What Scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Scaffolding in MVC based Web Frameworks=&lt;br /&gt;
&lt;br /&gt;
Many web frameworks make use of Model-View-Controller architecture in order to modularize their code. MVC framework separates the business logic, controller and the view part, which increases readability, understandability and reusability. Rails also uses MVC framework to implement web applications, and scaffolding helps to generate this model-view-controller code that we see in detail.&lt;br /&gt;
&lt;br /&gt;
First we will describe how the scaffolding approach works in Rails framework. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website. We just define some attributes of a car like its color, year and model.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -6.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -7	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -8	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -9	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -10 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
With this you now have a functioning application. Start the web server and point your browser to http://localhost:3000/cars (unless you decided to override the defaults). You will be presented with a basic screen showing all the cars and their details. Links to web pages to add, edit and destroy a record are also provided. Using these, you can modify existing records or add new records.&lt;br /&gt;
Sample auto generated code for the above example is as below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Controller for car in cars_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CarsController &amp;lt; ApplicationController&lt;br /&gt;
  # GET /cars&lt;br /&gt;
  # GET /cars.xml&lt;br /&gt;
  def index&lt;br /&gt;
    @cars = Car.all&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # index.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @cars }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1&lt;br /&gt;
  # GET /cars/1.xml&lt;br /&gt;
  def show&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # show.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/new&lt;br /&gt;
  # GET /cars/new.xml&lt;br /&gt;
  def new&lt;br /&gt;
    @car = Car.new&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # new.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1/edit&lt;br /&gt;
  def edit&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # POST /cars&lt;br /&gt;
  # POST /cars.xml&lt;br /&gt;
  def create&lt;br /&gt;
    @car = Car.new(params[:car])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.save&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully created.') }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car, :status =&amp;gt; :created, :location =&amp;gt; @car }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;new&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # PUT /cars/1&lt;br /&gt;
  # PUT /cars/1.xml&lt;br /&gt;
  def update&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.update_attributes(params[:car])&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully updated.') }&lt;br /&gt;
        format.xml  { head :ok }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;edit&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # DELETE /cars/1&lt;br /&gt;
  # DELETE /cars/1.xml&lt;br /&gt;
  def destroy&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
    @car.destroy&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html { redirect_to(cars_url) }&lt;br /&gt;
      format.xml  { head :ok }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Sample view file for EDIT generated in views-&amp;gt;cars-&amp;gt;edit.html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Editing car&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;% form_for(@car) do |f| %&amp;gt;&lt;br /&gt;
  &amp;lt;%= f.error_messages %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :color %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :color %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :maker %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :maker %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :model %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :model %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :year %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.date_select :year %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.submit 'Update' %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= link_to 'Show', @car %&amp;gt; |&lt;br /&gt;
&amp;lt;%= link_to 'Back', cars_path %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Database migrate file generated in db-&amp;gt;migrate&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def self.up&lt;br /&gt;
    create_table :cars do |t|&lt;br /&gt;
      t.string :color&lt;br /&gt;
      t.string :maker&lt;br /&gt;
      t.integer :model&lt;br /&gt;
      t.date :year&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.down&lt;br /&gt;
    drop_table :cars&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Database schema generated in db-&amp;gt;schema.rb file&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ActiveRecord::Schema.define(:version =&amp;gt; 20100919144829) do&lt;br /&gt;
&lt;br /&gt;
  create_table &amp;quot;cars&amp;quot;, :force =&amp;gt; true do |t|&lt;br /&gt;
    t.string   &amp;quot;color&amp;quot;&lt;br /&gt;
    t.string   &amp;quot;maker&amp;quot;&lt;br /&gt;
    t.integer  &amp;quot;model&amp;quot;&lt;br /&gt;
    t.date     &amp;quot;year&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;created_at&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;updated_at&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Dynamic Scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
==Other Examples==&lt;br /&gt;
A more detailed listing of examples of scaffolding in various other web frameworks can be found in last year's treatment of the same topic here.&lt;br /&gt;
&lt;br /&gt;
http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2009/wiki1b_9_ss&lt;br /&gt;
&lt;br /&gt;
==Benefits of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
We have noticed that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
You can go through some of the other frameworks to create scaffold web applications.&lt;br /&gt;
# [http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm CakePHP Framework]&lt;br /&gt;
# [http://www.grails.org/Scaffolding Grails Framework]&lt;br /&gt;
#[http://msdn.microsoft.com/en-us/library/ee377606.aspx ASP.NET Framework]&lt;br /&gt;
#[http://www.ntchosting.com/php/frameworks/codeigniter/ Codeigniter]&lt;br /&gt;
#[http://www.myeclipseide.com/me4s/features/iphone-scaffolding.php iPhone]&lt;br /&gt;
#[http://wiki.netbeans.org/JsfCrudGenerator70 NetBeans CRUD Generator]&lt;br /&gt;
&lt;br /&gt;
=Bibiliography=&lt;br /&gt;
==References==&lt;br /&gt;
	&lt;br /&gt;
#Programming Ruby(2nd Edition): The Pragmatic Programmers' Guide (Pragmatic Programmers Series),  by Dave Thomas, Andy Hunt, Andrew Hunt, Chad Fowler, Chad Fowler: Publisher: Pragmatic Bookshelf&lt;br /&gt;
#Agile Web Development with Rails, 3rd ed. by Dave Thomas, David Heinemeier Hansson, David Hansson, Publisher: Pragmatic Bookshelf&lt;br /&gt;
#http://msdn.microsoft.com/en-us/library/cc488469.aspx&lt;br /&gt;
#http://guides.rubyonrails.org/getting_started.html&lt;br /&gt;
&lt;br /&gt;
==External Sites==&lt;br /&gt;
&lt;br /&gt;
#http://en.wikipedia.org/wiki/Scaffolding_Theory&lt;br /&gt;
#http://www.wisegeek.com/what-is-web-application-scaffolding.htm&lt;br /&gt;
#http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm&lt;br /&gt;
#http://cpan.uwinnipeg.ca/htdocs/Scaffold/Scaffold.html&lt;br /&gt;
&lt;br /&gt;
==MediaSite==&lt;br /&gt;
&lt;br /&gt;
# http://www.asp.net/aspnet-in-net-35-sp1/videos/getting-started-with-dynamic-data&lt;br /&gt;
#http://www.youtube.com/watch?v=zV6aueUh8Bs&lt;br /&gt;
#http://www.youtube.com/watch?v=LWoCfTyWG_E&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_2d_dg&amp;diff=36715</id>
		<title>CSC/ECE 517 Fall 2010/ch2 2d dg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_2d_dg&amp;diff=36715"/>
		<updated>2010-10-05T03:58:36Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for developing an application.&lt;br /&gt;
Scaffolding is nothing but a basic structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as [http://en.wikipedia.org/wiki/Boilerplate_(text) boilerplate code]. In a [http://en.wikipedia.org/wiki/Model–View–Controller MVC] framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and Evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should develop the base or a temporary framework for their children to walk in the new world. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators which offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or writing a template generator script, which created these templates for a project. But these generators and scripts were non-standardized and often viewed as taking time away from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What Scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Scaffolding in MVC based Web Frameworks=&lt;br /&gt;
&lt;br /&gt;
Many web frameworks make use of Model-View-Controller architecture in order to modularize their code. MVC framework separates the business logic, controller and the view part, which increases readability, understandability and reusability. Rails also uses MVC framework to implement web applications, so lets see how scaffolding works in this MVC framework.&lt;br /&gt;
First we will describe how the scaffolding approach works in Rails framework. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website. We just define some attributes of a car like its color, year and model.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -6.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -7	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -8	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -9	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -10 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
With this you now have a functioning application. Start the web server and point your browser to http://localhost:3000/cars (unless you decided to override the defaults). You will be presented with a basic screen showing all the cars and their details. Links to web pages to add, edit and destroy a record are also provided. Using these, you can modify existing records or add new records.&lt;br /&gt;
Sample auto generated code for the above example is as below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Controller for car in cars_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CarsController &amp;lt; ApplicationController&lt;br /&gt;
  # GET /cars&lt;br /&gt;
  # GET /cars.xml&lt;br /&gt;
  def index&lt;br /&gt;
    @cars = Car.all&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # index.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @cars }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1&lt;br /&gt;
  # GET /cars/1.xml&lt;br /&gt;
  def show&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # show.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/new&lt;br /&gt;
  # GET /cars/new.xml&lt;br /&gt;
  def new&lt;br /&gt;
    @car = Car.new&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # new.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1/edit&lt;br /&gt;
  def edit&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # POST /cars&lt;br /&gt;
  # POST /cars.xml&lt;br /&gt;
  def create&lt;br /&gt;
    @car = Car.new(params[:car])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.save&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully created.') }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car, :status =&amp;gt; :created, :location =&amp;gt; @car }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;new&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # PUT /cars/1&lt;br /&gt;
  # PUT /cars/1.xml&lt;br /&gt;
  def update&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.update_attributes(params[:car])&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully updated.') }&lt;br /&gt;
        format.xml  { head :ok }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;edit&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # DELETE /cars/1&lt;br /&gt;
  # DELETE /cars/1.xml&lt;br /&gt;
  def destroy&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
    @car.destroy&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html { redirect_to(cars_url) }&lt;br /&gt;
      format.xml  { head :ok }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Sample view file for EDIT generated in views-&amp;gt;cars-&amp;gt;edit.html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Editing car&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;% form_for(@car) do |f| %&amp;gt;&lt;br /&gt;
  &amp;lt;%= f.error_messages %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :color %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :color %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :maker %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :maker %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :model %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :model %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :year %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.date_select :year %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.submit 'Update' %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= link_to 'Show', @car %&amp;gt; |&lt;br /&gt;
&amp;lt;%= link_to 'Back', cars_path %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Database migrate file generated in db-&amp;gt;migrate&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def self.up&lt;br /&gt;
    create_table :cars do |t|&lt;br /&gt;
      t.string :color&lt;br /&gt;
      t.string :maker&lt;br /&gt;
      t.integer :model&lt;br /&gt;
      t.date :year&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.down&lt;br /&gt;
    drop_table :cars&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Database schema generated in db-&amp;gt;schema.rb file&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ActiveRecord::Schema.define(:version =&amp;gt; 20100919144829) do&lt;br /&gt;
&lt;br /&gt;
  create_table &amp;quot;cars&amp;quot;, :force =&amp;gt; true do |t|&lt;br /&gt;
    t.string   &amp;quot;color&amp;quot;&lt;br /&gt;
    t.string   &amp;quot;maker&amp;quot;&lt;br /&gt;
    t.integer  &amp;quot;model&amp;quot;&lt;br /&gt;
    t.date     &amp;quot;year&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;created_at&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;updated_at&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Dynamic Scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
==Other Examples==&lt;br /&gt;
A more detailed listing of examples of scaffolding in various other web frameworks can be found in last year's treatment of the same topic here.&lt;br /&gt;
&lt;br /&gt;
http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2009/wiki1b_9_ss&lt;br /&gt;
&lt;br /&gt;
==Benefits of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
We have noticed that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
You can go through some of the other frameworks to create scaffold web applications.&lt;br /&gt;
# [http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm CakePHP Framework]&lt;br /&gt;
# [http://www.grails.org/Scaffolding Grails Framework]&lt;br /&gt;
#[http://msdn.microsoft.com/en-us/library/ee377606.aspx ASP.NET Framework]&lt;br /&gt;
#[http://www.ntchosting.com/php/frameworks/codeigniter/ Codeigniter]&lt;br /&gt;
#[http://www.myeclipseide.com/me4s/features/iphone-scaffolding.php iPhone]&lt;br /&gt;
#[http://wiki.netbeans.org/JsfCrudGenerator70 NetBeans CRUD Generator]&lt;br /&gt;
&lt;br /&gt;
=Bibiliography=&lt;br /&gt;
==References==&lt;br /&gt;
	&lt;br /&gt;
#Programming Ruby(2nd Edition): The Pragmatic Programmers' Guide (Pragmatic Programmers Series),  by Dave Thomas, Andy Hunt, Andrew Hunt, Chad Fowler, Chad Fowler: Publisher: Pragmatic Bookshelf&lt;br /&gt;
#Agile Web Development with Rails, 3rd ed. by Dave Thomas, David Heinemeier Hansson, David Hansson, Publisher: Pragmatic Bookshelf&lt;br /&gt;
#http://msdn.microsoft.com/en-us/library/cc488469.aspx&lt;br /&gt;
#http://guides.rubyonrails.org/getting_started.html&lt;br /&gt;
&lt;br /&gt;
==External Sites==&lt;br /&gt;
&lt;br /&gt;
#http://en.wikipedia.org/wiki/Scaffolding_Theory&lt;br /&gt;
#http://www.wisegeek.com/what-is-web-application-scaffolding.htm&lt;br /&gt;
#http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm&lt;br /&gt;
#http://cpan.uwinnipeg.ca/htdocs/Scaffold/Scaffold.html&lt;br /&gt;
&lt;br /&gt;
==MediaSite==&lt;br /&gt;
&lt;br /&gt;
# http://www.asp.net/aspnet-in-net-35-sp1/videos/getting-started-with-dynamic-data&lt;br /&gt;
#http://www.youtube.com/watch?v=zV6aueUh8Bs&lt;br /&gt;
#http://www.youtube.com/watch?v=LWoCfTyWG_E&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_2d_dg&amp;diff=36697</id>
		<title>CSC/ECE 517 Fall 2010/ch2 2d dg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_2d_dg&amp;diff=36697"/>
		<updated>2010-10-05T02:34:40Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for developing an application.&lt;br /&gt;
Scaffolding is nothing but a basic structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as [http://en.wikipedia.org/wiki/Boilerplate_(text) boilerplate code]. In a [http://en.wikipedia.org/wiki/Model–View–Controller MVC] framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and Evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should develop the base or a temporary framework for their children to walk in the new world. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators which offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or writing a template generator script, which created these templates for a project. But these generators and scripts were non-standardized and often viewed as taking time away from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What Scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Scaffolding in MVC based Web Frameworks=&lt;br /&gt;
&lt;br /&gt;
First we will describe how the scaffolding approach works in Rails framework. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website. We just define some attributes of a car like its color, year and model.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -6.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -7	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -8	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -9	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -10 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
With this you now have a functioning application. Start the web server and point your browser to http://localhost:3000/cars (unless you decided to override the defaults). You will be presented with a basic screen showing all the cars and their details. Links to web pages to add, edit and destroy a record are also provided. Using these, you can modify existing records or add new records.&lt;br /&gt;
Sample auto generated code for the above example is as below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Controller for car in cars_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CarsController &amp;lt; ApplicationController&lt;br /&gt;
  # GET /cars&lt;br /&gt;
  # GET /cars.xml&lt;br /&gt;
  def index&lt;br /&gt;
    @cars = Car.all&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # index.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @cars }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1&lt;br /&gt;
  # GET /cars/1.xml&lt;br /&gt;
  def show&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # show.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/new&lt;br /&gt;
  # GET /cars/new.xml&lt;br /&gt;
  def new&lt;br /&gt;
    @car = Car.new&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # new.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1/edit&lt;br /&gt;
  def edit&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # POST /cars&lt;br /&gt;
  # POST /cars.xml&lt;br /&gt;
  def create&lt;br /&gt;
    @car = Car.new(params[:car])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.save&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully created.') }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car, :status =&amp;gt; :created, :location =&amp;gt; @car }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;new&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # PUT /cars/1&lt;br /&gt;
  # PUT /cars/1.xml&lt;br /&gt;
  def update&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.update_attributes(params[:car])&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully updated.') }&lt;br /&gt;
        format.xml  { head :ok }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;edit&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # DELETE /cars/1&lt;br /&gt;
  # DELETE /cars/1.xml&lt;br /&gt;
  def destroy&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
    @car.destroy&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html { redirect_to(cars_url) }&lt;br /&gt;
      format.xml  { head :ok }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Sample view file for EDIT generated in views-&amp;gt;cars-&amp;gt;edit.html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Editing car&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;% form_for(@car) do |f| %&amp;gt;&lt;br /&gt;
  &amp;lt;%= f.error_messages %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :color %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :color %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :maker %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :maker %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :model %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :model %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :year %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.date_select :year %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.submit 'Update' %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= link_to 'Show', @car %&amp;gt; |&lt;br /&gt;
&amp;lt;%= link_to 'Back', cars_path %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Database migrate file generated in db-&amp;gt;migrate&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def self.up&lt;br /&gt;
    create_table :cars do |t|&lt;br /&gt;
      t.string :color&lt;br /&gt;
      t.string :maker&lt;br /&gt;
      t.integer :model&lt;br /&gt;
      t.date :year&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.down&lt;br /&gt;
    drop_table :cars&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Database schema generated in db-&amp;gt;schema.rb file&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ActiveRecord::Schema.define(:version =&amp;gt; 20100919144829) do&lt;br /&gt;
&lt;br /&gt;
  create_table &amp;quot;cars&amp;quot;, :force =&amp;gt; true do |t|&lt;br /&gt;
    t.string   &amp;quot;color&amp;quot;&lt;br /&gt;
    t.string   &amp;quot;maker&amp;quot;&lt;br /&gt;
    t.integer  &amp;quot;model&amp;quot;&lt;br /&gt;
    t.date     &amp;quot;year&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;created_at&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;updated_at&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Dynamic Scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
==Other Examples==&lt;br /&gt;
A more detailed listing of examples of scaffolding in various other web frameworks can be found in last year's treatment of the same topic here.&lt;br /&gt;
&lt;br /&gt;
http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2009/wiki1b_9_ss&lt;br /&gt;
&lt;br /&gt;
==Benefits of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
We have noticed that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
You can go through some of the other frameworks to create scaffold web applications.&lt;br /&gt;
# [http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm CakePHP Framework]&lt;br /&gt;
# [http://www.grails.org/Scaffolding Grails Framework]&lt;br /&gt;
#[http://msdn.microsoft.com/en-us/library/ee377606.aspx ASP.NET Framework]&lt;br /&gt;
#[http://www.ntchosting.com/php/frameworks/codeigniter/ Codeigniter]&lt;br /&gt;
#[http://www.myeclipseide.com/me4s/features/iphone-scaffolding.php iPhone]&lt;br /&gt;
#[http://wiki.netbeans.org/JsfCrudGenerator70 NetBeans CRUD Generator]&lt;br /&gt;
&lt;br /&gt;
=Bibiliography=&lt;br /&gt;
==References==&lt;br /&gt;
	&lt;br /&gt;
#Programming Ruby(2nd Edition): The Pragmatic Programmers' Guide (Pragmatic Programmers Series),  by Dave Thomas, Andy Hunt, Andrew Hunt, Chad Fowler, Chad Fowler: Publisher: Pragmatic Bookshelf&lt;br /&gt;
#Agile Web Development with Rails, 3rd ed. by Dave Thomas, David Heinemeier Hansson, David Hansson, Publisher: Pragmatic Bookshelf&lt;br /&gt;
#http://msdn.microsoft.com/en-us/library/cc488469.aspx&lt;br /&gt;
#http://guides.rubyonrails.org/getting_started.html&lt;br /&gt;
&lt;br /&gt;
==External Sites==&lt;br /&gt;
&lt;br /&gt;
#http://en.wikipedia.org/wiki/Scaffolding_Theory&lt;br /&gt;
#http://www.wisegeek.com/what-is-web-application-scaffolding.htm&lt;br /&gt;
#http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm&lt;br /&gt;
#http://cpan.uwinnipeg.ca/htdocs/Scaffold/Scaffold.html&lt;br /&gt;
&lt;br /&gt;
==MediaSite==&lt;br /&gt;
&lt;br /&gt;
# http://www.asp.net/aspnet-in-net-35-sp1/videos/getting-started-with-dynamic-data&lt;br /&gt;
#http://www.youtube.com/watch?v=zV6aueUh8Bs&lt;br /&gt;
#http://www.youtube.com/watch?v=LWoCfTyWG_E&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_2d_dg&amp;diff=36524</id>
		<title>CSC/ECE 517 Fall 2010/ch2 2d dg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_2d_dg&amp;diff=36524"/>
		<updated>2010-10-03T00:34:22Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for developing an application.&lt;br /&gt;
Scaffolding is nothing but a basic structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as [http://en.wikipedia.org/wiki/Boilerplate_(text) boilerplate code]. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and Evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should develop the base or a temporary framework for their children to walk in the new world. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators which offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or writing a template generator script, which created these templates for a project. But these generators and scripts were non-standardized and often viewed as taking time away from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What Scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Scaffolding in MVC based Web Frameworks=&lt;br /&gt;
&lt;br /&gt;
First we will describe how the scaffolding approach works in Rails framework. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website. We just define some attributes of a car like its color, year and model.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -6.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -7	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -8	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -9	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -10 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
With this you now have a functioning application. Start the web server and point your browser to http://localhost:3000/cars (unless you decided to override the defaults). You will be presented with a basic screen showing all the cars and their details. Links to web pages to add, edit and destroy a record are also provided. Using these, you can modify existing records or add new records.&lt;br /&gt;
Sample auto generated code for the above example is as below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Controller for car in cars_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CarsController &amp;lt; ApplicationController&lt;br /&gt;
  # GET /cars&lt;br /&gt;
  # GET /cars.xml&lt;br /&gt;
  def index&lt;br /&gt;
    @cars = Car.all&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # index.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @cars }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1&lt;br /&gt;
  # GET /cars/1.xml&lt;br /&gt;
  def show&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # show.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/new&lt;br /&gt;
  # GET /cars/new.xml&lt;br /&gt;
  def new&lt;br /&gt;
    @car = Car.new&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # new.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1/edit&lt;br /&gt;
  def edit&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # POST /cars&lt;br /&gt;
  # POST /cars.xml&lt;br /&gt;
  def create&lt;br /&gt;
    @car = Car.new(params[:car])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.save&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully created.') }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car, :status =&amp;gt; :created, :location =&amp;gt; @car }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;new&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # PUT /cars/1&lt;br /&gt;
  # PUT /cars/1.xml&lt;br /&gt;
  def update&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.update_attributes(params[:car])&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully updated.') }&lt;br /&gt;
        format.xml  { head :ok }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;edit&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # DELETE /cars/1&lt;br /&gt;
  # DELETE /cars/1.xml&lt;br /&gt;
  def destroy&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
    @car.destroy&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html { redirect_to(cars_url) }&lt;br /&gt;
      format.xml  { head :ok }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Sample view file for EDIT generated in views-&amp;gt;cars-&amp;gt;edit.html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Editing car&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;% form_for(@car) do |f| %&amp;gt;&lt;br /&gt;
  &amp;lt;%= f.error_messages %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :color %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :color %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :maker %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :maker %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :model %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :model %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :year %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.date_select :year %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.submit 'Update' %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= link_to 'Show', @car %&amp;gt; |&lt;br /&gt;
&amp;lt;%= link_to 'Back', cars_path %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Database migrate file generated in db-&amp;gt;migrate&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def self.up&lt;br /&gt;
    create_table :cars do |t|&lt;br /&gt;
      t.string :color&lt;br /&gt;
      t.string :maker&lt;br /&gt;
      t.integer :model&lt;br /&gt;
      t.date :year&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.down&lt;br /&gt;
    drop_table :cars&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Database schema generated in db-&amp;gt;schema.rb file&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ActiveRecord::Schema.define(:version =&amp;gt; 20100919144829) do&lt;br /&gt;
&lt;br /&gt;
  create_table &amp;quot;cars&amp;quot;, :force =&amp;gt; true do |t|&lt;br /&gt;
    t.string   &amp;quot;color&amp;quot;&lt;br /&gt;
    t.string   &amp;quot;maker&amp;quot;&lt;br /&gt;
    t.integer  &amp;quot;model&amp;quot;&lt;br /&gt;
    t.date     &amp;quot;year&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;created_at&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;updated_at&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Dynamic Scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
==Other Examples==&lt;br /&gt;
A more detailed listing of examples of scaffolding in various other web frameworks can be found in last year's treatment of the same topic here.&lt;br /&gt;
&lt;br /&gt;
http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2009/wiki1b_9_ss&lt;br /&gt;
&lt;br /&gt;
==Benefits of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
We have noticed that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
You can go through some of the other frameworks to create scaffold web applications.&lt;br /&gt;
# [http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm CakePHP Framework]&lt;br /&gt;
# [http://www.grails.org/Scaffolding Grails Framework]&lt;br /&gt;
#[http://msdn.microsoft.com/en-us/library/ee377606.aspx ASP.NET Framework]&lt;br /&gt;
#[http://www.ntchosting.com/php/frameworks/codeigniter/ Codeigniter]&lt;br /&gt;
#[http://www.myeclipseide.com/me4s/features/iphone-scaffolding.php iPhone]&lt;br /&gt;
#[http://wiki.netbeans.org/JsfCrudGenerator70 NetBeans CRUD Generator]&lt;br /&gt;
&lt;br /&gt;
=Bibiliography=&lt;br /&gt;
==References==&lt;br /&gt;
	&lt;br /&gt;
#Programming Ruby(2nd Edition): The Pragmatic Programmers' Guide (Pragmatic Programmers Series),  by Dave Thomas, Andy Hunt, Andrew Hunt, Chad Fowler, Chad Fowler: Publisher: Pragmatic Bookshelf&lt;br /&gt;
#Agile Web Development with Rails, 3rd ed. by Dave Thomas, David Heinemeier Hansson, David Hansson, Publisher: Pragmatic Bookshelf&lt;br /&gt;
#http://msdn.microsoft.com/en-us/library/cc488469.aspx&lt;br /&gt;
#http://guides.rubyonrails.org/getting_started.html&lt;br /&gt;
&lt;br /&gt;
==External Sites==&lt;br /&gt;
&lt;br /&gt;
#http://en.wikipedia.org/wiki/Scaffolding_Theory&lt;br /&gt;
#http://www.wisegeek.com/what-is-web-application-scaffolding.htm&lt;br /&gt;
#http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm&lt;br /&gt;
#http://cpan.uwinnipeg.ca/htdocs/Scaffold/Scaffold.html&lt;br /&gt;
&lt;br /&gt;
==MediaSite==&lt;br /&gt;
&lt;br /&gt;
# http://www.asp.net/aspnet-in-net-35-sp1/videos/getting-started-with-dynamic-data&lt;br /&gt;
#http://www.youtube.com/watch?v=zV6aueUh8Bs&lt;br /&gt;
#http://www.youtube.com/watch?v=LWoCfTyWG_E&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_2d_dg&amp;diff=36523</id>
		<title>CSC/ECE 517 Fall 2010/ch2 2d dg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_2d_dg&amp;diff=36523"/>
		<updated>2010-10-03T00:25:32Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for developing an application.&lt;br /&gt;
Scaffolding is nothing but a basic structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and Evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, the support can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators which offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or writing a template generator script, which created these templates for a project. But these generators and scripts were non-standardized and often viewed as taking time away from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==What Scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Scaffolding in MVC based Web Frameworks=&lt;br /&gt;
&lt;br /&gt;
First we will describe how the scaffolding approach works in Rails framework. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website. We just define some attributes of a car like its color, year and model.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -6.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -7	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -8	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -9	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -10 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
With this you now have a functioning application. Start the web server and point your browser to http://localhost:3000/cars (unless you decided to override the defaults). You will be presented with a basic screen showing all the cars and their details. Links to web pages to add, edit and destroy a record are also provided. Using these, you can modify existing records or add new records.&lt;br /&gt;
Sample auto generated code for the above example is as below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Controller for car in cars_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CarsController &amp;lt; ApplicationController&lt;br /&gt;
  # GET /cars&lt;br /&gt;
  # GET /cars.xml&lt;br /&gt;
  def index&lt;br /&gt;
    @cars = Car.all&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # index.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @cars }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1&lt;br /&gt;
  # GET /cars/1.xml&lt;br /&gt;
  def show&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # show.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/new&lt;br /&gt;
  # GET /cars/new.xml&lt;br /&gt;
  def new&lt;br /&gt;
    @car = Car.new&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # new.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1/edit&lt;br /&gt;
  def edit&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # POST /cars&lt;br /&gt;
  # POST /cars.xml&lt;br /&gt;
  def create&lt;br /&gt;
    @car = Car.new(params[:car])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.save&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully created.') }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car, :status =&amp;gt; :created, :location =&amp;gt; @car }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;new&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # PUT /cars/1&lt;br /&gt;
  # PUT /cars/1.xml&lt;br /&gt;
  def update&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.update_attributes(params[:car])&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully updated.') }&lt;br /&gt;
        format.xml  { head :ok }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;edit&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # DELETE /cars/1&lt;br /&gt;
  # DELETE /cars/1.xml&lt;br /&gt;
  def destroy&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
    @car.destroy&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html { redirect_to(cars_url) }&lt;br /&gt;
      format.xml  { head :ok }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Sample view file for EDIT generated in views-&amp;gt;cars-&amp;gt;edit.html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Editing car&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;% form_for(@car) do |f| %&amp;gt;&lt;br /&gt;
  &amp;lt;%= f.error_messages %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :color %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :color %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :maker %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :maker %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :model %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :model %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :year %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.date_select :year %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.submit 'Update' %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= link_to 'Show', @car %&amp;gt; |&lt;br /&gt;
&amp;lt;%= link_to 'Back', cars_path %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Database migrate file generated in db-&amp;gt;migrate&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def self.up&lt;br /&gt;
    create_table :cars do |t|&lt;br /&gt;
      t.string :color&lt;br /&gt;
      t.string :maker&lt;br /&gt;
      t.integer :model&lt;br /&gt;
      t.date :year&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.down&lt;br /&gt;
    drop_table :cars&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Database schema generated in db-&amp;gt;schema.rb file&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ActiveRecord::Schema.define(:version =&amp;gt; 20100919144829) do&lt;br /&gt;
&lt;br /&gt;
  create_table &amp;quot;cars&amp;quot;, :force =&amp;gt; true do |t|&lt;br /&gt;
    t.string   &amp;quot;color&amp;quot;&lt;br /&gt;
    t.string   &amp;quot;maker&amp;quot;&lt;br /&gt;
    t.integer  &amp;quot;model&amp;quot;&lt;br /&gt;
    t.date     &amp;quot;year&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;created_at&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;updated_at&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Dynamic Scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
==Other Examples==&lt;br /&gt;
A more detailed listing of examples of scaffolding in various other web frameworks can be found in last year's treatment of the same topic here.&lt;br /&gt;
&lt;br /&gt;
http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2009/wiki1b_9_ss&lt;br /&gt;
&lt;br /&gt;
==Benefits of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
We have noticed that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
You can go through some of the other frameworks to create scaffold web applications.&lt;br /&gt;
# [http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm CakePHP Framework]&lt;br /&gt;
# [http://www.grails.org/Scaffolding Grails Framework]&lt;br /&gt;
#[http://msdn.microsoft.com/en-us/library/ee377606.aspx ASP.NET Framework]&lt;br /&gt;
#[http://www.ntchosting.com/php/frameworks/codeigniter/ Codeigniter]&lt;br /&gt;
#[http://www.myeclipseide.com/me4s/features/iphone-scaffolding.php iPhone]&lt;br /&gt;
#[http://wiki.netbeans.org/JsfCrudGenerator70 NetBeans CRUD Generator]&lt;br /&gt;
&lt;br /&gt;
=Bibiliography=&lt;br /&gt;
==References==&lt;br /&gt;
	&lt;br /&gt;
#Programming Ruby(2nd Edition): The Pragmatic Programmers' Guide (Pragmatic Programmers Series),  by Dave Thomas, Andy Hunt, Andrew Hunt, Chad Fowler, Chad Fowler: Publisher: Pragmatic Bookshelf&lt;br /&gt;
#Agile Web Development with Rails, 3rd ed. by Dave Thomas, David Heinemeier Hansson, David Hansson, Publisher: Pragmatic Bookshelf&lt;br /&gt;
#http://msdn.microsoft.com/en-us/library/cc488469.aspx&lt;br /&gt;
#http://guides.rubyonrails.org/getting_started.html&lt;br /&gt;
&lt;br /&gt;
==External Sites==&lt;br /&gt;
&lt;br /&gt;
#http://en.wikipedia.org/wiki/Scaffolding_Theory&lt;br /&gt;
#http://www.wisegeek.com/what-is-web-application-scaffolding.htm&lt;br /&gt;
#http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm&lt;br /&gt;
#http://cpan.uwinnipeg.ca/htdocs/Scaffold/Scaffold.html&lt;br /&gt;
&lt;br /&gt;
==MediaSite==&lt;br /&gt;
&lt;br /&gt;
# http://www.asp.net/aspnet-in-net-35-sp1/videos/getting-started-with-dynamic-data&lt;br /&gt;
#http://www.youtube.com/watch?v=zV6aueUh8Bs&lt;br /&gt;
#http://www.youtube.com/watch?v=LWoCfTyWG_E&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_2d_dg&amp;diff=36522</id>
		<title>CSC/ECE 517 Fall 2010/ch2 2d dg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_2d_dg&amp;diff=36522"/>
		<updated>2010-10-03T00:21:42Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for developing an application.&lt;br /&gt;
Scaffolding is nothing but a basic structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and Evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, the support can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators which offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or writing a template generator script, which created these templates for a project. But these generators and scripts were non-standardized and often viewed as taking time away from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
==Benefits of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
We have noticed that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
==What Scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Scaffolding in MVC based Web Frameworks=&lt;br /&gt;
&lt;br /&gt;
First we will describe how the scaffolding approach works in Rails framework. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website. We just define some attributes of a car like its color, year and model.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -6.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -7	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -8	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -9	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -10 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
With this you now have a functioning application. Start the web server and point your browser to http://localhost:3000/cars (unless you decided to override the defaults). You will be presented with a basic screen showing all the cars and their details. Links to web pages to add, edit and destroy a record are also provided. Using these, you can modify existing records or add new records.&lt;br /&gt;
Sample auto generated code for the above example is as below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Controller for car in cars_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CarsController &amp;lt; ApplicationController&lt;br /&gt;
  # GET /cars&lt;br /&gt;
  # GET /cars.xml&lt;br /&gt;
  def index&lt;br /&gt;
    @cars = Car.all&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # index.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @cars }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1&lt;br /&gt;
  # GET /cars/1.xml&lt;br /&gt;
  def show&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # show.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/new&lt;br /&gt;
  # GET /cars/new.xml&lt;br /&gt;
  def new&lt;br /&gt;
    @car = Car.new&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # new.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1/edit&lt;br /&gt;
  def edit&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # POST /cars&lt;br /&gt;
  # POST /cars.xml&lt;br /&gt;
  def create&lt;br /&gt;
    @car = Car.new(params[:car])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.save&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully created.') }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car, :status =&amp;gt; :created, :location =&amp;gt; @car }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;new&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # PUT /cars/1&lt;br /&gt;
  # PUT /cars/1.xml&lt;br /&gt;
  def update&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.update_attributes(params[:car])&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully updated.') }&lt;br /&gt;
        format.xml  { head :ok }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;edit&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # DELETE /cars/1&lt;br /&gt;
  # DELETE /cars/1.xml&lt;br /&gt;
  def destroy&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
    @car.destroy&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html { redirect_to(cars_url) }&lt;br /&gt;
      format.xml  { head :ok }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Sample view file for EDIT generated in views-&amp;gt;cars-&amp;gt;edit.html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Editing car&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;% form_for(@car) do |f| %&amp;gt;&lt;br /&gt;
  &amp;lt;%= f.error_messages %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :color %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :color %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :maker %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :maker %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :model %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :model %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :year %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.date_select :year %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.submit 'Update' %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= link_to 'Show', @car %&amp;gt; |&lt;br /&gt;
&amp;lt;%= link_to 'Back', cars_path %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Database migrate file generated in db-&amp;gt;migrate&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def self.up&lt;br /&gt;
    create_table :cars do |t|&lt;br /&gt;
      t.string :color&lt;br /&gt;
      t.string :maker&lt;br /&gt;
      t.integer :model&lt;br /&gt;
      t.date :year&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.down&lt;br /&gt;
    drop_table :cars&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Database schema generated in db-&amp;gt;schema.rb file&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ActiveRecord::Schema.define(:version =&amp;gt; 20100919144829) do&lt;br /&gt;
&lt;br /&gt;
  create_table &amp;quot;cars&amp;quot;, :force =&amp;gt; true do |t|&lt;br /&gt;
    t.string   &amp;quot;color&amp;quot;&lt;br /&gt;
    t.string   &amp;quot;maker&amp;quot;&lt;br /&gt;
    t.integer  &amp;quot;model&amp;quot;&lt;br /&gt;
    t.date     &amp;quot;year&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;created_at&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;updated_at&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Dynamic Scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
==Other Examples==&lt;br /&gt;
A more detailed listing of examples of scaffolding in various other web frameworks can be found in last year's treatment of the same topic here.&lt;br /&gt;
&lt;br /&gt;
http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2009/wiki1b_9_ss&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
You can go through some of the other frameworks to create scaffold web applications.&lt;br /&gt;
# [http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm CakePHP Framework]&lt;br /&gt;
# [http://www.grails.org/Scaffolding Grails Framework]&lt;br /&gt;
#[http://msdn.microsoft.com/en-us/library/ee377606.aspx ASP.NET Framework]&lt;br /&gt;
#[http://www.ntchosting.com/php/frameworks/codeigniter/ Codeigniter]&lt;br /&gt;
#[http://www.myeclipseide.com/me4s/features/iphone-scaffolding.php iPhone]&lt;br /&gt;
#[http://wiki.netbeans.org/JsfCrudGenerator70 NetBeans CRUD Generator]&lt;br /&gt;
&lt;br /&gt;
=Bibiliography=&lt;br /&gt;
==References==&lt;br /&gt;
	&lt;br /&gt;
#Programming Ruby(2nd Edition): The Pragmatic Programmers' Guide (Pragmatic Programmers Series),  by Dave Thomas, Andy Hunt, Andrew Hunt, Chad Fowler, Chad Fowler: Publisher: Pragmatic Bookshelf&lt;br /&gt;
#Agile Web Development with Rails, 3rd ed. by Dave Thomas, David Heinemeier Hansson, David Hansson, Publisher: Pragmatic Bookshelf&lt;br /&gt;
#http://msdn.microsoft.com/en-us/library/cc488469.aspx&lt;br /&gt;
#http://guides.rubyonrails.org/getting_started.html&lt;br /&gt;
&lt;br /&gt;
==External Sites==&lt;br /&gt;
&lt;br /&gt;
#http://en.wikipedia.org/wiki/Scaffolding_Theory&lt;br /&gt;
#http://www.wisegeek.com/what-is-web-application-scaffolding.htm&lt;br /&gt;
#http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm&lt;br /&gt;
#http://cpan.uwinnipeg.ca/htdocs/Scaffold/Scaffold.html&lt;br /&gt;
&lt;br /&gt;
==MediaSite==&lt;br /&gt;
&lt;br /&gt;
# http://www.asp.net/aspnet-in-net-35-sp1/videos/getting-started-with-dynamic-data&lt;br /&gt;
#http://www.youtube.com/watch?v=zV6aueUh8Bs&lt;br /&gt;
#http://www.youtube.com/watch?v=LWoCfTyWG_E&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_2d_dg&amp;diff=36222</id>
		<title>CSC/ECE 517 Fall 2010/ch2 2d dg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_2d_dg&amp;diff=36222"/>
		<updated>2010-09-22T23:18:15Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and Evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What Scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Scaffolding in MVC based Web Frameworks=&lt;br /&gt;
&lt;br /&gt;
First we will describe how the scaffolding approach works in Rails framework. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -8	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -9	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -10	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -11 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
&lt;br /&gt;
Sample auto generated code for the above example is as below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Controller for car in cars_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CarsController &amp;lt; ApplicationController&lt;br /&gt;
  # GET /cars&lt;br /&gt;
  # GET /cars.xml&lt;br /&gt;
  def index&lt;br /&gt;
    @cars = Car.all&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # index.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @cars }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1&lt;br /&gt;
  # GET /cars/1.xml&lt;br /&gt;
  def show&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # show.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/new&lt;br /&gt;
  # GET /cars/new.xml&lt;br /&gt;
  def new&lt;br /&gt;
    @car = Car.new&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # new.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1/edit&lt;br /&gt;
  def edit&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # POST /cars&lt;br /&gt;
  # POST /cars.xml&lt;br /&gt;
  def create&lt;br /&gt;
    @car = Car.new(params[:car])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.save&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully created.') }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car, :status =&amp;gt; :created, :location =&amp;gt; @car }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;new&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # PUT /cars/1&lt;br /&gt;
  # PUT /cars/1.xml&lt;br /&gt;
  def update&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.update_attributes(params[:car])&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully updated.') }&lt;br /&gt;
        format.xml  { head :ok }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;edit&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # DELETE /cars/1&lt;br /&gt;
  # DELETE /cars/1.xml&lt;br /&gt;
  def destroy&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
    @car.destroy&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html { redirect_to(cars_url) }&lt;br /&gt;
      format.xml  { head :ok }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Sample view file for EDIT generated in views-&amp;gt;cars-&amp;gt;edit.html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Editing car&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;% form_for(@car) do |f| %&amp;gt;&lt;br /&gt;
  &amp;lt;%= f.error_messages %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :color %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :color %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :maker %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :maker %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :model %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :model %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :year %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.date_select :year %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.submit 'Update' %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= link_to 'Show', @car %&amp;gt; |&lt;br /&gt;
&amp;lt;%= link_to 'Back', cars_path %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Database migrate file generated in db-&amp;gt;migrate&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def self.up&lt;br /&gt;
    create_table :cars do |t|&lt;br /&gt;
      t.string :color&lt;br /&gt;
      t.string :maker&lt;br /&gt;
      t.integer :model&lt;br /&gt;
      t.date :year&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.down&lt;br /&gt;
    drop_table :cars&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Database schema generated in db-&amp;gt;schema.rb file&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ActiveRecord::Schema.define(:version =&amp;gt; 20100919144829) do&lt;br /&gt;
&lt;br /&gt;
  create_table &amp;quot;cars&amp;quot;, :force =&amp;gt; true do |t|&lt;br /&gt;
    t.string   &amp;quot;color&amp;quot;&lt;br /&gt;
    t.string   &amp;quot;maker&amp;quot;&lt;br /&gt;
    t.integer  &amp;quot;model&amp;quot;&lt;br /&gt;
    t.date     &amp;quot;year&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;created_at&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;updated_at&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Dynamic Scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
==Other Examples==&lt;br /&gt;
A more detailed listing of examples of scaffolding in various other web frameworks can be found in last year's treatment of the same topic here.&lt;br /&gt;
&lt;br /&gt;
http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2009/wiki1b_9_ss&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
You can go through some of the other frameworks to create scaffold web applications.&lt;br /&gt;
# [http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm CakePHP Framework]&lt;br /&gt;
# [http://www.grails.org/Scaffolding Grails Framework]&lt;br /&gt;
#[http://msdn.microsoft.com/en-us/library/ee377606.aspx ASP.NET Framework]&lt;br /&gt;
#[http://www.ntchosting.com/php/frameworks/codeigniter/ Codeigniter]&lt;br /&gt;
#[http://www.myeclipseide.com/me4s/features/iphone-scaffolding.php iPhone]&lt;br /&gt;
#[http://wiki.netbeans.org/JsfCrudGenerator70 NetBeans CRUD Generator]&lt;br /&gt;
&lt;br /&gt;
=Bibiliography=&lt;br /&gt;
==References==&lt;br /&gt;
	&lt;br /&gt;
#Programming Ruby(2nd Edition): The Pragmatic Programmers' Guide (Pragmatic Programmers Series),  by Dave Thomas, Andy Hunt, Andrew Hunt, Chad Fowler, Chad Fowler: Publisher: Pragmatic Bookshelf&lt;br /&gt;
#Agile Web Development with Rails, 3rd ed. by Dave Thomas, David Heinemeier Hansson, David Hansson, Publisher: Pragmatic Bookshelf&lt;br /&gt;
#http://msdn.microsoft.com/en-us/library/cc488469.aspx&lt;br /&gt;
#http://guides.rubyonrails.org/getting_started.html&lt;br /&gt;
&lt;br /&gt;
==External Sites==&lt;br /&gt;
&lt;br /&gt;
#http://en.wikipedia.org/wiki/Scaffolding_Theory&lt;br /&gt;
#http://www.wisegeek.com/what-is-web-application-scaffolding.htm&lt;br /&gt;
#http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm&lt;br /&gt;
#http://cpan.uwinnipeg.ca/htdocs/Scaffold/Scaffold.html&lt;br /&gt;
&lt;br /&gt;
==MediaSite==&lt;br /&gt;
&lt;br /&gt;
# http://www.asp.net/aspnet-in-net-35-sp1/videos/getting-started-with-dynamic-data&lt;br /&gt;
#http://www.youtube.com/watch?v=zV6aueUh8Bs&lt;br /&gt;
#http://www.youtube.com/watch?v=LWoCfTyWG_E&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_2d_dg&amp;diff=36221</id>
		<title>CSC/ECE 517 Fall 2010/ch2 2d dg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_2d_dg&amp;diff=36221"/>
		<updated>2010-09-22T23:17:22Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and Evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What Scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Scaffolding in MVC based Web Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -8	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -9	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -10	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -11 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
&lt;br /&gt;
Sample auto generated code for the above example is as below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Controller for car in cars_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CarsController &amp;lt; ApplicationController&lt;br /&gt;
  # GET /cars&lt;br /&gt;
  # GET /cars.xml&lt;br /&gt;
  def index&lt;br /&gt;
    @cars = Car.all&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # index.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @cars }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1&lt;br /&gt;
  # GET /cars/1.xml&lt;br /&gt;
  def show&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # show.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/new&lt;br /&gt;
  # GET /cars/new.xml&lt;br /&gt;
  def new&lt;br /&gt;
    @car = Car.new&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # new.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1/edit&lt;br /&gt;
  def edit&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # POST /cars&lt;br /&gt;
  # POST /cars.xml&lt;br /&gt;
  def create&lt;br /&gt;
    @car = Car.new(params[:car])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.save&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully created.') }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car, :status =&amp;gt; :created, :location =&amp;gt; @car }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;new&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # PUT /cars/1&lt;br /&gt;
  # PUT /cars/1.xml&lt;br /&gt;
  def update&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.update_attributes(params[:car])&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully updated.') }&lt;br /&gt;
        format.xml  { head :ok }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;edit&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # DELETE /cars/1&lt;br /&gt;
  # DELETE /cars/1.xml&lt;br /&gt;
  def destroy&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
    @car.destroy&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html { redirect_to(cars_url) }&lt;br /&gt;
      format.xml  { head :ok }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Sample view file for EDIT generated in views-&amp;gt;cars-&amp;gt;edit.html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Editing car&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;% form_for(@car) do |f| %&amp;gt;&lt;br /&gt;
  &amp;lt;%= f.error_messages %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :color %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :color %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :maker %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :maker %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :model %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :model %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :year %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.date_select :year %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.submit 'Update' %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= link_to 'Show', @car %&amp;gt; |&lt;br /&gt;
&amp;lt;%= link_to 'Back', cars_path %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Database migrate file generated in db-&amp;gt;migrate&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def self.up&lt;br /&gt;
    create_table :cars do |t|&lt;br /&gt;
      t.string :color&lt;br /&gt;
      t.string :maker&lt;br /&gt;
      t.integer :model&lt;br /&gt;
      t.date :year&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.down&lt;br /&gt;
    drop_table :cars&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Database schema generated in db-&amp;gt;schema.rb file&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ActiveRecord::Schema.define(:version =&amp;gt; 20100919144829) do&lt;br /&gt;
&lt;br /&gt;
  create_table &amp;quot;cars&amp;quot;, :force =&amp;gt; true do |t|&lt;br /&gt;
    t.string   &amp;quot;color&amp;quot;&lt;br /&gt;
    t.string   &amp;quot;maker&amp;quot;&lt;br /&gt;
    t.integer  &amp;quot;model&amp;quot;&lt;br /&gt;
    t.date     &amp;quot;year&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;created_at&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;updated_at&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Dynamic Scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
==Other Examples==&lt;br /&gt;
A more detailed listing of examples of scaffolding in various other web frameworks can be found in last year's treatment of the same topic here.&lt;br /&gt;
&lt;br /&gt;
http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2009/wiki1b_9_ss&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
You can go through some of the other frameworks to create scaffold web applications.&lt;br /&gt;
# [http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm CakePHP Framework]&lt;br /&gt;
# [http://www.grails.org/Scaffolding Grails Framework]&lt;br /&gt;
#[http://msdn.microsoft.com/en-us/library/ee377606.aspx ASP.NET Framework]&lt;br /&gt;
#[http://www.ntchosting.com/php/frameworks/codeigniter/ Codeigniter]&lt;br /&gt;
#[http://www.myeclipseide.com/me4s/features/iphone-scaffolding.php iPhone]&lt;br /&gt;
#[http://wiki.netbeans.org/JsfCrudGenerator70 NetBeans CRUD Generator]&lt;br /&gt;
&lt;br /&gt;
=Bibiliography=&lt;br /&gt;
==References==&lt;br /&gt;
	&lt;br /&gt;
#Programming Ruby(2nd Edition): The Pragmatic Programmers' Guide (Pragmatic Programmers Series),  by Dave Thomas, Andy Hunt, Andrew Hunt, Chad Fowler, Chad Fowler: Publisher: Pragmatic Bookshelf&lt;br /&gt;
#Agile Web Development with Rails, 3rd ed. by Dave Thomas, David Heinemeier Hansson, David Hansson, Publisher: Pragmatic Bookshelf&lt;br /&gt;
#http://msdn.microsoft.com/en-us/library/cc488469.aspx&lt;br /&gt;
#http://guides.rubyonrails.org/getting_started.html&lt;br /&gt;
&lt;br /&gt;
==External Sites==&lt;br /&gt;
&lt;br /&gt;
#http://en.wikipedia.org/wiki/Scaffolding_Theory&lt;br /&gt;
#http://www.wisegeek.com/what-is-web-application-scaffolding.htm&lt;br /&gt;
#http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm&lt;br /&gt;
#http://cpan.uwinnipeg.ca/htdocs/Scaffold/Scaffold.html&lt;br /&gt;
&lt;br /&gt;
==MediaSite==&lt;br /&gt;
&lt;br /&gt;
# http://www.asp.net/aspnet-in-net-35-sp1/videos/getting-started-with-dynamic-data&lt;br /&gt;
#http://www.youtube.com/watch?v=zV6aueUh8Bs&lt;br /&gt;
#http://www.youtube.com/watch?v=LWoCfTyWG_E&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_2d_dg&amp;diff=36220</id>
		<title>CSC/ECE 517 Fall 2010/ch2 2d dg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_2d_dg&amp;diff=36220"/>
		<updated>2010-09-22T23:14:56Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and Evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What Scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Example of Scaffolding in CRUD Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -8	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -9	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -10	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -11 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
&lt;br /&gt;
Sample auto generated code for the above example is as below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Controller for car in cars_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CarsController &amp;lt; ApplicationController&lt;br /&gt;
  # GET /cars&lt;br /&gt;
  # GET /cars.xml&lt;br /&gt;
  def index&lt;br /&gt;
    @cars = Car.all&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # index.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @cars }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1&lt;br /&gt;
  # GET /cars/1.xml&lt;br /&gt;
  def show&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # show.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/new&lt;br /&gt;
  # GET /cars/new.xml&lt;br /&gt;
  def new&lt;br /&gt;
    @car = Car.new&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # new.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1/edit&lt;br /&gt;
  def edit&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # POST /cars&lt;br /&gt;
  # POST /cars.xml&lt;br /&gt;
  def create&lt;br /&gt;
    @car = Car.new(params[:car])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.save&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully created.') }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car, :status =&amp;gt; :created, :location =&amp;gt; @car }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;new&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # PUT /cars/1&lt;br /&gt;
  # PUT /cars/1.xml&lt;br /&gt;
  def update&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.update_attributes(params[:car])&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully updated.') }&lt;br /&gt;
        format.xml  { head :ok }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;edit&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # DELETE /cars/1&lt;br /&gt;
  # DELETE /cars/1.xml&lt;br /&gt;
  def destroy&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
    @car.destroy&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html { redirect_to(cars_url) }&lt;br /&gt;
      format.xml  { head :ok }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Sample view file for EDIT generated in views-&amp;gt;cars-&amp;gt;edit.html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Editing car&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;% form_for(@car) do |f| %&amp;gt;&lt;br /&gt;
  &amp;lt;%= f.error_messages %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :color %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :color %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :maker %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :maker %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :model %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :model %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :year %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.date_select :year %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.submit 'Update' %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= link_to 'Show', @car %&amp;gt; |&lt;br /&gt;
&amp;lt;%= link_to 'Back', cars_path %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Database migrate file generated in db-&amp;gt;migrate&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def self.up&lt;br /&gt;
    create_table :cars do |t|&lt;br /&gt;
      t.string :color&lt;br /&gt;
      t.string :maker&lt;br /&gt;
      t.integer :model&lt;br /&gt;
      t.date :year&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.down&lt;br /&gt;
    drop_table :cars&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Database schema generated in db-&amp;gt;schema.rb file&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ActiveRecord::Schema.define(:version =&amp;gt; 20100919144829) do&lt;br /&gt;
&lt;br /&gt;
  create_table &amp;quot;cars&amp;quot;, :force =&amp;gt; true do |t|&lt;br /&gt;
    t.string   &amp;quot;color&amp;quot;&lt;br /&gt;
    t.string   &amp;quot;maker&amp;quot;&lt;br /&gt;
    t.integer  &amp;quot;model&amp;quot;&lt;br /&gt;
    t.date     &amp;quot;year&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;created_at&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;updated_at&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Dynamic Scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
==Other Examples==&lt;br /&gt;
A more detailed listing of examples of scaffolding in various other web frameworks can be found in last year's treatment of the same topic here.&lt;br /&gt;
&lt;br /&gt;
http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2009/wiki1b_9_ss&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
You can go through some of the other frameworks to create scaffold web applications.&lt;br /&gt;
# [http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm CakePHP Framework]&lt;br /&gt;
# [http://www.grails.org/Scaffolding Grails Framework]&lt;br /&gt;
#[http://msdn.microsoft.com/en-us/library/ee377606.aspx ASP.NET Framework]&lt;br /&gt;
#[http://www.ntchosting.com/php/frameworks/codeigniter/ Codeigniter]&lt;br /&gt;
#[http://www.myeclipseide.com/me4s/features/iphone-scaffolding.php iPhone]&lt;br /&gt;
#[http://wiki.netbeans.org/JsfCrudGenerator70 NetBeans CRUD Generator]&lt;br /&gt;
&lt;br /&gt;
=Bibiliography=&lt;br /&gt;
==References==&lt;br /&gt;
	&lt;br /&gt;
#Programming Ruby(2nd Edition): The Pragmatic Programmers' Guide (Pragmatic Programmers Series),  by Dave Thomas, Andy Hunt, Andrew Hunt, Chad Fowler, Chad Fowler: Publisher: Pragmatic Bookshelf&lt;br /&gt;
#Agile Web Development with Rails, 3rd ed. by Dave Thomas, David Heinemeier Hansson, David Hansson, Publisher: Pragmatic Bookshelf&lt;br /&gt;
#http://msdn.microsoft.com/en-us/library/cc488469.aspx&lt;br /&gt;
#http://guides.rubyonrails.org/getting_started.html&lt;br /&gt;
&lt;br /&gt;
==External Sites==&lt;br /&gt;
&lt;br /&gt;
#http://en.wikipedia.org/wiki/Scaffolding_Theory&lt;br /&gt;
#http://www.wisegeek.com/what-is-web-application-scaffolding.htm&lt;br /&gt;
#http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm&lt;br /&gt;
#http://cpan.uwinnipeg.ca/htdocs/Scaffold/Scaffold.html&lt;br /&gt;
&lt;br /&gt;
==MediaSite==&lt;br /&gt;
&lt;br /&gt;
# http://www.asp.net/aspnet-in-net-35-sp1/videos/getting-started-with-dynamic-data&lt;br /&gt;
#http://www.youtube.com/watch?v=zV6aueUh8Bs&lt;br /&gt;
#http://www.youtube.com/watch?v=LWoCfTyWG_E&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_2d_dg&amp;diff=36219</id>
		<title>CSC/ECE 517 Fall 2010/ch2 2d dg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2010/ch2_2d_dg&amp;diff=36219"/>
		<updated>2010-09-22T23:14:28Z</updated>

		<summary type="html">&lt;p&gt;ISuite: Updated Version of Scaffolding in Web Application Frameworks&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and Evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What Scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Example of Scaffolding in CRUD Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -8	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -9	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -10	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -11 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
&lt;br /&gt;
Sample auto generated code for the above example is as below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Controller for car in cars_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CarsController &amp;lt; ApplicationController&lt;br /&gt;
  # GET /cars&lt;br /&gt;
  # GET /cars.xml&lt;br /&gt;
  def index&lt;br /&gt;
    @cars = Car.all&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # index.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @cars }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1&lt;br /&gt;
  # GET /cars/1.xml&lt;br /&gt;
  def show&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # show.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/new&lt;br /&gt;
  # GET /cars/new.xml&lt;br /&gt;
  def new&lt;br /&gt;
    @car = Car.new&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # new.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1/edit&lt;br /&gt;
  def edit&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # POST /cars&lt;br /&gt;
  # POST /cars.xml&lt;br /&gt;
  def create&lt;br /&gt;
    @car = Car.new(params[:car])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.save&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully created.') }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car, :status =&amp;gt; :created, :location =&amp;gt; @car }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;new&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # PUT /cars/1&lt;br /&gt;
  # PUT /cars/1.xml&lt;br /&gt;
  def update&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.update_attributes(params[:car])&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully updated.') }&lt;br /&gt;
        format.xml  { head :ok }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;edit&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # DELETE /cars/1&lt;br /&gt;
  # DELETE /cars/1.xml&lt;br /&gt;
  def destroy&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
    @car.destroy&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html { redirect_to(cars_url) }&lt;br /&gt;
      format.xml  { head :ok }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Sample view file for EDIT generated in views-&amp;gt;cars-&amp;gt;edit.html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Editing car&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;% form_for(@car) do |f| %&amp;gt;&lt;br /&gt;
  &amp;lt;%= f.error_messages %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :color %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :color %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :maker %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :maker %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :model %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :model %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :year %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.date_select :year %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.submit 'Update' %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= link_to 'Show', @car %&amp;gt; |&lt;br /&gt;
&amp;lt;%= link_to 'Back', cars_path %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Database migrate file generated in db-&amp;gt;migrate&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def self.up&lt;br /&gt;
    create_table :cars do |t|&lt;br /&gt;
      t.string :color&lt;br /&gt;
      t.string :maker&lt;br /&gt;
      t.integer :model&lt;br /&gt;
      t.date :year&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.down&lt;br /&gt;
    drop_table :cars&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Database schema generated in db-&amp;gt;schema.rb file&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ActiveRecord::Schema.define(:version =&amp;gt; 20100919144829) do&lt;br /&gt;
&lt;br /&gt;
  create_table &amp;quot;cars&amp;quot;, :force =&amp;gt; true do |t|&lt;br /&gt;
    t.string   &amp;quot;color&amp;quot;&lt;br /&gt;
    t.string   &amp;quot;maker&amp;quot;&lt;br /&gt;
    t.integer  &amp;quot;model&amp;quot;&lt;br /&gt;
    t.date     &amp;quot;year&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;created_at&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;updated_at&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Dynamic Scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
==Other Examples==&lt;br /&gt;
A more detailed listing of examples of scaffolding in various other web frameworks can be found in last year's treatment of the same topic here.&lt;br /&gt;
&lt;br /&gt;
http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2009/wiki1b_9_ss&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
You can go through some of the other frameworks to create scaffold web applications.&lt;br /&gt;
# [http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm CakePHP Framework]&lt;br /&gt;
# [http://www.grails.org/Scaffolding Grails Framework]&lt;br /&gt;
#[http://msdn.microsoft.com/en-us/library/ee377606.aspx ASP.NET Framework]&lt;br /&gt;
#[http://www.ntchosting.com/php/frameworks/codeigniter/ Codeigniter]&lt;br /&gt;
#[http://www.myeclipseide.com/me4s/features/iphone-scaffolding.php iPhone]&lt;br /&gt;
#[http://wiki.netbeans.org/JsfCrudGenerator70 NetBeans CRUD Generator]&lt;br /&gt;
&lt;br /&gt;
=Bibiliography=&lt;br /&gt;
==References==&lt;br /&gt;
	&lt;br /&gt;
#Programming Ruby(2nd Edition): The Pragmatic Programmers' Guide (Pragmatic Programmers Series),  by Dave Thomas, Andy Hunt, Andrew Hunt, Chad Fowler, Chad Fowler: Publisher: Pragmatic Bookshelf&lt;br /&gt;
#Agile Web Development with Rails, 3rd ed. by Dave Thomas, David Heinemeier Hansson, David Hansson, Publisher: Pragmatic Bookshelf&lt;br /&gt;
#http://msdn.microsoft.com/en-us/library/cc488469.aspx&lt;br /&gt;
#http://guides.rubyonrails.org/getting_started.html&lt;br /&gt;
&lt;br /&gt;
==External Sites==&lt;br /&gt;
&lt;br /&gt;
#http://en.wikipedia.org/wiki/Scaffolding_Theory&lt;br /&gt;
#http://www.wisegeek.com/what-is-web-application-scaffolding.htm&lt;br /&gt;
#http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm&lt;br /&gt;
#http://cpan.uwinnipeg.ca/htdocs/Scaffold/Scaffold.html&lt;br /&gt;
&lt;br /&gt;
==MediaSite==&lt;br /&gt;
&lt;br /&gt;
# http://www.asp.net/aspnet-in-net-35-sp1/videos/getting-started-with-dynamic-data&lt;br /&gt;
#http://www.youtube.com/watch?v=zV6aueUh8Bs&lt;br /&gt;
#http://www.youtube.com/watch?v=LWoCfTyWG_E&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36218</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36218"/>
		<updated>2010-09-22T23:12:34Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and Evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What Scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Example of Scaffolding in CRUD Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -8	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -9	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -10	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -11 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
&lt;br /&gt;
Sample auto generated code for the above example is as below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Controller for car in cars_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CarsController &amp;lt; ApplicationController&lt;br /&gt;
  # GET /cars&lt;br /&gt;
  # GET /cars.xml&lt;br /&gt;
  def index&lt;br /&gt;
    @cars = Car.all&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # index.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @cars }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1&lt;br /&gt;
  # GET /cars/1.xml&lt;br /&gt;
  def show&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # show.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/new&lt;br /&gt;
  # GET /cars/new.xml&lt;br /&gt;
  def new&lt;br /&gt;
    @car = Car.new&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # new.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1/edit&lt;br /&gt;
  def edit&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # POST /cars&lt;br /&gt;
  # POST /cars.xml&lt;br /&gt;
  def create&lt;br /&gt;
    @car = Car.new(params[:car])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.save&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully created.') }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car, :status =&amp;gt; :created, :location =&amp;gt; @car }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;new&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # PUT /cars/1&lt;br /&gt;
  # PUT /cars/1.xml&lt;br /&gt;
  def update&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.update_attributes(params[:car])&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully updated.') }&lt;br /&gt;
        format.xml  { head :ok }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;edit&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # DELETE /cars/1&lt;br /&gt;
  # DELETE /cars/1.xml&lt;br /&gt;
  def destroy&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
    @car.destroy&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html { redirect_to(cars_url) }&lt;br /&gt;
      format.xml  { head :ok }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Sample view file for EDIT generated in views-&amp;gt;cars-&amp;gt;edit.html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Editing car&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;% form_for(@car) do |f| %&amp;gt;&lt;br /&gt;
  &amp;lt;%= f.error_messages %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :color %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :color %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :maker %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :maker %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :model %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :model %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :year %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.date_select :year %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.submit 'Update' %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= link_to 'Show', @car %&amp;gt; |&lt;br /&gt;
&amp;lt;%= link_to 'Back', cars_path %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Database migrate file generated in db-&amp;gt;migrate&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def self.up&lt;br /&gt;
    create_table :cars do |t|&lt;br /&gt;
      t.string :color&lt;br /&gt;
      t.string :maker&lt;br /&gt;
      t.integer :model&lt;br /&gt;
      t.date :year&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.down&lt;br /&gt;
    drop_table :cars&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Database schema generated in db-&amp;gt;schema.rb file&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ActiveRecord::Schema.define(:version =&amp;gt; 20100919144829) do&lt;br /&gt;
&lt;br /&gt;
  create_table &amp;quot;cars&amp;quot;, :force =&amp;gt; true do |t|&lt;br /&gt;
    t.string   &amp;quot;color&amp;quot;&lt;br /&gt;
    t.string   &amp;quot;maker&amp;quot;&lt;br /&gt;
    t.integer  &amp;quot;model&amp;quot;&lt;br /&gt;
    t.date     &amp;quot;year&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;created_at&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;updated_at&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Dynamic Scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
==Other Examples==&lt;br /&gt;
A more detailed listing of examples of scaffolding in various other web frameworks can be found in last year's treatment of the same topic here.&lt;br /&gt;
&lt;br /&gt;
http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2009/wiki1b_9_ss&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
You can go through some of the other frameworks to create scaffold web applications.&lt;br /&gt;
# [http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm CakePHP Framework]&lt;br /&gt;
# [http://www.grails.org/Scaffolding Grails Framework]&lt;br /&gt;
#[http://msdn.microsoft.com/en-us/library/ee377606.aspx ASP.NET Framework]&lt;br /&gt;
#[http://www.ntchosting.com/php/frameworks/codeigniter/ Codeigniter]&lt;br /&gt;
#[http://www.myeclipseide.com/me4s/features/iphone-scaffolding.php iPhone]&lt;br /&gt;
#[http://wiki.netbeans.org/JsfCrudGenerator70 NetBeans CRUD Generator]&lt;br /&gt;
&lt;br /&gt;
=Bibiliography=&lt;br /&gt;
==References==&lt;br /&gt;
	&lt;br /&gt;
#Programming Ruby(2nd Edition): The Pragmatic Programmers' Guide (Pragmatic Programmers Series),  by Dave Thomas, Andy Hunt, Andrew Hunt, Chad Fowler, Chad Fowler: Publisher: Pragmatic Bookshelf&lt;br /&gt;
#Agile Web Development with Rails, 3rd ed. by Dave Thomas, David Heinemeier Hansson, David Hansson, Publisher: Pragmatic Bookshelf&lt;br /&gt;
#http://msdn.microsoft.com/en-us/library/cc488469.aspx&lt;br /&gt;
#http://guides.rubyonrails.org/getting_started.html&lt;br /&gt;
&lt;br /&gt;
==External Sites==&lt;br /&gt;
&lt;br /&gt;
#http://en.wikipedia.org/wiki/Scaffolding_Theory&lt;br /&gt;
#http://www.wisegeek.com/what-is-web-application-scaffolding.htm&lt;br /&gt;
#http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm&lt;br /&gt;
#http://cpan.uwinnipeg.ca/htdocs/Scaffold/Scaffold.html&lt;br /&gt;
&lt;br /&gt;
==MediaSite==&lt;br /&gt;
&lt;br /&gt;
# http://www.asp.net/aspnet-in-net-35-sp1/videos/getting-started-with-dynamic-data&lt;br /&gt;
#http://www.youtube.com/watch?v=zV6aueUh8Bs&lt;br /&gt;
#http://www.youtube.com/watch?v=LWoCfTyWG_E&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36217</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36217"/>
		<updated>2010-09-22T23:10:24Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and Evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What Scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Example of Scaffolding in CRUD Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -8	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -9	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -10	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -11 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
&lt;br /&gt;
Sample auto generated code for the above example is as below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Controller for car in cars_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CarsController &amp;lt; ApplicationController&lt;br /&gt;
  # GET /cars&lt;br /&gt;
  # GET /cars.xml&lt;br /&gt;
  def index&lt;br /&gt;
    @cars = Car.all&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # index.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @cars }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1&lt;br /&gt;
  # GET /cars/1.xml&lt;br /&gt;
  def show&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # show.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/new&lt;br /&gt;
  # GET /cars/new.xml&lt;br /&gt;
  def new&lt;br /&gt;
    @car = Car.new&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # new.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1/edit&lt;br /&gt;
  def edit&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # POST /cars&lt;br /&gt;
  # POST /cars.xml&lt;br /&gt;
  def create&lt;br /&gt;
    @car = Car.new(params[:car])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.save&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully created.') }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car, :status =&amp;gt; :created, :location =&amp;gt; @car }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;new&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # PUT /cars/1&lt;br /&gt;
  # PUT /cars/1.xml&lt;br /&gt;
  def update&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.update_attributes(params[:car])&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully updated.') }&lt;br /&gt;
        format.xml  { head :ok }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;edit&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # DELETE /cars/1&lt;br /&gt;
  # DELETE /cars/1.xml&lt;br /&gt;
  def destroy&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
    @car.destroy&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html { redirect_to(cars_url) }&lt;br /&gt;
      format.xml  { head :ok }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Sample view file for EDIT generated in views-&amp;gt;cars-&amp;gt;edit.html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Editing car&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;% form_for(@car) do |f| %&amp;gt;&lt;br /&gt;
  &amp;lt;%= f.error_messages %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :color %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :color %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :maker %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :maker %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :model %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :model %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :year %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.date_select :year %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.submit 'Update' %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= link_to 'Show', @car %&amp;gt; |&lt;br /&gt;
&amp;lt;%= link_to 'Back', cars_path %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Database migrate file generated in db-&amp;gt;migrate&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def self.up&lt;br /&gt;
    create_table :cars do |t|&lt;br /&gt;
      t.string :color&lt;br /&gt;
      t.string :maker&lt;br /&gt;
      t.integer :model&lt;br /&gt;
      t.date :year&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.down&lt;br /&gt;
    drop_table :cars&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Database schema generated in db-&amp;gt;schema.rb file&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ActiveRecord::Schema.define(:version =&amp;gt; 20100919144829) do&lt;br /&gt;
&lt;br /&gt;
  create_table &amp;quot;cars&amp;quot;, :force =&amp;gt; true do |t|&lt;br /&gt;
    t.string   &amp;quot;color&amp;quot;&lt;br /&gt;
    t.string   &amp;quot;maker&amp;quot;&lt;br /&gt;
    t.integer  &amp;quot;model&amp;quot;&lt;br /&gt;
    t.date     &amp;quot;year&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;created_at&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;updated_at&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Dynamic Scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
A more detailed listing of examples of scaffolding in various other web frameworks can be found in last year's treatment of the same topic here.&lt;br /&gt;
http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2009/wiki1b_9_ss&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
You can go through some of the other frameworks to create scaffold web applications.&lt;br /&gt;
# [http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm CakePHP Framework]&lt;br /&gt;
# [http://www.grails.org/Scaffolding Grails Framework]&lt;br /&gt;
#[http://msdn.microsoft.com/en-us/library/ee377606.aspx ASP.NET Framework]&lt;br /&gt;
#[http://www.ntchosting.com/php/frameworks/codeigniter/ Codeigniter]&lt;br /&gt;
#[http://www.myeclipseide.com/me4s/features/iphone-scaffolding.php iPhone]&lt;br /&gt;
#[http://wiki.netbeans.org/JsfCrudGenerator70 NetBeans CRUD Generator]&lt;br /&gt;
&lt;br /&gt;
=Bibiliography=&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
	&lt;br /&gt;
#Programming Ruby(2nd Edition): The Pragmatic Programmers' Guide (Pragmatic Programmers Series),  by Dave Thomas, Andy Hunt, Andrew Hunt, Chad Fowler, Chad Fowler: Publisher: Pragmatic Bookshelf&lt;br /&gt;
#Agile Web Development with Rails, 3rd ed. by Dave Thomas, David Heinemeier Hansson, David Hansson, Publisher: Pragmatic Bookshelf&lt;br /&gt;
#http://msdn.microsoft.com/en-us/library/cc488469.aspx&lt;br /&gt;
#http://guides.rubyonrails.org/getting_started.html&lt;br /&gt;
&lt;br /&gt;
==External Sites==&lt;br /&gt;
&lt;br /&gt;
#http://en.wikipedia.org/wiki/Scaffolding_Theory&lt;br /&gt;
#http://www.wisegeek.com/what-is-web-application-scaffolding.htm&lt;br /&gt;
#http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm&lt;br /&gt;
#http://cpan.uwinnipeg.ca/htdocs/Scaffold/Scaffold.html&lt;br /&gt;
&lt;br /&gt;
==MediaSite==&lt;br /&gt;
&lt;br /&gt;
# http://www.asp.net/aspnet-in-net-35-sp1/videos/getting-started-with-dynamic-data&lt;br /&gt;
#http://www.youtube.com/watch?v=zV6aueUh8Bs&lt;br /&gt;
#http://www.youtube.com/watch?v=LWoCfTyWG_E&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36216</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36216"/>
		<updated>2010-09-22T23:07:57Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and Evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What Scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Example of Scaffolding in CRUD Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -8	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -9	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -10	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -11 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
&lt;br /&gt;
Sample auto generated code for the above example is as below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Controller for car in cars_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CarsController &amp;lt; ApplicationController&lt;br /&gt;
  # GET /cars&lt;br /&gt;
  # GET /cars.xml&lt;br /&gt;
  def index&lt;br /&gt;
    @cars = Car.all&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # index.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @cars }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1&lt;br /&gt;
  # GET /cars/1.xml&lt;br /&gt;
  def show&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # show.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/new&lt;br /&gt;
  # GET /cars/new.xml&lt;br /&gt;
  def new&lt;br /&gt;
    @car = Car.new&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # new.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1/edit&lt;br /&gt;
  def edit&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # POST /cars&lt;br /&gt;
  # POST /cars.xml&lt;br /&gt;
  def create&lt;br /&gt;
    @car = Car.new(params[:car])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.save&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully created.') }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car, :status =&amp;gt; :created, :location =&amp;gt; @car }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;new&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # PUT /cars/1&lt;br /&gt;
  # PUT /cars/1.xml&lt;br /&gt;
  def update&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.update_attributes(params[:car])&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully updated.') }&lt;br /&gt;
        format.xml  { head :ok }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;edit&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # DELETE /cars/1&lt;br /&gt;
  # DELETE /cars/1.xml&lt;br /&gt;
  def destroy&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
    @car.destroy&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html { redirect_to(cars_url) }&lt;br /&gt;
      format.xml  { head :ok }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Sample view file for EDIT generated in views-&amp;gt;cars-&amp;gt;edit.html.erb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Editing car&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;% form_for(@car) do |f| %&amp;gt;&lt;br /&gt;
  &amp;lt;%= f.error_messages %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :color %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :color %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :maker %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :maker %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :model %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.text_field :model %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.label :year %&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.date_select :year %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;%= f.submit 'Update' %&amp;gt;&lt;br /&gt;
  &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= link_to 'Show', @car %&amp;gt; |&lt;br /&gt;
&amp;lt;%= link_to 'Back', cars_path %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Database migrate file generated in db-&amp;gt;migrate&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
  def self.up&lt;br /&gt;
    create_table :cars do |t|&lt;br /&gt;
      t.string :color&lt;br /&gt;
      t.string :maker&lt;br /&gt;
      t.integer :model&lt;br /&gt;
      t.date :year&lt;br /&gt;
&lt;br /&gt;
      t.timestamps&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.down&lt;br /&gt;
    drop_table :cars&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Database schema generated in db-&amp;gt;schema.rb file&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ActiveRecord::Schema.define(:version =&amp;gt; 20100919144829) do&lt;br /&gt;
&lt;br /&gt;
  create_table &amp;quot;cars&amp;quot;, :force =&amp;gt; true do |t|&lt;br /&gt;
    t.string   &amp;quot;color&amp;quot;&lt;br /&gt;
    t.string   &amp;quot;maker&amp;quot;&lt;br /&gt;
    t.integer  &amp;quot;model&amp;quot;&lt;br /&gt;
    t.date     &amp;quot;year&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;created_at&amp;quot;&lt;br /&gt;
    t.datetime &amp;quot;updated_at&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Dynamic Scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
You can go through some of the other frameworks to create scaffold web applications.&lt;br /&gt;
# [http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm CakePHP Framework]&lt;br /&gt;
# [http://www.grails.org/Scaffolding Grails Framework]&lt;br /&gt;
#[http://msdn.microsoft.com/en-us/library/ee377606.aspx ASP.NET Framework]&lt;br /&gt;
#[http://www.ntchosting.com/php/frameworks/codeigniter/ Codeigniter]&lt;br /&gt;
#[http://www.myeclipseide.com/me4s/features/iphone-scaffolding.php iPhone]&lt;br /&gt;
#[http://wiki.netbeans.org/JsfCrudGenerator70 NetBeans CRUD Generator]&lt;br /&gt;
&lt;br /&gt;
=Bibiliography=&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
	&lt;br /&gt;
#Programming Ruby(2nd Edition): The Pragmatic Programmers' Guide (Pragmatic Programmers Series),  by Dave Thomas, Andy Hunt, Andrew Hunt, Chad Fowler, Chad Fowler: Publisher: Pragmatic Bookshelf&lt;br /&gt;
#Agile Web Development with Rails, 3rd ed. by Dave Thomas, David Heinemeier Hansson, David Hansson, Publisher: Pragmatic Bookshelf&lt;br /&gt;
#http://msdn.microsoft.com/en-us/library/cc488469.aspx&lt;br /&gt;
#http://guides.rubyonrails.org/getting_started.html&lt;br /&gt;
&lt;br /&gt;
==External Sites==&lt;br /&gt;
&lt;br /&gt;
#http://en.wikipedia.org/wiki/Scaffolding_Theory&lt;br /&gt;
#http://www.wisegeek.com/what-is-web-application-scaffolding.htm&lt;br /&gt;
#http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm&lt;br /&gt;
#http://cpan.uwinnipeg.ca/htdocs/Scaffold/Scaffold.html&lt;br /&gt;
&lt;br /&gt;
==MediaSite==&lt;br /&gt;
&lt;br /&gt;
# http://www.asp.net/aspnet-in-net-35-sp1/videos/getting-started-with-dynamic-data&lt;br /&gt;
#http://www.youtube.com/watch?v=zV6aueUh8Bs&lt;br /&gt;
#http://www.youtube.com/watch?v=LWoCfTyWG_E&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36211</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36211"/>
		<updated>2010-09-22T23:04:12Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and Evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What Scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Example of Scaffolding in CRUD Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -8	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -9	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -10	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -11 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
Sample auto generated code for the above example is as below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Controller for car in cars_controller.rb&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CarsController &amp;lt; ApplicationController&lt;br /&gt;
  # GET /cars&lt;br /&gt;
  # GET /cars.xml&lt;br /&gt;
  def index&lt;br /&gt;
    @cars = Car.all&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # index.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @cars }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1&lt;br /&gt;
  # GET /cars/1.xml&lt;br /&gt;
  def show&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # show.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/new&lt;br /&gt;
  # GET /cars/new.xml&lt;br /&gt;
  def new&lt;br /&gt;
    @car = Car.new&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html # new.html.erb&lt;br /&gt;
      format.xml  { render :xml =&amp;gt; @car }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /cars/1/edit&lt;br /&gt;
  def edit&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # POST /cars&lt;br /&gt;
  # POST /cars.xml&lt;br /&gt;
  def create&lt;br /&gt;
    @car = Car.new(params[:car])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.save&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully created.') }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car, :status =&amp;gt; :created, :location =&amp;gt; @car }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;new&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # PUT /cars/1&lt;br /&gt;
  # PUT /cars/1.xml&lt;br /&gt;
  def update&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      if @car.update_attributes(params[:car])&lt;br /&gt;
        format.html { redirect_to(@car, :notice =&amp;gt; 'Car was successfully updated.') }&lt;br /&gt;
        format.xml  { head :ok }&lt;br /&gt;
      else&lt;br /&gt;
        format.html { render :action =&amp;gt; &amp;quot;edit&amp;quot; }&lt;br /&gt;
        format.xml  { render :xml =&amp;gt; @car.errors, :status =&amp;gt; :unprocessable_entity }&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # DELETE /cars/1&lt;br /&gt;
  # DELETE /cars/1.xml&lt;br /&gt;
  def destroy&lt;br /&gt;
    @car = Car.find(params[:id])&lt;br /&gt;
    @car.destroy&lt;br /&gt;
&lt;br /&gt;
    respond_to do |format|&lt;br /&gt;
      format.html { redirect_to(cars_url) }&lt;br /&gt;
      format.xml  { head :ok }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==Dynamic Scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
You can go through some of the other frameworks to create scaffold web applications.&lt;br /&gt;
# [http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm CakePHP Framework]&lt;br /&gt;
# [http://www.grails.org/Scaffolding Grails Framework]&lt;br /&gt;
#[http://msdn.microsoft.com/en-us/library/ee377606.aspx ASP.NET Framework]&lt;br /&gt;
#[http://www.ntchosting.com/php/frameworks/codeigniter/ Codeigniter]&lt;br /&gt;
#[http://www.myeclipseide.com/me4s/features/iphone-scaffolding.php iPhone]&lt;br /&gt;
#[http://wiki.netbeans.org/JsfCrudGenerator70 NetBeans CRUD Generator]&lt;br /&gt;
&lt;br /&gt;
=Bibiliography=&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
	&lt;br /&gt;
#Programming Ruby(2nd Edition): The Pragmatic Programmers' Guide (Pragmatic Programmers Series),  by Dave Thomas, Andy Hunt, Andrew Hunt, Chad Fowler, Chad Fowler: Publisher: Pragmatic Bookshelf&lt;br /&gt;
#Agile Web Development with Rails, 3rd ed. by Dave Thomas, David Heinemeier Hansson, David Hansson, Publisher: Pragmatic Bookshelf&lt;br /&gt;
#http://msdn.microsoft.com/en-us/library/cc488469.aspx&lt;br /&gt;
#http://guides.rubyonrails.org/getting_started.html&lt;br /&gt;
&lt;br /&gt;
==External Sites==&lt;br /&gt;
&lt;br /&gt;
#http://en.wikipedia.org/wiki/Scaffolding_Theory&lt;br /&gt;
#http://www.wisegeek.com/what-is-web-application-scaffolding.htm&lt;br /&gt;
#http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm&lt;br /&gt;
#http://cpan.uwinnipeg.ca/htdocs/Scaffold/Scaffold.html&lt;br /&gt;
&lt;br /&gt;
==MediaSite==&lt;br /&gt;
&lt;br /&gt;
# http://www.asp.net/aspnet-in-net-35-sp1/videos/getting-started-with-dynamic-data&lt;br /&gt;
#http://www.youtube.com/watch?v=zV6aueUh8Bs&lt;br /&gt;
#http://www.youtube.com/watch?v=LWoCfTyWG_E&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36209</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36209"/>
		<updated>2010-09-22T22:54:55Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and Evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What Scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Example of Scaffolding in CRUD Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -8	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -9	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -10	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -11 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
Apart from the Rails framework, you can also go through the scaffolding approaches in other web frameworks. &lt;br /&gt;
&lt;br /&gt;
==Dynamic Scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
You can go through some of the other frameworks to create scaffold web applications.&lt;br /&gt;
# [http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm CakePHP Framework]&lt;br /&gt;
# [http://www.grails.org/Scaffolding Grails Framework]&lt;br /&gt;
#[http://msdn.microsoft.com/en-us/library/ee377606.aspx ASP.NET Framework]&lt;br /&gt;
#[http://www.ntchosting.com/php/frameworks/codeigniter/ Codeigniter]&lt;br /&gt;
#[http://www.myeclipseide.com/me4s/features/iphone-scaffolding.php iPhone]&lt;br /&gt;
#[http://wiki.netbeans.org/JsfCrudGenerator70 NetBeans CRUD Generator]&lt;br /&gt;
&lt;br /&gt;
=Bibiliography=&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
	&lt;br /&gt;
#Programming Ruby(2nd Edition): The Pragmatic Programmers' Guide (Pragmatic Programmers Series),  by Dave Thomas, Andy Hunt, Andrew Hunt, Chad Fowler, Chad Fowler: Publisher: Pragmatic Bookshelf&lt;br /&gt;
#Agile Web Development with Rails, 3rd ed. by Dave Thomas, David Heinemeier Hansson, David Hansson, Publisher: Pragmatic Bookshelf&lt;br /&gt;
#http://msdn.microsoft.com/en-us/library/cc488469.aspx&lt;br /&gt;
#http://guides.rubyonrails.org/getting_started.html&lt;br /&gt;
&lt;br /&gt;
==External Sites==&lt;br /&gt;
&lt;br /&gt;
#http://en.wikipedia.org/wiki/Scaffolding_Theory&lt;br /&gt;
#http://www.wisegeek.com/what-is-web-application-scaffolding.htm&lt;br /&gt;
#http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm&lt;br /&gt;
#http://cpan.uwinnipeg.ca/htdocs/Scaffold/Scaffold.html&lt;br /&gt;
&lt;br /&gt;
==MediaSite==&lt;br /&gt;
&lt;br /&gt;
# http://www.asp.net/aspnet-in-net-35-sp1/videos/getting-started-with-dynamic-data&lt;br /&gt;
#http://www.youtube.com/watch?v=zV6aueUh8Bs&lt;br /&gt;
#http://www.youtube.com/watch?v=LWoCfTyWG_E&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36208</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36208"/>
		<updated>2010-09-22T22:53:56Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and Evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What Scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Example of Scaffolding in CRUD Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -8	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -9	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -10	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -11 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
Apart from the Rails framework, you can also go through the scaffolding approaches in other web frameworks. &lt;br /&gt;
&lt;br /&gt;
==Dynamic Scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
You can go through some of the other frameworks to create scaffold web applications.&lt;br /&gt;
# [http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm CakePHP Framework]&lt;br /&gt;
# [http://www.grails.org/Scaffolding Grails Framework]&lt;br /&gt;
#[http://msdn.microsoft.com/en-us/library/ee377606.aspx ASP.NET Framework]&lt;br /&gt;
#[http://www.ntchosting.com/php/frameworks/codeigniter/ Codeigniter]&lt;br /&gt;
#[http://www.myeclipseide.com/me4s/features/iphone-scaffolding.php iPhone]&lt;br /&gt;
#[http://wiki.netbeans.org/JsfCrudGenerator70 NetBeans CRUD Generator]&lt;br /&gt;
&lt;br /&gt;
=Bibiliography=&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
	&lt;br /&gt;
#Programming Ruby(2nd Edition): The Pragmatic Programmers' Guide (Pragmatic Programmers Series),  by Dave Thomas, Andy Hunt, Andrew Hunt, Chad Fowler, Chad Fowler: Publisher: Pragmatic Bookshelf&lt;br /&gt;
#http://msdn.microsoft.com/en-us/library/cc488469.aspx&lt;br /&gt;
#http://guides.rubyonrails.org/getting_started.html&lt;br /&gt;
&lt;br /&gt;
==External Sites==&lt;br /&gt;
&lt;br /&gt;
#http://en.wikipedia.org/wiki/Scaffolding_Theory&lt;br /&gt;
#http://www.wisegeek.com/what-is-web-application-scaffolding.htm&lt;br /&gt;
#http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm&lt;br /&gt;
#http://cpan.uwinnipeg.ca/htdocs/Scaffold/Scaffold.html&lt;br /&gt;
&lt;br /&gt;
==MediaSite==&lt;br /&gt;
&lt;br /&gt;
# http://www.asp.net/aspnet-in-net-35-sp1/videos/getting-started-with-dynamic-data&lt;br /&gt;
#http://www.youtube.com/watch?v=zV6aueUh8Bs&lt;br /&gt;
#http://www.youtube.com/watch?v=LWoCfTyWG_E&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36206</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36206"/>
		<updated>2010-09-22T22:53:16Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and Evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What Scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Example of Scaffolding in CRUD Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -8	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -9	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -10	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -11 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
Apart from the Rails framework, you can also go through the scaffolding approaches in other web frameworks. &lt;br /&gt;
&lt;br /&gt;
==Dynamic Scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
You can go through some of the other frameworks to create scaffold web applications.&lt;br /&gt;
# [http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm CakePHP Framework]&lt;br /&gt;
# [http://www.grails.org/Scaffolding Grails Framework]&lt;br /&gt;
#[http://msdn.microsoft.com/en-us/library/ee377606.aspx ASP.NET Framework]&lt;br /&gt;
#[http://www.ntchosting.com/php/frameworks/codeigniter/ Codeigniter]&lt;br /&gt;
#[http://www.myeclipseide.com/me4s/features/iphone-scaffolding.php iPhone]&lt;br /&gt;
#[http://wiki.netbeans.org/JsfCrudGenerator70 NetBeans CRUD Generator]&lt;br /&gt;
&lt;br /&gt;
=Bibiliography=&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
	&lt;br /&gt;
#Programming Ruby(2nd Edition): The Pragmatic Programmers' Guide (Pragmatic Programmers Series),  by Dave Thomas, Andy Hunt, Andrew Hunt, Chad Fowler, Chad Fowler&lt;br /&gt;
   Publisher: Pragmatic Bookshelf&lt;br /&gt;
#http://msdn.microsoft.com/en-us/library/cc488469.aspx&lt;br /&gt;
#http://guides.rubyonrails.org/getting_started.html&lt;br /&gt;
&lt;br /&gt;
==External Sites==&lt;br /&gt;
&lt;br /&gt;
#http://en.wikipedia.org/wiki/Scaffolding_Theory&lt;br /&gt;
#http://www.wisegeek.com/what-is-web-application-scaffolding.htm&lt;br /&gt;
#http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm&lt;br /&gt;
#http://cpan.uwinnipeg.ca/htdocs/Scaffold/Scaffold.html&lt;br /&gt;
&lt;br /&gt;
==MediaSite==&lt;br /&gt;
&lt;br /&gt;
# http://www.asp.net/aspnet-in-net-35-sp1/videos/getting-started-with-dynamic-data&lt;br /&gt;
#http://www.youtube.com/watch?v=zV6aueUh8Bs&lt;br /&gt;
#http://www.youtube.com/watch?v=LWoCfTyWG_E&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36204</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36204"/>
		<updated>2010-09-22T22:48:42Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and Evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What Scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Example of Scaffolding in CRUD Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -8	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -9	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -10	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -11 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
Apart from the Rails framework, you can also go through the scaffolding approaches in other web frameworks. &lt;br /&gt;
&lt;br /&gt;
==Dynamic Scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
You can go through some of the other frameworks to create scaffold web applications.&lt;br /&gt;
# [http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm CakePHP Framework]&lt;br /&gt;
# [http://www.grails.org/Scaffolding Grails Framework]&lt;br /&gt;
#[http://msdn.microsoft.com/en-us/library/ee377606.aspx ASP.NET Framework]&lt;br /&gt;
#[http://www.ntchosting.com/php/frameworks/codeigniter/ Codeigniter]&lt;br /&gt;
#[http://www.myeclipseide.com/me4s/features/iphone-scaffolding.php iPhone]&lt;br /&gt;
#[http://wiki.netbeans.org/JsfCrudGenerator70 NetBeans CRUD Generator]&lt;br /&gt;
&lt;br /&gt;
=Bibiliography=&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
	&lt;br /&gt;
#[http://msdn.microsoft.com/en-us/library/cc488469.aspx]&lt;br /&gt;
#[http://guides.rubyonrails.org/getting_started.html]&lt;br /&gt;
&lt;br /&gt;
==External Sites==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Scaffolding_Theory]&lt;br /&gt;
#[http://www.wisegeek.com/what-is-web-application-scaffolding.htm]&lt;br /&gt;
#[http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm]&lt;br /&gt;
#[http://cpan.uwinnipeg.ca/htdocs/Scaffold/Scaffold.html]&lt;br /&gt;
&lt;br /&gt;
==MediaSite==&lt;br /&gt;
&lt;br /&gt;
# http://www.asp.net/aspnet-in-net-35-sp1/videos/getting-started-with-dynamic-data&lt;br /&gt;
#http://www.youtube.com/watch?v=zV6aueUh8Bs&lt;br /&gt;
#http://www.youtube.com/watch?v=LWoCfTyWG_E&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36203</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36203"/>
		<updated>2010-09-22T22:46:47Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and Evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What Scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Example of Scaffolding in CRUD Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -8	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -9	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -10	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -11 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
Apart from the Rails framework, you can also go through the scaffolding approaches in other web frameworks. &lt;br /&gt;
&lt;br /&gt;
==Dynamic Scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
You can go through some of the other frameworks to create scaffold web applications.&lt;br /&gt;
# [http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm CakePHP Framework]&lt;br /&gt;
# [http://www.grails.org/Scaffolding Grails Framework]&lt;br /&gt;
#[http://msdn.microsoft.com/en-us/library/ee377606.aspx ASP.NET Framework]&lt;br /&gt;
#[http://www.ntchosting.com/php/frameworks/codeigniter/ Codeigniter]&lt;br /&gt;
#[http://www.myeclipseide.com/me4s/features/iphone-scaffolding.php iPhone]&lt;br /&gt;
#[http://wiki.netbeans.org/JsfCrudGenerator70 NetBeans CRUD Generator]&lt;br /&gt;
&lt;br /&gt;
=Bibiliography=&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
	&lt;br /&gt;
#[http://msdn.microsoft.com/en-us/library/cc488469.aspx]&lt;br /&gt;
#[http://guides.rubyonrails.org/getting_started.html]&lt;br /&gt;
&lt;br /&gt;
==External Sites==&lt;br /&gt;
&lt;br /&gt;
#[http://en.wikipedia.org/wiki/Scaffolding_Theory]&lt;br /&gt;
#[http://www.wisegeek.com/what-is-web-application-scaffolding.htm]&lt;br /&gt;
#[http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm]&lt;br /&gt;
#[http://cpan.uwinnipeg.ca/htdocs/Scaffold/Scaffold.html]&lt;br /&gt;
&lt;br /&gt;
==MediaSite==&lt;br /&gt;
&lt;br /&gt;
# [http://www.asp.net/aspnet-in-net-35-sp1/videos/getting-started-with-dynamic-data]&lt;br /&gt;
#[http://www.youtube.com/watch?v=zV6aueUh8Bs]&lt;br /&gt;
#[http://www.youtube.com/watch?v=LWoCfTyWG_E]&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36201</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36201"/>
		<updated>2010-09-22T22:44:17Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and Evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What Scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Example of Scaffolding in CRUD Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -8	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -9	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -10	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -11 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
Apart from the Rails framework, you can also go through the scaffolding approaches in other web frameworks. &lt;br /&gt;
&lt;br /&gt;
==Dynamic Scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
You can go through some of the other frameworks to create scaffold web applications.&lt;br /&gt;
# [http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm CakePHP Framework]&lt;br /&gt;
# [http://www.grails.org/Scaffolding Grails Framework]&lt;br /&gt;
#[http://msdn.microsoft.com/en-us/library/ee377606.aspx ASP.NET Framework]&lt;br /&gt;
#[http://www.ntchosting.com/php/frameworks/codeigniter/ Codeigniter]&lt;br /&gt;
#[http://www.myeclipseide.com/me4s/features/iphone-scaffolding.php iPhone]&lt;br /&gt;
#[http://wiki.netbeans.org/JsfCrudGenerator70 NetBeans CRUD Generator]&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36200</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36200"/>
		<updated>2010-09-22T22:42:46Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and Evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What Scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Example of Scaffolding in CRUD Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -8	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -9	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -10	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -11 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
Apart from the Rails framework, you can also go through the scaffolding approaches in other web frameworks. &lt;br /&gt;
&lt;br /&gt;
==Dynamic Scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
# [http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm CakePHP Framework]&lt;br /&gt;
# [http://www.grails.org/Scaffolding Grails Framework]&lt;br /&gt;
#[http://msdn.microsoft.com/en-us/library/ee377606.aspx ASP.NET Framework]&lt;br /&gt;
#[http://www.ntchosting.com/php/frameworks/codeigniter/ Codeigniter]&lt;br /&gt;
#[http://www.myeclipseide.com/me4s/features/iphone-scaffolding.php iPhone]&lt;br /&gt;
#[http://wiki.netbeans.org/JsfCrudGenerator70 NetBeans CRUD Generator]&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36194</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36194"/>
		<updated>2010-09-22T22:38:32Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and Evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What Scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Example of Scaffolding in CRUD Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -8	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -9	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -10	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -11 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
Apart from the Rails framework, you can also go through the scaffolding approaches in other web frameworks. &lt;br /&gt;
&lt;br /&gt;
==Dynamic Scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
Some links of the scaffolding in other software can be found below.&lt;br /&gt;
{| border=1 cellspacing=0 cellpadding=5&lt;br /&gt;
| S No.&lt;br /&gt;
|Web Frameworks&lt;br /&gt;
|Associated links&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|CakePHP&lt;br /&gt;
|[http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm CakePHP Code Generation]&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|CakePHP&lt;br /&gt;
|[http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm CakePHP Code Generation]&lt;br /&gt;
|- |1&lt;br /&gt;
|CakePHP&lt;br /&gt;
|[http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm CakePHP Code Generation]&lt;br /&gt;
|- |1&lt;br /&gt;
|CakePHP&lt;br /&gt;
|[http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm CakePHP Code Generation]&lt;br /&gt;
|- |1&lt;br /&gt;
|CakePHP&lt;br /&gt;
|[http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm CakePHP Code Generation]&lt;br /&gt;
|- &lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36191</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36191"/>
		<updated>2010-09-22T22:34:35Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and Evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What Scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Example of Scaffolding in CRUD Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -8	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -9	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -10	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -11 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
Apart from the Rails framework, you can also go through the scaffolding approaches in other web frameworks. &lt;br /&gt;
&lt;br /&gt;
==Dynamic Scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
Some links of the scaffolding in other software can be found below.&lt;br /&gt;
{| border=1 cellspacing=0 cellpadding=5&lt;br /&gt;
| S No.&lt;br /&gt;
|Web Frameworks&lt;br /&gt;
|Associated links&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|CakePHP&lt;br /&gt;
|[http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm]&lt;br /&gt;
|- &lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36188</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36188"/>
		<updated>2010-09-22T22:29:46Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and Evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What Scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Example of Scaffolding in CRUD Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -8	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -9	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -10	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -11 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
Apart from the Rails framework, you can also go through the scaffolding approaches in other web frameworks. &lt;br /&gt;
&lt;br /&gt;
==Dynamic Scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
Some links of the scaffolding in other software can be found below.&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36187</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36187"/>
		<updated>2010-09-22T22:29:01Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What Scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Example of Scaffolding in CRUD Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -8	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -9	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -10	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -11 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
Apart from the Rails framework, you can also go through the scaffolding approaches in other web frameworks. &lt;br /&gt;
&lt;br /&gt;
==Dynamic Scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
Some links of the scaffolding in other software can be found below.&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36186</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36186"/>
		<updated>2010-09-22T22:26:22Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Example of Scaffolding in CRUD Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -8	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -9	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -10	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -11 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
Apart from the Rails framework, you can also go through the scaffolding approaches in other web frameworks. &lt;br /&gt;
&lt;br /&gt;
==Dynamic scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
Some links of the scaffolding in other software can be found below.&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36185</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36185"/>
		<updated>2010-09-22T22:25:12Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Example of Scaffolding in CRUD Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It creates the db migrate file for the given model.&lt;br /&gt;
This creates the schema in db/migrate/2002301293_create_cars.rb file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class CreateCars &amp;lt; ActiveRecord::Migration&lt;br /&gt;
def self.up&lt;br /&gt;
create_table :cars do |t|&lt;br /&gt;
t.string :color&lt;br /&gt;
t.string :maker&lt;br /&gt;
t.number :model&lt;br /&gt;
t.date :year&lt;br /&gt;
t.timestamps&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def self.down&lt;br /&gt;
drop_table :cars&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -8	You then run a rake task to actually create the database tables using the migrate file.&lt;br /&gt;
&lt;br /&gt;
Step -9	Now go to Window-&amp;gt;Show View-&amp;gt;Rake&lt;br /&gt;
&lt;br /&gt;
Step -10	In the Rake window, select migrate task from the drop down box and run it.&lt;br /&gt;
&lt;br /&gt;
You can also right click the   &lt;br /&gt;
*	create_cars.rb file, &lt;br /&gt;
*	select the rake menu option and &lt;br /&gt;
*	then select migrate option.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rake db:migrate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Step -11 	You can then go to your sqlite database and check that tables have been created.&lt;br /&gt;
&lt;br /&gt;
Scaffold will always generate the tables in the Development database.&lt;br /&gt;
Apart from the Rails framework, you can also go through the scaffolding approaches in other web frameworks. &lt;br /&gt;
&lt;br /&gt;
==Dynamic scaffolding in CakePHP==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in CakePHP is a little more limited than Rails. Unlike Rails, database tables and schema are created separately in CakePHP. It follows the dynamic scaffolding paradigm where you don't need to run an external command to generate the scaffolded code, what is needed is just to define the $scaffold variable and scaffolding is taken care of.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Steps for code generation in CakePHP&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step -1	Create the database schema and the tables.&lt;br /&gt;
&lt;br /&gt;
Step -2	Each table that has to be scaffolded should have a corresponding controller.&lt;br /&gt;
&lt;br /&gt;
Step -3	That controller must define the variable $scaffold&lt;br /&gt;
For eg, considering our cars example, lets say we have a cars controller-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class CarsController extends AppController&lt;br /&gt;
    {&lt;br /&gt;
        var $scaffold;&lt;br /&gt;
    }&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&lt;br /&gt;
This will go in CarsController.php in app/controllers directory.&lt;br /&gt;
That is all that is required. The framework will now auto-generate the basic functionality for create, update, delete.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
Some links of the scaffolding in other software can be found below.&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36182</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36182"/>
		<updated>2010-09-22T22:20:51Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Example of Scaffolding in CRUD Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the [http://www.eclipse.org/  Eclipse IDE] to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36180</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36180"/>
		<updated>2010-09-22T22:20:09Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Example of Scaffolding in CRUD Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the[http://www.eclipse.org/  Eclipse IDE ] to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36179</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36179"/>
		<updated>2010-09-22T22:18:15Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Example of Scaffolding in CRUD Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the Eclipse IDE to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt; &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36178</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36178"/>
		<updated>2010-09-22T22:17:14Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Example of Scaffolding in CRUD Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the Eclipse IDE to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists app/controllers/&lt;br /&gt;
exists app/helpers/&lt;br /&gt;
create app/views/cars&lt;br /&gt;
exists app/views/layouts/&lt;br /&gt;
exists test/functional/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/unit/helpers/&lt;br /&gt;
exists public/stylesheets/&lt;br /&gt;
create app/views/cars/index.html.erb&lt;br /&gt;
create app/views/cars/show.html.erb&lt;br /&gt;
create app/views/cars/new.html.erb&lt;br /&gt;
create app/views/cars/edit.html.erb&lt;br /&gt;
create app/views/layouts/cars.html.erb&lt;br /&gt;
create public/stylesheets/scaffold.css&lt;br /&gt;
create app/controllers/cars_controller.rb&lt;br /&gt;
create test/functional/cars_controller_test.rb&lt;br /&gt;
create app/helpers/cars_helper.rb&lt;br /&gt;
create test/unit/helpers/cars_helper_test.rb&lt;br /&gt;
route  map.resources :cars&lt;br /&gt;
dependency model&lt;br /&gt;
&lt;br /&gt;
exists app/models/&lt;br /&gt;
exists test/unit/&lt;br /&gt;
exists test/fixtures/&lt;br /&gt;
create app/models/car.rb&lt;br /&gt;
create test/unit/car_test.rb&lt;br /&gt;
create test/fixtures/cars.yml&lt;br /&gt;
create db/migrate&lt;br /&gt;
create db/migrate/20100919144829_create_cars.rb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36177</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36177"/>
		<updated>2010-09-22T22:15:51Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Example of Scaffolding in CRUD Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the Eclipse IDE to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters, specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
                &amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36176</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36176"/>
		<updated>2010-09-22T22:14:25Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Example of Scaffolding in CRUD Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
Follow these steps in the Eclipse IDE to create a scaffolding of a car website.&lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
Generator-&amp;gt;scaffold&lt;br /&gt;
&lt;br /&gt;
Step -5.	In parameters – specify the model, fields and their type&lt;br /&gt;
&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
&lt;br /&gt;
Step -7.	This will run the generate script and create files in View, controllers, model, db etc as shown below: &lt;br /&gt;
&lt;br /&gt;
&amp;gt;script/generate scaffold Car color:string maker:string model:number year:date&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36175</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36175"/>
		<updated>2010-09-22T22:09:25Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Benefits of Scaffolding===&lt;br /&gt;
&lt;br /&gt;
We have noticed, that scaffolding makes the developers job easier, and rather than making a lot of configuration changes at the very first time or may be at the time of updations, he can concentrate on the business logic of the application, which saves his lot of time that he may have spent in creating and maintaining the database code. So you can read out the benefits of Scaffolding below,&lt;br /&gt;
&lt;br /&gt;
*It acts as a tool for the developers to quickly generate running web application environment for the Internet.&lt;br /&gt;
*It provides modular stubs to perform typical CRUD implementations.&lt;br /&gt;
*It improves development productivity for system architects.&lt;br /&gt;
*It improves efficiency by creating reusable components for developers by using frameworks and code generators.&lt;br /&gt;
&lt;br /&gt;
=Example of Scaffolding in CRUD Framework=&lt;br /&gt;
&lt;br /&gt;
Here we will describe how the scaffolding approach works in Rails frameworks. Scaffolding gets its popularity with the rails framework only, and it comes as the inbuilt feature of the rails framework.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Rails Framework==&lt;br /&gt;
&lt;br /&gt;
Now lets see how does scaffolding in the rails framework helps to create the database schema at the start of an application by using very simple commands.&lt;br /&gt;
Rails scaffolding helps to create model, view and controllers for the new resource in a single operation.&lt;br /&gt;
&lt;br /&gt;
Follow these steps in Eclipse IDE to &lt;br /&gt;
&lt;br /&gt;
Step -1.	Create New Rails Project: New-&amp;gt;New Rails Project&lt;br /&gt;
Step -2.	Get the generator view: Window-&amp;gt;Show View-&amp;gt;Generators&lt;br /&gt;
Step -3.	Make sure current project for Generator is the project that you want.&lt;br /&gt;
Step -4.	Select the scaffold generator from drop down box: &lt;br /&gt;
                               Generator-&amp;gt;scaffold&lt;br /&gt;
Step -5.	In parameters – specify the model, fields and their type&lt;br /&gt;
Step -6.	Here we take, Car color:string maker:string year:date&lt;br /&gt;
Step -7.	This will run the generate script and create View files, controllers, db etc as shown below:&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36174</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36174"/>
		<updated>2010-09-22T21:59:37Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==What scaffolding is Today?==&lt;br /&gt;
===Current Scaffolding Scope===&lt;br /&gt;
&lt;br /&gt;
Scaffolding is now a part of many web application frameworks. We can find a number of development software’s that uses web application scaffolding approach. Frameworks	may include,			&lt;br /&gt;
&lt;br /&gt;
*Ruby on Rails, 	&lt;br /&gt;
*CakePHP , &lt;br /&gt;
*ASP.NET&lt;br /&gt;
*CodeIgniter  &lt;br /&gt;
*iPhone Web Scaffolding&lt;br /&gt;
*Grails &lt;br /&gt;
&lt;br /&gt;
These frameworks actually contain some software components that create the skeletal attachments to the application’s database and other external devices.&lt;br /&gt;
We will see how this scaffolding works in some of the frameworks described above in next few paragraphs.&lt;br /&gt;
&lt;br /&gt;
===Where scaffolding lies? ===&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36173</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36173"/>
		<updated>2010-09-22T21:57:05Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Origin in Web Applications===&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36172</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36172"/>
		<updated>2010-09-22T21:56:16Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and evolution==&lt;br /&gt;
==Scaffolding Theory==&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Scaffolding Origin in Web Applications====&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36171</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36171"/>
		<updated>2010-09-22T21:54:25Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Scaffolding Origin in Web Applications====&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36170</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36170"/>
		<updated>2010-09-22T21:51:21Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
====Scaffolding Origin in Web Applications====&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36169</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36169"/>
		<updated>2010-09-22T21:49:34Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and evolution==&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
====Scaffolding Origin in Web Applications====&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36168</id>
		<title>User:ISuite</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:ISuite&amp;diff=36168"/>
		<updated>2010-09-22T21:47:13Z</updated>

		<summary type="html">&lt;p&gt;ISuite: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;b style=&amp;quot;font-size:20pt&amp;quot;&amp;gt;Scaffolding in Web Application Frameworks&amp;lt;/b&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=Overview=&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in General==&lt;br /&gt;
&lt;br /&gt;
Scaffolding in education is basically the support a teacher gives to a new student to get him started on his subject. Scaffolding is also the temporary structure often used by workers in construction. &lt;br /&gt;
&lt;br /&gt;
So what we know of the word scaffolding in real world – a temporary structure to lean on while you build the main structure. The temporary structure can then be discarded.&lt;br /&gt;
&lt;br /&gt;
==Scaffolding in Programming==&lt;br /&gt;
&lt;br /&gt;
It is with the same basic idea that scaffolding in web programming frameworks refer to. It refers to a temporary structure, which is useful as a starting point for the novice.&lt;br /&gt;
&lt;br /&gt;
Scaffolding is nothing but a basic temporary structure that helps a new programmer to get started quickly. It is meta-programming method to quickly generate a functioning web application with the CRUD functionality. Any web application that interacts with database has 4 basic functions generally called CRUD, which it always needs and these are: &lt;br /&gt;
&lt;br /&gt;
*	Create a record, &lt;br /&gt;
*	Read, &lt;br /&gt;
*	Update or &lt;br /&gt;
*	Delete a record. &lt;br /&gt;
&lt;br /&gt;
A scaffold will generate a functioning web application that allows you to carry out these functions. Usually you get a running web application with not more than a few lines of code. &lt;br /&gt;
&lt;br /&gt;
It generates for you what is often termed as boilerplate code. In a MVC framework, scaffolding will usually create basic model, views and controllers and also the database objects needed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Features of Scaffolding==&lt;br /&gt;
&lt;br /&gt;
In software applications, we need to use a number of frameworks to make application run. The frameworks may include:&lt;br /&gt;
&lt;br /&gt;
*	Database access&lt;br /&gt;
*	Screen design, and &lt;br /&gt;
*	Business rules&lt;br /&gt;
&lt;br /&gt;
And scaffolding is the mechanism by which we can create the skeletal of the web application at first go.&lt;br /&gt;
&lt;br /&gt;
So, now after having some basic concept of scaffolding, we can list out the main features of scaffolding below,&lt;br /&gt;
 &lt;br /&gt;
*	It is a framework that provides the minimal setup of the components like database, application servers, and web servers.&lt;br /&gt;
*	When you want to use the structure early on in the development cycle when you are experimenting with the database schema and layout, it helps to quickly generate basic functional application for you directly from the database schema.&lt;br /&gt;
*	Scaffolding helps when the schema undergoes refinement and you don't need to waste your time to change the views and controllers explicitly to align with the change.&lt;br /&gt;
*	It isn't what you would like to use directly in your production systems, you can eventually make changes as you move on with your added and updated project requirements. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=History of Scaffolding=&lt;br /&gt;
==Origin and evolution==&lt;br /&gt;
&lt;br /&gt;
===Scaffolding Theory===&lt;br /&gt;
Scaffolding theory in education came into being in 1950, by, Jerome Bruner, where he described the various scaffolding techniques for oral language and written vocabulary. &lt;br /&gt;
In Oral scaffolding, parents and adults help the children to make them know how to speak and communicate, how they should use the words and develop the base or a temporary framework for their children to walk in the new world. And once the child secures the control over the things, base can be taken away. Similarly, in written scaffolding, typical supporting instructions were given by the instructor to the students to learn vocabulary, to calibrate the task, to identify the task and work independently on the task, in this way they built the scaffold for them on which they can lean on while learning. &lt;br /&gt;
So children use oral scaffolding as a vehicle to communicate and written scaffolding as tool for new thinking. And the teacher’s instructions also get changed from time to time, starting from the directions, to suggestions, to encouragement, and then observation.&lt;br /&gt;
&lt;br /&gt;
====Scaffolding Origin in Web Applications====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Scaffolding has been around in various forms for some time. Earlier, separate code generators were written, which would generate CRUD functionality for certain frameworks. They were often the third party generators who offered varying capabilities and mainly acted as database code generators. &lt;br /&gt;
&lt;br /&gt;
You could also have custom scripts, which could generate the CRUD screens from some database specifications. Often each new project involved writing up some templates to get the basic functionality or write a template generator script, which created these templates for your project. But these generators and scripts were non-standardized and often viewed as taking away time from the core development of an application.&lt;/div&gt;</summary>
		<author><name>ISuite</name></author>
	</entry>
</feed>