CSC/ECE 517 Spring 2014/ch1a 1c yj: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
= Object Oriented Frameworks Evaluation =
= Object Oriented Frameworks Review =


= Background =
= Background =

Revision as of 04:48, 16 February 2014

Object Oriented Frameworks Review

Background

In such internet age, web applications had been highly valued by programmers on the Web. To help those who aimed to utilize the design patterns to produce a maintainable, readable, and high quality code, many object-oriented web frameworks have been released to the public allowing enthusiastic programmers to take advantage of the well-built developing environment.

You may already see several examples from other chapters(here, here, and here), but today, we are going to deliver several further details on each, based on their strength and weaknesses, and make a comparison to make the decision on choosing the best object-oriented web frameworks easier. At the end of the page, a table of #Feature-based Comparison on Web Frameworks is also provided.

Frameworks

As there are tons of object-oriented web frameworks that can be found online, we will limit to only four of the most famous web frameworks we consider are the most popular today.

Ruby on Rails

  • First created: 2003 by David Heinemeier Hansson <ref>http://rubyonrails.org/</ref>
  • Current Developer: Rails Core Team
  • Current version: 4.0.2 and 3.2.16
  • Licence: Rails under the MIT license. Ruby under the Ruby License.

Ruby on Rails has been one of the most popular web app frameworks on Ruby <ref>https://www.ruby-toolbox.com/categories/web_app_frameworks</ref>, Some of the famous applications built with Rails can be Twitter and Github.

Strength

Faster development
Many people say Ruby on Rails helps developers being productive. People even developed a survey to proof such claim is true. <ref>http://martinfowler.com/articles/rubyAtThoughtWorks.html#IsRubyMoreProductive</ref> Forgoing the runtime performance, ruby comes with the interpreter and support of MVC design, that helps the developer minimize any repeating code, and maximize the scalability of web application.
More readable code thanks to Ruby
It may be hard to say if this is one of the strengths of rails, because readability is the advantage for every framework developed on Ruby. It is still worth to compare with the frameworks which are developed on languages other than Ruby.
A code in Ruby <ref>http://www.slideshare.net/dosire/when-to-use-ruby-on-rails-1308900#</ref>

 describe Bowling do
   before(:each) do
       @bowling = Bowling.new
   end
   it "should score 0 for gutter game" do
       20.times { @bowling.hit(0) }
       @bowling.score.should = 0
   end
 end

Will look like this in PHP

Class NewBowlingGame extends PHPSpec_Context
 {
  private $_bowling = null;
  public function before()
  {
       $this->_bowling = new Bowling;
  }
  public function itShouldScore0ForGutterGame()
  {
       for ($i=1; $i<=20; $i++) {
       $this->_bowling->hit(0);
       $this->spec($this->_bowling->score)->should->equal(0);
       }
  }
}

Weakness

Run relatively slow
Since Ruby on Rails was designed to optimize the development speed and readability, such optimization sacrificed the runtime speed on web applications that was written in rails. In fact, according to performance comparison result published online, the performance of rails on JSON serialization, single query, multiple queries, fortunes, data updates and plain text, are way far from the top tier of all of the frameworks. <ref name ="benchmark">http://www.techempower.com/benchmarks/</ref>
Unique way of thinking
Ruby is a smart language, so as Ruby on Rails. Most of the works on rails seem to be more than straight forward, as well as readable. However, the more people focus on rails, the more they are far from the effort behind. There are more and more frameworks that were inspired by rails, but most of the long-existed large scale works are built based on a traditional way. Most of the times the way of thinking in Ruby on Rails is not adaptable to other languages, especially for those frameworks that are considered more "enterprise-based".

CakePHP

Inspired on the Ruby on Rails project and using many of the same concepts, it’s called this way because it was written based on a minimal version of a Rapid Application Framework in PHP. CakePHP is licensed and distributed under the MIT license, and provides an extensible architecture for development of web applications.

The slogan of CakePHP is to “CakePHP makes building web applications simpler, faster and require less code.” [2] Started from 2005, CakePHP has been praised for its security, flexibility, and the support of good MVC convention.

Strengths

Build quickly and no configuration". Rapid prototyping without XML or YAML files.

Framework is completely open source. Perfect for commercial applications.

Security built-in tools. CSRF protection, Sql injection prevention and XSS prevention help develops applications safe and secure.

Weakness

Inability to create tables based on the definition model and no admin interface.
Speed
Although the current version is much faster and efficient than previous versions, CakePHP is still one of the slowest frameworks without optimization. It is even slower than Ruby on rails. <ref name="benchmark" /> <ref>http://blog.curiasolutions.com/the-great-web-framework-shootout/</ref> However, there are still a lot of discussions about how to optimize the speed of cakePHP due to its popularity, such as speed up the reverse routing, change the setting of caching, etc. <ref>http://www.dereuromark.de/2012/02/13/what-really-speeds-up-your-cakephp-app/</ref>

Django

This is a high level Python Web framework for rapid development on the Web in an easy way. It mainly focus on the DRY (Don't Repeat Yourself) Principle, and it provides several free API’s to handle database-abstraction. According to the documentation, a typical workflow is to get the site as fast as possible, populate the data (as in a content management publishing), to finally develop the data in the same way is presented to the public.

Strength

Just to mention some of the most important:

With the Object-relational it is possible to define the data model entirely in Python and get a rich dynamic database-access API for free — but you can still write SQL if needed.

Quick example This example model defines a Person, which has a first_name and last_name:

from django.db import models

class Person(models.Model):
   first_name = models.CharField(max_length=30)
   last_name = models.CharField(max_length=30)

first_name and last_name are fields of the model. Each field is specified as a class attribute, and each attribute maps to a database column.

The above Person model would create a database table like this:

CREATE TABLE myapp_person (
   "id" serial NOT NULL PRIMARY KEY,
   "first_name" varchar(30) NOT NULL,
   "last_name" varchar(30) NOT NULL
);

The Admin interface save work on creating interfaces for people to add and update content.

The Cache system based on memcached enables django the super perfomance needed for any application.

Weakness

Terminology. Apparently Django does not share the same view for the MVC framework, the Controller is called “View” and the View is called “template”

Some would say that is not greatly customizable, which could be good for a rapid development, but it will limit the flexibity too.

Play!

Written in Scala and Java, Play Framework is another choice for Java lovers that was developed based on open source, following the MVC model pattern, and is also inspired on Ruby on Rails and Django. Famous websites built with Play! are LinkedIn, coursera, etc. Play! calls itself as “The High Velocity Web Framework For Java and Scala” <ref>http://www.playframework.com/</ref>.

Strength

Simplified development cycle due to full-stack
play framework comes with almost everything that a web application will need for development, which minimizes the waste of time on setup for the framework and looking for additional libraries during the development cycle. It comes with compiler, web server, in-memory DB server, offline documentation, integrated database manager, local and distributed cache management, fixtures, evolutions, dependency management, lots of utility libraries, unit tests, selenium tests, functional tests, and great IDE support (because it's Java!).
Provide built-in frameworks for unit testing and functional testing. Allow use to mock a whole application for testing reasons.
As every Java lover got used to, play utilizes JUnit for unit testing and functional testing. Play is also famous for the unique way in which it approaches testing. It makes use of JavaTest with FakeAplication to allow developer to spin up a real version of "fake application" with an in-memory database. Moreover, it has a good default for selenium test for black box testing to produce reproducible tests for use cases. They also provide a decent interface to give an overview for the written tests. <ref>http://zeroturnaround.com/rebellabs/the-2014-decision-makers-guide-to-java-web-frameworks</ref>

Weakness

Simple at first, but it gets complicated when trying to take full advantage of it <ref name="javacompare">http://zeroturnaround.com/rebellabs/the-curious-coders-java-web-frameworks-comparison-spring-mvc-grails-vaadin-gwt-wicket-play-struts-and-jsf/11/#!/</ref>
Like other frameworks, it is easy to get a simple web application built with play framework to get off the ground. Play wants to provide the whole ecosystem, which is way more than a mere framework. They provide a lot of features that are really convenient to develop a web application one in all, but in some cases, it is required to research into the Scala when necessary.
Significant learning curve when integrating it with any existing build tools and environment. <ref name="javacompare" />
As mentioned above, play actually provides a well-built ecosystem, but rather than a mere framework. Swapping or migrating the existed items in the infrastructure may not be working well. Even if it is in Java, it did not take advantage of the flexibility and robustness of Java.
Lack of backward compatibility
One of the most generally accepted problems of play framework is the lack of the backward compatibility. For now, play 2.x is not compatible with play 1.x, which is also a potential concern for the web developer who wants to keep the framework updated in the future.<ref>http://www.javacodegeeks.com/2013/09/the-pros-and-cons-of-play-and-grails-java-framework.html</ref>

Feature-based Comparison on Web Frameworks

Feature-based Comparison on Web Frameworks <ref>http://en.wikipedia.org/wiki/Comparison_of_web_application_frameworks</ref>
Project Language Ajax MVC framework MVC push-pull Testing framework(s) DB migration framework(s) Security framework(s) Template framework(s) Caching framework(s) Form validation framework(s) Scaffolding
Ruby on Rails Ruby Prototype, script.aculo.us, jQuery Yes (ActiveRecord, Action Pack) Push Unit Tests, Functional Tests and Integration Tests Yes Plug-in Yes Yes Yes Yes
CakePHP PHP >= 5.2 Prototype, script.aculo.us, jQuery, MooTools Yes Push Unit tests, object mocking, fixtures, code coverage, memory analysis with SimpleTest and XDebug PHPUnit (cakephp 2.0) Yes, CakePHP Schema Shell by default, and some others ACL-based Themes, layouts, views, elements Memcache, Redis, XCache, APC, File Validation, security Yes
Django Python Yes Yes Push unittest, test client, LiveServerTestCase Provided by South(http://south.aeracode.org/), Django Evolution ACL-based Django Template Language Cache Framework Django Forms API No, not by default
Play Scala/Java Yes Yes Push-pull Unit test, Functional test, Selenium Yes, similar to Ruby on Rails via Core Security module Yes Yes Server-side validation Yes

References

<references/>