CSC/ECE 517 Fall 2007/wiki2 1 p23: Difference between revisions
m (→Architecture) |
m (→Apache Struts) |
||
Line 47: | Line 47: | ||
Struts achieves separation between data, views and the underlying logic, according to the MVC architecture. It provides the controller (ActionServlet) and views can be generated for the user interface, usually with JSP. The developer must link the model, view and the controller together with a configuration file struts-config.xml. Messaging between components is achieved through JavaBeans. | Struts achieves separation between data, views and the underlying logic, according to the MVC architecture. It provides the controller (ActionServlet) and views can be generated for the user interface, usually with JSP. The developer must link the model, view and the controller together with a configuration file struts-config.xml. Messaging between components is achieved through JavaBeans. | ||
Like Ruby on Rails, the 'router' receives requests and actions defined in the configuration file determine the processing of the request. The Action class corresponding to this action is called, and it interacts with the model | Like Ruby on Rails, the 'router' receives requests and actions defined in the configuration file determine the processing of the request. The Action class corresponding to this action is called, and it interacts with the model to receive a string (ActionForward) indicating where the results must be directed. | ||
== JavaBeans == | == JavaBeans == | ||
Line 55: | Line 55: | ||
== Other Features == | == Other Features == | ||
Struts supports internationalization, and also includes a template mechanism (Tiles) | Struts supports internationalization, and also includes a template mechanism (Tiles). | ||
= Comparison and Evaluation = | = Comparison and Evaluation = |
Revision as of 01:50, 25 October 2007
Ruby on Rails and Apache Struts: A comparison based study
There exist several web application development frameworks in the market. A software developer faces a dilemma regarding which of these to employ to implement his application, based on criteria such as enhanced productivity, complexity, scalability, requirement satisfaction, maintenance, etc. This article aims to compare two such frameworks, Ruby on Rails and Apache Struts, from the perspective of the developer and that of the finished application.
Introduction
Web application frameworks are employed to develop dynamic web pages as well as web applications and services. Generally, web application frameworks comprise libraries compiled into a cohesive software stack. Web applications differ from static web pages in that they allow the generation of dynamic responses through database interaction.
Ruby on Rails as well as Apache Struts are based on what is known as the Model-View-Controller (MVC) architectural pattern. The concept underlying MVC is to separate the presentation layer (view) from the logic and the data model. This ensures that any changes to the user interface will not affect the business logic, and reorganization of the data model will not affect the user's view. Ruby on Rails and the Apache Struts framework are both based on the MVC Architecture.
Problem Statement
"Compare Ruby on Rails with Apache Struts. The Apache Struts framework in the Java world occupies a position similar to Ruby on Rails, except that it is not as universally used. Compare the two. Which are the advantages of each for the developer? For the finished application?"
Ruby on Rails
Ruby on Rails is a framework that facilitates the development, deployment and maintenance of web applications, written in the Ruby programming language.
Design Paradigms
Rails was designed with the underlying concept of Don't Repeat Yourself (DRY), which emphasizes that every piece of information in the system should be expressed only once. As a result, changes to applications designed with Rails will impact a lot less code than they would in other frameworks.
Another paradigm that Rails is based on is Convention over Configuration (CoC), which means that Rails has defaults for every aspect of the application being developed. Hence, following conventions can lead to application deployment with much less code than would have been written in another programming language. Rails is the first framework to have adopted this paradigm. Ruby also provides scaffolding, an "autogenerated framework for manipulating a model".
Architecture
Rails is designed based on the MVC Architecture. It enforces a structure for the application where models, views and controllers are developed functionally separately, and then knit together during the execution of the application. Incoming requests are sent to a 'router', which computes where the request must be directed to, and how it must be interpreted. This directs the request to a method in the controller (an action), which performs some data manipulation or computation. The data is then rendered as a view to the user.
Structure
Rails' framework consists of the following packages: Active Record, Action Pack, Active Support, Action Mailer and Action Web Service.
Active Record
Rails maps relational database tuples to objects using Active Record: tables map to classes, rows to objects, and columns to object attributes. Active Record facilitates the implementation of the primitive database operations: Create, Read, Update and Delete. It is also the model part that allows the user to define relationships such as belongs_to and has_many.
Apache Struts
Apache Struts is a web application framework for developing web applications in Java.
Architecture
Struts achieves separation between data, views and the underlying logic, according to the MVC architecture. It provides the controller (ActionServlet) and views can be generated for the user interface, usually with JSP. The developer must link the model, view and the controller together with a configuration file struts-config.xml. Messaging between components is achieved through JavaBeans.
Like Ruby on Rails, the 'router' receives requests and actions defined in the configuration file determine the processing of the request. The Action class corresponding to this action is called, and it interacts with the model to receive a string (ActionForward) indicating where the results must be directed.
JavaBeans
Other Features
Struts supports internationalization, and also includes a template mechanism (Tiles).
Comparison and Evaluation
These web application frameworks can be compared against each other based on several criteria.
Comparison criteria
- Complexity
- Speed
- Hmm?
Conclusion and scope for future work
The Ruby developer is more productive by spending less time writing code. The database migrations enhance productivity by reducing effort spent in switching between schema versions. In the traditional J2EE environment, version control would be required for the developer to achieve the same.
With Rails, one line of code, namely, scaffold :table_name can generate all the CRUD methods required for the application. Achieving the same in the traditional J2EE environment translates roughly to a hundred lines of code.
Apache Struts contains a predefined tag library, to process the content of JavaBeans from the views without the need for any embedded Java code.
See Also
Agile Web Development with Rails by Dave Thomas and David Heinemeier Hansson, with Leon Breedt, Mike Clark, James Duncan Davidson, Justin Gehtland, and Andreas Schwarz
Model Driven Development with Rails by Antonios Protopsaltou
Starting with Struts2 by Ian Roughley
References
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]
[ ]