CSC/ECE 517 Fall 2009/wiki1b 9 ss: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
 
Line 118: Line 118:
=Scaffolding in Flash=
=Scaffolding in Flash=
==[http://www.gaiaflashframework.com/ Gaia]==
==[http://www.gaiaflashframework.com/ Gaia]==
Gaia is an open source front-end framework for the [http://www.adobe.com/products/flash/ Flash] programming environment. The term front-end framework is meant to mean that no advanced knowledge of the Flash coding convention is required in order to get up and running and can be used by novice developers. The fact that Gaia prides itself on requiring little to no code to get going is nothing new compared to other frameworks, however, what makes Gaia interesting is its support for [http://en.wikipedia.org/wiki/Search_engine_optimization SEO] (Search Engine Optimization) scaffolding. The way that SEO scaffolding works is it generates the XHTML pages for every SEO enabled page on the site. For each one of these XHTML pages the copy for the developer's flash is included. This one file per page relationship makes it much easier for the developer to optimize his/her site for search engines. The scaffolding information is stored in a file called Scaffold.as. An example of accessing the scaffolding from a page would look like the example below.[[http://www.stevensacks.net/2008/04/16/gaia-flash-framework-21-seo-scaffolding/ 12]]
Gaia is an open source front-end framework for the [http://www.adobe.com/products/flash/ Flash] programming environment. The term "front-end framework" means that no advanced knowledge of the Flash coding convention is required to use it allowing novice developers to use it. The fact that Gaia prides itself on requiring little to no code to get going is nothing new compared to other frameworks, however, what makes Gaia interesting is its support for [http://en.wikipedia.org/wiki/Search_engine_optimization SEO] (Search Engine Optimization) scaffolding. The way that SEO scaffolding works is it generates the XHTML pages for every SEO enabled page on the site. For each one of these XHTML pages, the copy for the developer's flash is included. This one file per page relationship makes it much easier for the developer to optimize his/her site for search engines. The scaffolding information is stored in a file called Scaffold.as. An example of accessing the scaffolding from a page would look like the example below:[[http://www.stevensacks.net/2008/04/16/gaia-flash-framework-21-seo-scaffolding/ 12]]
<pre>
<pre>
new Scaffold(this);
new Scaffold(this);

Latest revision as of 19:41, 25 September 2009

Scaffolding in Web application frameworks

Topic :We have discussed scaffolds for Ruby on Rails. The dynamic scaffold of Rails 1.x was replaced in Rails 2 by a generator of scaffolds for specific tables. Why did this change take place? What are the pros and cons of dynamic scaffolds? Many languages other than Ruby (Java, Python, and PHP, for example) provide Web application frameworks. Do any of these languages have the equivalent of scaffolding? If so, how does it compare to Rails?

The concept of Scaffolding

Scaffolding in a web application framework allows a software developer to create data-driven web applications quickly by automating CRUD (Create, Read, Update, Delete) data operations. It achieves this by generating pages for the models within the MVC architecture of the application. The pages have a working data form that can communicate with the database. This allows the developer to get an early look at the data presented in the application as a raw design from which they can build, modify, or rework the application in order to achieve a final product.

For the young developer, scaffolding has the advantage of quickly and easily building a functioning database-driven application. It also shows the developer what kind of methods and logic must be present within the application's controllers in order to produce a successful product. Scaffolding is a pragmatic tool to help young developers learn about creating web applications.

For the experienced developer, scaffolding gives them fast access to viewing and editing pages. With this, the experienced developer can customize the application through the use of metadata, templates, overriding the scaffold actions with custom ones, or they may use the quickly generated "build as a rough draft" option from which they will write their own structure.

Scaffolding has become very popular within the web development community and is showing up in several web frameworks. This is mostly because it increases work flow and allows web designers to spend more time designing instead of building interfaces to data. Scaffolding has become so wide spread that it can be found in such frameworks as Ruby on Rails, Python, PHP, Java, .NET, and Flash. [1, 2, 3, 15, 18]

Dynamic Scaffolding

Dynamic Scaffolding generates the data interfaces at run time. With very little written code and no necessary knowledge of the underpinning data interfaces, a developer could get a web application up and running in very little time and with little effort by using Dynamic Scaffolding.

Young developers loved it because they could get a web application up and running without having to know the gory details, or having to know much about the framework they were working with. Many experienced developers also liked it because it allowed them to quickly prototype an application and wow clients as they saw the product come to life in a matter of minutes.

However, there were issues with Dynamic Scaffolding. Dynamic Scaffolding creates the data interfaces at run time causing the interfaces to be hidden from the developer. This left the developer clueless regarding the implementation. This lack of knowledge created problems. One problem was that the developer did not learn how to handle a typical CRUD scenario. Even if the developer did know how to build and customize their own CRUD scenario, the code created was hidden which maked it very difficult to access and work with. Because of these issues, many application development purists see Dynamic Scaffolding as doing more harm than good. [1, 2, 3, 10, 14, 15]

Scaffold Generation

Scaffold Generation is another approach to scaffolding that generates the data interfaces for a developer, but it also gives them access to the generated code. This process is a bit less automated than Dynamic Scaffolding because changes to the model will not be automatically updated elsewhere in the application. What developers lose in automation, they gain in having a working site filled with examples from which to learn from. Developers also have immediate access to the data interfaces so they can make modifications quickly and efficiently. Furthermore, Scaffold Generation has the advantage of reducing the learning curve from a scaffold created controller to a custom one. Dynamic Scaffolding was easy for a developer to create a simple CRUD interface, but there was a large gap between that step and a custom interface to handle a specific job with specific needs. This gap is not nearly as wide now since the developer has access to the code created through Scaffold Generation and can use it as a foundation to branch out into custom interpretations of the simple CRUD scenario. [1, 2, 3, 10, 14, 15]

Scaffolding in Ruby on Rails

Scaffolding became popular in Ruby on Rails and has since moved on to several other frameworks. The first generation of Ruby on Rails supported Dynamic Scaffolding. Scaffold Generation was also supported, however books, demos, and tutorials based on the first generation of Ruby on Rails largely omitted this fact. Beginning with the second generation of Ruby on Rails, Dynamic Scaffolding was no longer supported and Scaffolding Generation took center stage.

Ruby on Rails 1.x

In the first generation of Ruby on Rails a developer would generate a modal, then use a migrate file to create layout columns in the model's database table. After that they would generate a controller and add scaffolding. A scaffolding example in Ruby on Rails 1.x would look like the example below.[2, 3, 15]

scaffold :modelname

Ruby on Rails 2.x

Ruby on Rails 2.x may have taken away Dynamic Scaffolding but it made Scaffold Generation simpler and involving less steps. This is due to being able to create your model, migrate file, and column layout all in one step. A scaffolding example in Ruby on Rails 2.x would look like the example below. [2, 3, 15]

 ./script/generate scaffold ModelName field1:type field2:type field3:type

Once this script is executed the generator will build 14 files in your application, along with some folders, and edit one more. Here’s a quick overview of what it creates:

  • The model with the name you specified as ModelName
  • Migration script to create the ModelNames table in your database
  • A set of views for add, edit, display, and delete
  • A view to control the overall look and feel of the views
  • A cascading style sheet to make the scaffold views look better
  • the ModalName controller
  • Testing harness for the ModalName controller
  • Helper functions
  • Routing information
  • Unit testing harness for ModalName
  • Unit testing harness for ModalName helper

Scaffolding in Python

Django

Django is a high-level python web framework that was written in a newsroom to provide as much automation as possible for web developers under heavy deadlines. In Django you find scaffolding in what it calls the admin interface. The idea behind the admin interface is that user pages differ greatly from client to client, but administrative tools largely remain the same and can be very repetitive to develop over and over; therefore it makes since to create a tool that will create these types of applications for us. By hooking to the metadata in your model, a fully functional web application can immediately be used as an administration tool to help manage your site. The way the admin interface is implemented is: for each model you want to associate with the admin interface, you mark that model. Then in your url.py file you add the url for the admin interface. This would look like the example below:[14]

 urlpatterns = patterns('',
    (r'^admin/', include('django.contrib.admin.urls')),
 )

This use of scaffolding in Django quickly and easily created an entire administration application.

This is accomplished mainly in two files. They are called scaffold.py and meta_scaffold.py. The scaffold.py file is used to generate a particular model. The meta_scaffold.py file is used to generate a template for all of the models.[17]

Scaffolding in PHP

CakePHP

When Ruby on Rails began to take off, many frameworks decided to model themselves after what Ruby on Rails was doing. CakePHP is a web development framework written in PHP that has incorporated many of the same concepts and design principles as Ruby on Rails. Because of this CakePHP prides itself on supporting scaffolding.[7]

CakePHP really has two types of scaffolding, one that it is actually called Scaffolding and another that is called Bake. What CakePHP calls Scaffolding is really like Dynamic Scaffolding. Here you have a model and then in your controller you declare a scaffold variable. CakePHP handles the rest behind the scenes. An example would look like the code below: [4, 5]

<?php

class MyController extends AppController {
    var $scaffold;
}

?>

The Bake console with CakePHP generates code for the models, views, and controllers. Bake works like Scaffold Generation and creates a fully functional structure a developer can learn from or build upon. An example would look like the code below:[6]

cake bake model [model name]
cake bake controller [controller name]
cake bake view [view name]

Scaffolding in Java

GRails

GRails is an open source framework that integrates with a programming environment called Groovy. Groovy is based on the Java platform. GRails supports Dynamic Scaffolding, however, it does allow a developer to access the generated code if they want. If a developer tells GRails to install templates, the current scaffold code will be created in a template file that can be modified to fit specific needs. GRails supports other Java technologies such as Spring and Hibernate. An example snippet of scaffoldng in GRails would look like the example below:[9, 10]

class myController{
 def scaffold=true
}

In order to edit the templates generated by the Dynamic Scaffolding, you must install them. The installed templates would be stored in a new folder called 'templates' in the '/src' directory. An example would look like the code below:

grails install-templates

A popular tactic is to generate the templates of the scaffolding before letting the scaffold create the views. This will allow the developer to edit the templates to meet the layout requirements of the project. That way, when the scaffold generates the views, all the views will adhere to those layout requirements without having to modify each one. [16]

For a short video tutorial on scaffolding in GRails please visit the following link: [19]

Appfuse

Appfuse is an open source project and application. It uses open source tools built on the java platform to help a developer build web applications quickly. Appfuse is not actually a framework. Appfuse is more of a tool for code generation that can be used with other Java web frameworks. It can be integrated into other open source technolgies such as Spring, Hibernate, and Struts.[8]

Scaffolding in .NET

.NET is a Microsoft framework that can be used to develop applications on machines running Microsoft software. In .NET Microsoft includes scaffolding as part of a broader structure it calls Dynamic Data. Dynamic Data uses LINQ to SQL for it's data access from which it builds corresponding controllers and views. Dynamic Data was originally part of a project called Blinq but that project was terminated and Dynamic Data became a part of .NET in its 3.5 extensions package. An example of setting up a scaffold in .NET would look like the example below.[11]

ScaffoldTable(true)
public partial class myClass{
}

Scaffolding in Flash

Gaia

Gaia is an open source front-end framework for the Flash programming environment. The term "front-end framework" means that no advanced knowledge of the Flash coding convention is required to use it allowing novice developers to use it. The fact that Gaia prides itself on requiring little to no code to get going is nothing new compared to other frameworks, however, what makes Gaia interesting is its support for SEO (Search Engine Optimization) scaffolding. The way that SEO scaffolding works is it generates the XHTML pages for every SEO enabled page on the site. For each one of these XHTML pages, the copy for the developer's flash is included. This one file per page relationship makes it much easier for the developer to optimize his/her site for search engines. The scaffolding information is stored in a file called Scaffold.as. An example of accessing the scaffolding from a page would look like the example below:[12]

new Scaffold(this);

Resources

1.http://en.wikipedia.org/wiki/Scaffold_(programming)
2.http://fairleads.blogspot.com/2007/12/rails-20-and-scaffolding-step-by-step.html
3.http://www.packtpub.com/article/Working-with-Rails-ActiveRecord-Migrations-Models-Scaffolding-and-Database-Completion
4.http://www.developer.com/lang/php/article.php/3636686/Scaffolding-with-CakePHP---Managing-Your-Fantasy-Football-Team.htm
5.http://book.cakephp.org/view/105/Scaffolding
6.http://www.webdevelopment2.com/cakephp-bake-baking-models-controllers-views-cakephp-12/
7.http://en.wikipedia.org/wiki/CakePHP
8.http://en.wikipedia.org/wiki/AppFuse
9.http://en.wikipedia.org/wiki/Grails_(framework)
10.http://grails.org/Scaffolding
11.http://www.infoq.com/news/2007/12/aspnet-dynamic-data
12.http://www.stevensacks.net/2008/04/16/gaia-flash-framework-21-seo-scaffolding/
13.http://en.wikipedia.org/wiki/Search_engine_optimization
14.http://www.djangobook.com/
15.http://guides.rubyonrails.org/
16.http://docs.codehaus.org/display/GRAILS/Artifact+and+Scaffolding+Templates
17.http://code.djangoproject.com/wiki/Scaffolding

Literature

18.Agile Web Development with Rails

Media

19.http://www.youtube.com/watch?v=LWoCfTyWG_E

Official Sites

http://rubyonrails.org/
http://www.djangoproject.com/
http://cakephp.org/
http://appfuse.org/display/APF/Home
http://grails.org/
http://www.microsoft.com/NET/
http://www.gaiaflashframework.com/
http://groovy.codehaus.org/