Reasons to use Ruby on Rails - People

attackkaboomInternet και Εφαρμογές Web

2 Φεβ 2013 (πριν από 5 χρόνια και 3 μήνες)

154 εμφανίσεις

Reasons for Using Ruby on Rails as a Software Development Framework for
Web Applications

By Carlos Kirkconnell

Fall 2008 CIS764

Ruby is a dynamic programming language that lately has gained a lot of popularity.
Rails is

a web development framework written in Ruby. Rails is currently the 4

most popular development platform used by web developers. Every year it’s
winning popularity. This paper will discuss some of the reasons why many
developers are embracing
Ruby on Rai
ls as their web development platform.

Ruby is de
signed for Programmer Happiness.

Yukihiro Matsumoto, the creator of
Ruby, has stated many times that one of his design objectives was “programmers
happiness”. Psychological studies have shown that the mood
of people during their
actual work time is a factor that affects their productivity. Especially on creative
type of jobs (architects, designers, musicians, etc…), when workers are happier, they
tend to produce better quality work. Many software development

companies have
found that value of “happiness”, and have decided to invest thousands of dollars on
making their workers happy. Ruby attempts to give programmers “happiness” by
having a very clean and concise syntax. The dynamic nature of Ruby allows
work designers to create behavior that is really convenient for programmers.

Rails is designed with simplicity in mind. Two

that rails always keeps in
mind are:


Convention over Configuration: This means that if a developer follows the

lineups, he should be able to work with it writing the least
amount of code poss


Don’t Repeat Yourself: This principle is also known as “keep DRY”. Rails
highly encourages develop
ers to remove repetitive code.

established design patterns are p
ut into practice. A Ruby on Rails application is
based on the MVC pattern. The three major components of the Ruby on Rails
framework are:


: ActiveRecord is the library that rails uses to model data
classes. A class models each table on the dat
abase. Since Ruby is a dynamic
programming language, rails can read the schema of a table and create on the
fly methods and properties for a class enforcing the principle of convention
over configuration.
Tables built and named using the Rails conventions
translate into elegant classes with practically no effort from the developer.
The developer only needs to derive a class named as a table on the database
from the base ActiveRecord class. The ActiveRecord library has many means
of performing validation
s at the model level. The validations are written in a
human readable way that is easier to make then the validations mechanisms
provided by the majority of development frameworks that currently exist.


: ActionController is the library that

rails uses to provide
the controlling component of the framework. ActionController provides
mechanisms for managing HTTP requests from users, and calling the correct
business logic for each request. Usually related web pages are managed by
the same contr
oller, thus avoiding the repetition of logic that happens on
other web development frameworks that require one controller class per
web page.


ActionView is the component of the Rails framework that deals
with presenting the information to users

via web pages. ActionView also
allows users to submit information to controllers using either HTML forms or
well formed URL’s.

ActionView uses ERB as a templating tool for embedding
ruby code on both HTML and XML files. ERB can also be used to serve many
other file types. ActionView differs from many of the “advanced” templating
tools in that it has no “Components”. A component is a class that is in charge
of a modeling a user interface element as a class. Components may seem to
improve the reutilization o
f user interface parts, but unfortunately they also
tie the controller logic to the view logic. Rails made the decision of not
including components as part of ActionView because components violate the
MVC pattern.

Great interest has

in us
ing rails, b
ecause of its use of REST as an application
communication mechanism. REST is similar to SOAP or XML
RPC in that it’s used to
communicate one application with another. REST is a lightweight communication
protocol that relies on HTTP verbs to call for action
s. Other communication
technologies rely on complex discovery protocols that consume higher bandwidth
and make dynamic discovery and use of services a hard task.

REST consists of publishing resources. Resources are the basic data models that the
n business model is built from. Each REST resource can only have 4
operations performed on it: create, read, update and delete. These 4 operations are
usually referred as CRUD.
Each operation has an HTTP verb assigned to it. Create
has POST, Read has GET,
Update has PUT and Delete has DELETE.

Restricting the operations on the business model as only 4 possible ones appears to
be a detriment on the flexibility of the model. Lately it has been shown that all
complex operations on business objects can be modele
d used the 4 basic CRUD
operations. To do that special care must be placed on linking relationships between
models, and in some cases identifying them as a separate object. For example, if a
developer is working on an authentication system, it woul
d appear

that the “login”
method would be highly required in this model. It could initially be thought that
using the GET verb as a way of dealing with the login method is a good idea. The side
effect of that is that the authentication information would be sent to

the server by
using an open query string, this won’t seem like a very secure way of doing that. The
other option is to make some modifications to the model. By introducing a “Session”
model, developers can now use POST to login. Every time a user logs to
the system, a
session object is created. The information for creating that thus won’t be sent
through the query string, but as a POST variable, which can be encrypted by HTTPS.
A nice side effect happens after the addition of the session class. Now the sys
tem has
the functionality of creating a log of users that log in to the system. A timestamp can
be used to keep track on the times at which users use the system.

Although Ruby on Rails provides many advantages to advanced web developers, it
can be quite ha
rd to learn; specially to people that has worked platforms like J2EE
or .NET. These platforms highly rely on the use of advanced IDE’s, which provide a
lot of functionality via wizards. Ruby on Rails has no official IDE. Most of the work is
done on simple
text editors and console commands are used to create files and make
updates to the database. No intellisense (or very little) is available for Ruby on Rails
because of the dynamic nature of the language. Once the initial learning curve is
passed, usually d
evelopers gain higher productivity because of the characteristics of
the framework.


Dave Thomas, David H. Hansson.
Agile Web Development with Rails
, Pragmatic
Bookshelf, Second Edition

DePaul University Chicago,
Snakes and Rubies Conference

December 2005