CSC/ECE 517 Fall 2007/wiki2 1 pp: Difference between revisions
No edit summary |
No edit summary |
||
Line 58: | Line 58: | ||
==== Differences ==== | ==== Differences ==== | ||
{| border="1" cellspacing="0" | |||
cellpadding="5" align="center" | |||
! Feature | |||
! Ruby On Rails | |||
! Apache Struts | |||
|- | |||
| '''Base Controller''' | |||
| DispatchServlet | |||
| ActionServlet | |||
|- | |||
|} | |||
=== The Model === | === The Model === |
Revision as of 20:07, 24 October 2007
Ruby on Rails vs Apache Struts
Introduction
Apache Struts is an open source web based application framework for developing Java EE web applications. It uses Java Servlet API to extend and develop the Model view controller architecture. The goal of Struts is to separate the database logic from the presentation logic as well as business logic.
Rails is an open source framework for developing database backed web applications in Ruby . The biggest advantage of Ruby is simplicity. Rails takes full benefit of this. While developing an application with Ruby on Rails the programmer is saved from the hassles of writing too many lines of code. Keeping the code small makes it easier to debug and it also increases the readability and maintainability of the code . Ruby on Rails also uses the MVC architecture.
What is MVC?
In complex applications that involve a large amount of data , the programmer might wish to separate the data logic from the user interface logic.
This is where MVC comes in.
Model
It is used to represent business logic of the application. It indicates the application state and the actions to be performed on that state.
View
It is used to show the model to the user. It is usually HTML file that provides an interface for the model.
Controller
Responds to events.It may cause changes to the model.
Flow Of Control
- The user interacts with the user interface.
- A controller handles the data generated from user interactions and updates the model with the data from the user interface.
- View generates user interface using the model. For eg the in a flight reservation system the view may present the customer with the list of available seats in the flight.
Apache Struts is a framework that is used to implement model view architecture in Java whereas Ruby on rails implements model view architecture in Ruby.
Advantages Of Struts/Rails to the Application
As both struts and rails are MVC frameworks for developing database backed web applications they have the same advantage from the application point of view.
- Less Coupling-Often one class depends on some other classes for its functionality .This is not good design. Each class should have a specific focus. MVC architecture achieves this by providing separate classes for models,views and controllers.
- Ease Of Change -Business logic resides in both presentation and data access layer. So if there is any change in the business logic one needs to change the code at different layers (presentation database and business layers). This can lead to inconsistent code. Moreover there are chances that the code might be duplicated across multiple places.MVC helps prevent update problems by decoupling logic of all 3 layers.
- Flexibility Of Views – For the same function different views can be generated . For eg the same data can be implemented as applet ,HTML page or a spreadsheet in different applications.
- Modularity increases -In the absence of MVC it would be very cumbersome to remove components from the application or add new components to the application. With MVC modularity increases. So it becomes handy to incorporate new modules into the application.
Comparison
Front Controller
Similarities
The controller serves to provide the same core functionality in Ruby On Rails as well as Apache Struts . The controller accepts the incoming Http request , parses the URL of the request ,gets the values of the parameters from the query string and forwards the processing of the request to the appropriate action . The difference in the working lies in the processing of the HTTP request.
Differences
cellpadding="5" align="center"Feature | Ruby On Rails | Apache Struts |
---|---|---|
Base Controller | DispatchServlet | ActionServlet |
The Model
Similarities
In rails as well as struts model is used to interact with the database. It uses the data that the controller gathers to make corresponding changes to the database in a manner that is transparent to the user of the application.
Differences
Persistence Frameworks
Similarities
Persistence frameworks allow developers to map normal objects to relational tables using the least effort. In both ruby as well as java the aim of persistence frameworks is to make interactions with the database as simple as possible.