CSC/ECE 517 Fall 2009/wiki1b 9 ss
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 web frameworks allow 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 that 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 working database driven application. It also shows the developer what kinds of methods and logic must be present within the applications 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 then 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 from which they will write their own structure.
Scaffolding has become very popular within in the web development community and therefore is showing up in several web frameworks. This is mostly because it increases work flow and it 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, and .NET.
Dynamic Scaffolding
Dynamic Scaffolding generates the data interfaces at run time. With very little code written 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 with Dynamic Scaffolding. Young developers loved it because they could get a web application up and running without having to know the gory details, or even much about the framework they were working with. Many experienced developers also like it because it allowed them to quickly prototype an application and wow clients as they see their product come to life in a matter of minutes. There were problems with Dynamic Scaffolding however. Because Dynamic Scaffolding creates the data interfaces at run time, these interfaces are hidden from the developer and to them, it's rather magical in its implementation. This creates some problems. One problem is the developer does not actually 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 that is created is hidden which makes it very difficult to access and work with. Because of these problems, many application development purists see Dynamic Scaffolding as doing more harm than good.
Scaffold Generation
Scaffold Generation is another approach to scaffolding that generates the data interfaces for a developer, but 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 the developer loses in automation, they gain in having a working site filled with examples from which to learn from. They also have immediate access to the data interfaces so they can make modifications quickly and efficiently. Scaffold Generation also has the advantage of reducing the learning curve from a scaffold created controller to a custom one. With Dynamic Scaffolding is was easy for a developer to create a simple CRUD interface, but there was a big gap between that step and a custom interface that handles a specific job with specific needs. This gap is not nearly as wide now that 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.
Scaffolding in Ruby on Rails
Ruby on Rails 1.x
scaffold :modelname
Ruby on Rails 2.x
./script/generate scaffold ModelName field1:type field2:type field3:type