Presentation on how to chat with PDF using ChatGPT code interpreter
Yii Framework in the RAD context + Mashup demo built on YII
1. Yii framework in the RAD context
George-Leonard Chetreanu
Faculty of Computer Science, Iasi, Romania
george.chetreanu@info.uaic.ro
Abstract. The following papar provides a general view on RAD topic as well
as a short presentation of a particular development tool targeting the web.
M otivation for choosing the tool and a comparison with its alternatives are also
present.
Keywords: Web, database, DAO, AJAX, REST, services
1 Overvie w
1.1 Definiti on
Trying to answer what RAD means, it can be noted that there are various definition s
and exp lanations for the term, out of wh ich some worth mentioning are the fo llowing:
James Mart in, in his book first coining the term in 1991, wrote, “Rapid Application
Develop ment (RAD) is a development lifecycle designed to give much faster
development and higher-quality results than those achieved with the traditional
lifecycle. It is designed to take the maximu m advantage o f powerful development
software that has evolved recently.”
Professor Clifford Kettemborough of Whitehead College, University of Redlands,
defines Rapid Applicat ion Develop ment as “an approach to building co mputer
systems which combines Co mputer-Assisted Software Engineering (CASE) tools
and techniques, user-driven prototyping, and stringent project delivery time limits
into a potent, tested, reliable formula for top-notch quality and productivity. RAD
drastically raises the quality of finished systems while reducing the time it takes to
build them.”
Online Knowledge defines Rapid Applicat ion Develop ment as “a methodology
that enables organizations to develop strategically important systems faster while
reducing development costs and maintaining quality. Th is is achieved by using a
2. YII framework in the RAD context
series of proven application development techniques, within a well-defined
methodology.”
To put it shortly, RAD is a method and a set of tools allowing the rapid production
of software systems from concept to finish1. This technique emphasizes extensive user
involvement in the rapid and evolutionary construction of working prototypes of a
system to accelerate the system develop ment process. RAD is sometimes referred to
the “spiral approach” (see Fig.1) because the nature of the technique involves
repeatedly spiraling through the phases to construct a system with various levels of
completeness and complexity 2. RAD was a response to non-agile processes developed
in the 1970s, such as the “Waterfall” model. The problem with previous
methodologies was that applications took so long to build that requirements had
changed before the system was comp lete, often resulting in unusable systems.
Originally intended to describe a process involving application prototyping and
iterative develop ment, the term has become a marketing buzzword that generically
describes applications that can be designed and developed within 60-90 days.
Fig. 1 RAD Diagram by James P.
1 http://wysterdesir.com/2008/09/28/using-rapid-application-development-for-your-software-
project/
2 http://www.jscgroup.com/rapid-application-development.html
3. YII framework in the RAD context
1.2 Prerequisites3
Gathering requirements using workshops or focus groups
Prototyping and early, reiterat ive user testing of designs
The re-use of software co mponents
A rigid ly paced schedule that defers design imp rovements to the next product
version
Less formality in reviews and other team co mmunicat ion
4, 5
1.3 Advantages
Speed: the speed increases can be achieved using a variety of methods including,
rapid prototyping, virtualization of system related routines, the use of CASE tools
and other techniques.
Quality: as defined by RAD, quality is both the degree to which a delivered
application meets the needs of users as well as the degree to which a delivered
system has low maintenance costs. RAD increases quality through the involvement
of the user in the analysis and design stages. Some systems also deliver advantages
of interoperability, extensibility, and portability.
1.4 Disadvantages
Reduced scalability: because RAD focuses on development of a prototype that is
iteratively developed into a full system, the delivered solution may lack the
scalability of a solution that was designed as a full application fro m the start.
Reduced feature sets: due to time bo xing, where features are pushed off to later
versions in favor of delivering an application in a short time frame, RA D may
produce applications that are less full featured than traditionally developed
applications. This concern should be addressed as soon as possible through clear
communicat ion with the client as to what will be delivered and when.
3 http://searchsoftwarequality.techtarget.com/definition/rapid-application-development
4 http://www.blueink.biz/RapidApplicationDevelopment.aspx
5 http://www.selectbs.com/analysis-and-design/what-is-rapid-application-development
4. YII framework in the RAD context
2 YII Frame work
Yii is an open source, object-oriented, high-performance, co mponent-based PHP
web application framework best suited for developing Web 2.0 applications. Written
in PHP, it pro motes clean, DRY design and encourages rapid development. It works
to streamline your applicat ion development and helps to ensure an extremely
efficient, extensible, and maintainable end product.
Its clear mission statement is very much alike with some ideas behind the RAD
methodology: Yii helps Web developers build complex applications and deliver them
on-time.
Being designed with performance in mind, Yii is a great choice for any sized
project ranging fro m simp le websites to sophisticated, enterprise applications. With
YII the developer has full control over the configuration from head-to-toe
(presentation-to-persistence) to conform to any particular enterprise development
guidelines. The framework co mes packaged with tools to help test and debug the
applications built on it. It worth ment ioning that developers have easy access to a
clear and comprehensive documentation along with plenty of other resources to
inspire or help things get started.
YII development has been inspired by other well-known and proven frameworks
and applications like Prado, Ruby on Rails, jQuery, Sy mfony or Joo mla.
2.1 Features 6
Model-View-Controller (MVC) design pattern: adopts the proven MVC
architecture, wh ich allows for clean separation of concerns (SoC).
Database Access Objects (DAO), Query Builder, Active Record, DB Migration :
allo ws developers to model database data in terms of objects and avoid the tedium
and complexity of writ ing repetitive SQL statements.
Form input and validation: allows collecting form input extremely easy and safe. It
comes with a set of validators as well as numerous helper methods and widgets to
simp lify the task for form input and validation.
AJAX-enabled widgets: integrates jQuery and provides a set of AJAX-enabled
widgets, such as auto-complete input field, treeview, data grid, which enables
writing highly efficient and versatile user interface extremely simp le.
Authentication and authorization: built-in support for authentication and also for
authorization via h ierarch ical role -based access control (RBA C).
6 http://www.Yiiframework.com/features/
5. YII framework in the RAD context
Skinning and theming: the implemented mechanism allows developers to quickly
switch the outlook of a Yii-powered website.
Web services: supports automatic generation of comp lex WSDL service
specifications and management of Web service request handling.
Internationalization (I18N) and localization (L10N) : supports message translation,
date and time formatting, nu mber formatting, and interface localizat ion.
Layered caching scheme: supports data caching, page caching, fragment caching
and dynamic content. The storage medium of caching can be changed easily
without touching the application code.
Error handling and logging: Errors are handled and presented more nicely, and log
messages can be categorized, filtered and routed to different destinations.
Security: equipped with many security measures to help prevent your Web
applications fro m attacks such as SQL in jection, cross -site scripting (XSS), cross-
site request forgery (CSRF), and cookie tampering.
Unit and functionality testing: support for writ ing and running unit tests as well as
functionality tests, based on PHPUn it and Selen iu m.
Automatic code generation: provides a set of intuitive and highly extensible code
generation tools that can help you quickly generate the code you need for features
such as form input, CRUD.
Compliance to XHTML: HTM L code produced by Yii co mponents and code
generators complies to the XHTM L standard.
Purely object-oriented: sticks to strict OOP paradig m. It does not define any global
function or variable. And the class hierarchy that it defines allows maximu m
reusability and customizat ion.
Friendly with third-party code: designed to work well with third-party code, fro m
PEAR o r Zend Framework, for examp le.
Detailed documentation: Every single method or property is clearly documented
and there are also plenty of other resources at hand (tours, book and comprehensive
tutorials, wiki, blogs of enthusiastic users sharing code snippets and more).
Extension library: base functionality can always be extended by adding user-
contributed components that are grouped in an extension lib rary.
2.2 Comparison with alternative solutions
General
As opposed to other RAD tools based on technologies other than PHP, YII framework
doesn’t have a custom IDE to allow developers to build application in a „visual”
fashion by using forms, wizards or „drag-and-drop” editing to get components in
6. YII framework in the RAD context
place and connected. However, YII provides a web-based GUI for its code generation
and customizat ion functions, which can be seen as a basic but satisfactory alternative
to the capabilit ies of an actual IDE. Since the main focus when developing a business
application is to correctly model the requirements/necessities and make prototypes to
mirror real-life aspects, the way YII wo rks couldn’t be more appropriate: provided a
database model was designed, the framework then takes over and takes care of all the
functionality needed in order to interact with the model, allowing the developer to
handle the implementation of the business logic instead of loosing time „reinventing
the wheel”.
Furthermore, certain well-established development tools already provide support
and integration for YII. CodeLobster PHP Edit ion is a very good choice for a fully
featured IDE designed for web development that, among other important benefits,
helps develop YII based applications.
The very nature of YII Framewo rk and its lack of an IDE doesn’t recommend it for
non-technically skilled users, as oppos ed to some RA D tools wh ich, providing a lot of
automation and heavy visual editing, enable users with little o r no programming
knowledge to produce web applications. However, it worth mentioning that the
resulting applications in such cases are either not very complex or they are very hard
to customize in ways different to those taken into account by the tool’s developers.
Same technol ogy
Fig.2 shows how efficient is Yii co mpared with other popular PHP frameworks. In
the graph, RPS stands for "request per second" which describes how many requests an
application written in a framework can process per second. The higher the number,
the more efficient a framework is.
It can be easily seen that Yii outperforms all other frameworks in this comparison.
The performance advantage of Yii is especially significant when the widely
used APC extension is enabled.
7. YII framework in the RAD context
Fig. 1. Speed test obtained with ApacheBench tool7
Co mparing Yii with one of its main, still more popular and widely us ed competitor,
CakePHP, there are quite a few things that make Yii better:
PHP 5 features included in the core: First, and most importantly, what allows for
most of the stuff that I love in Yii over CakePHP is that it is PHP 5 only. PHP 4 is
not supported. Because of this, Yii is able to take use of many PHP 5 features that
Cake is not able to (like magic overloading functions )
OOP style AR and lazy loading: Yii takes use of PHP 5’s overloading functions in
its AR implementation in a very beautifu l manner. Instead of storing results from
queries in an array as Cake does, Yii allo ws accessing the queries in an OOP
manner.
Excellent Documentation
Fast and useful developer feedback : Along with the documentation the Yii
foru m is also an excellent place to get help.
More easily extended: This can be easily seen for the validation rules: beside
permitting to define an action in the model as a validation as in Cake, YII allows
to also define a whole class to be a validation type.
7 http://www.Yiiframework.com/performance/
8. 3 Mashup demo application
The envisioned mashup application was planned to bring together functionality /web
services from Twitter, Flickr and Google Maps. To run the application the user is
required to provide his Twitter account name (username). This is the only information
needed to start retrieving relevant data about the user, which will be nicely presented
in a combined fashion on the homepage and on the Map page.
The flow of the application is described below:
1. The account name is used to obtain the real name of the user and his address, along
with other Twitter related information (like his latest tweet and various statistics
about his twitting activity).
2. The real name is then used to look up photos of the user on Flickr. If the user is not
found on Flickr or doesn’t have any public photos available, the application will
search for photos from the user’s location. This search is customized to return
photos meeting a couple of criteria (like to be taken indoor an d to have geolocation
information available).
On homepage:
1. The user’s name, profile picture and latest tweet (with the date when it was posted)
are displayed.
2. Twitter tab is populated with Twitter gathered information.
3. A limited number of the photos are used to create a photo gallery placed inside the
Flickr tab. Each photo is listed along with the date when it was uploaded to Flickr.
Clicking on a photo opens the normal sized version along with its title.
On Map page:
1. The user’s profile picture is plotted on the map to the user’s location. Rolling over
with the mouse will display the user’s name. Clicking on it will display the user’s
latest tweet.
2. For all photos that have geolocation data available (latitude and longitude) a photo
icon is placed on the map in the right location. Rolling over an icon with the mouse
will display the photo’s title. Clicking the icon will display an info box containing
the small size version of the photo and other details beside its title (date added,
tags, views). Clicking the actual photo from this box will open the original Flickr
photo in a separate browser window/tab.
9. YII framework in the RAD context
3.1 Project setup
Coding was done with CodeLobster PHP Edition, which, as previously mentioned,
provides support for creating YII applications. XAMPP for Windows (PHP5) was
used to host and run the project locally.
Using the “New Project” wizard from CodeLobster (File->New->Project->Create
Empty Yii Site) a fresh skeleton of a YII application was deployed within minutes
into the htdocs directory of the web server. The newly created application was already
functional without any intervention made to the code and could be run in a browser,
having a default structure which included the following pages: Homepage, About
(static), Contact and Login.
3.2 Customization
The look of the application was edited from the main CSS file (root/css/main.css).
Changes in the default actions (what to do on each page) required the update of the
application’s main controller (root/protected/controllers/SiteController.php).
Menu links were edited from the main template file (root/views/layouts/main.php).
General settings (application name, enabling friendly URLs and extensions imports –
paths instead of params) required the update of the application’s configuration file
(root/protected/config/main.php)
To add new functionality to the framework, the following extensions were installed
(by simply copying their files to root/protected/extensions/ :
1. EActiveResource
2. httpclient
3. jquery-gmap
4. phpThumb
5. jqPrettyPhoto
6. ImageHelper
To make use of the new functionality, the following models were coded (and added to
root/protected/models):
1. FlickrUser – in charge of consuming web services from Flickr
2. TwitterUser – in charge of consuming web services from Twitter
Since the intended mashup didn’t require authenticating the user, the Login page was
modified (and its title and menu link changed to “Settings”) to serve as the place
where the user inputs his Twitter account name. The existing form code was edited
accordingly to leave only one field for the user to fill. The changes were performed to
the following files:
10. YII framework in the RAD context
1. root/protected/models/LoginForm.php
2. root/protected/views/login.php
Homepage template (root/protected/views/index.php) was edited to display general
user information and a tabs widget. The widget required two new template files to be
coded:
1. root/protected/views/tabTwitter.php
2. root/protected/views/tabFlick.php
The “About” page template (root/protected/views/about.php) was edited (and
renamed to map.php) to display the custom Google Map. The “About” page title and
its menu link were changed to “Map”.
These were all the changes made in order to get the mashup functionality in place. All
other files of the generated Yii application were not modified.