CSC/ECE 517 Fall 2009/wiki1b 9 ad

From Expertiza_Wiki
Revision as of 13:43, 20 September 2009 by Artonoops (talk | contribs)
Jump to navigation Jump to search

Scaffold

Scaffolding is a meta-programming method of building database-backed software applications. It is a technique that allows a programmer to quickly generate a skeleton interface that allows the user to perform basic CRUD ( Create Read Update Delete) operations on the application's database. The auto-generated interface can then be modified to perform more powerful tasks.


Why was dynamic scaffolding removed in Rails 2?

Dynamic Scaffolding of Rails 1.x was replaced by a generator of scaffolds in Rails 2.

David Heinemeier Hansson responding to a new rails developer on a Ruby forum said "Dynamic Scaffolding didn't really help people learn about Rails or give them a way to modify the generated interface, so we killed it.".

In dynamic scaffolding when the line scaffold :model_name is added to the controller ruby automatically generates the appropriate interfaces at run time. Since, scaffolding is implemented on the fly the programmer cannot easily modify and customize the interfaces.Therefore, dynamic scaffolding was removed in Rails 2 though it is still available as a plugin.

Pros and cons of Dynamic Scaffolding

Pros

  1. The biggest advantage of Dynamic scaffolding is that it allows the programmer to extend and modify the database schema without worrying about reflecting those changes in the interface. The user interface automatically updates to keep up with the changes.
  2. The code to generate scaffolds dynamically is simple in most frameworks and a lot is accomplished in a single line of code.

Cons

  1. The biggest disadvantage of Dynamic scaffolding is that the programmer cannot see whats going on. Since all the interfaces are generated on the fly, the code is hidden; this could be especially disadvantageous to someone who is trying to learn Rails.
  2. The dynamic nature of generating scaffolds makes the behaviour of the application a little unpredictable.
  3. It is difficult to modify or customize the scaffold code since it is generated at run time.


Scaffolding in frameworks for other languages

Many other languages such as Java, .NET, PHP, Python have frameworks that have adapted scaffolding. Let us walk through some of the frameworks that provide the scaffolding feature such as CakePHP, Codelgniter, Symphony and Yii for PHP, Django for Python, MonoRail and for .Net and Seam for Java.

CakePHP for PHP

Scaffolding in CakePHP is

Django for Python

Django is an open source web application framework, written in Python, which follows the model-view-controller architectural pattern. Just like Rails, Django aims at providing the concept of 'DRY' and extensive reusability. With regard to scaffolding, once the models are defined, Django can automatically create a professional and production ready administrative interface -- a Web site that lets authenticated users add, change and delete objects. The framework offers role-based authentication and also one does not have to deal with creating backend interfaces just to manage content. It uses generic views to help automate CRUD operations that rails scaffold provides, minus the html generation.

When compared with Rails, Rails is slightly faster because of its scaffolding feature which generates some html as well as the model-interaction code, which you can then tweak to your own liking. The one downside is Rails doesn't provide its own user auth system, but there are plenty of plugins that implement that. Customization of the generic views in Django is possible but you kind of have to hack around the blackbox or implement it yourself.

MonoRail for .net

MonoRail, a component of the Castle Project, is an open source web application framework built on top of the ASP.NET platform. Scaffolding like RoR, controllers adorned with the necessary scaffolding attributes can automatically produce the basic markup and logic for CRUD operations on the domain model. It proves handy for prototyping or creating rough-and-ready data entry capabilities in your applications. Its quite good to create prototype applications in no time. It is flexible upto an extent that its implementation allows you to override the views if you want, so the scaffolding will handle only the CRUD. MonoRail, just like Rails, maintains a standard for data access throughout its applications.

ASP.net Dynamic Data

ASP.NET Dynamic Data Support, a part of the ASP.NET 3.5 ExtensionsASP.NET 3.5 Extensions provides a scaffolding framework that allows rapid application development based on ASP.NET.

Resources