Libraries and frameworks for my new Web 2.0 project: jQuery

Web Development No Comments »

After I chose Yii Framework as my server-side technology, the next thing to choose was a JavaScript/AJAX library.

I was quite confident from the beginning that I’d use jQuery. Even though I never used it before, it seemed like everyone else was, so I though it must be pretty good.

Before jQuery I used ExtJS a little. ExtJS has a lot of cool widgets, but I never really understood how its widgets worked inside. I had some experience using Ext’s Element class to modify the DOM directly - I liked the low-levelness of it, but it was a little awkward to use. The thought of coding my own widgets (which I had to do for this new project) using ExtJS was scary.

So knowing that my new project is almost 100% JavaScript/Ajax and that I would have to write my own widgets since there aren’t any existing ones in any library that are like what I need, I decided to go with what people said was the best DOM manipulation library .. jQuery.

And so I tried it out … and was quickly amazed with how fast I was making progress on my project. Within a few days of using jQuery, I had the basics of the most important widget I had to code running. Using jQuery is a joy and whatever you imagine you can code it jQuery pretty quickly with only a few lines of code … but maybe too quickly.

The problem with using jQuery by itself is that because it is so easy to use, it can make you lazy in regards to structuring your code well and trying to make your code re-usable. Because everything feels like it’s only a few lines of code away to reality, you tend to go on and write it even though you already wrote a similar block of code just a few hundred lines above. At least this is what happened to me.

Because of this, even though I got my app working in only a few days it was (almost) all spaghetti code with little blocks of copy n pasted code all over the place and it was hard to find where to change things.

jQuery has a ‘plugin’ mechanism where you can extend jQuery by adding new functions to the $() object but I found it to be lacking. What was needed was a good Object Oriented Class system for JavaScript. My solution to that is going to be in my next post.

In any case, I have to say that jQuery is a very elegantly designed library that fulfills its purpose (DOM Manipulation) extremely well.

Here are the articles that helped me most when learning jQuery and more advanced JavaScript:

JavaScript Object-Oriented Programming Part 1 and Part 2 (a little dated, but explains the basics nicely)
Explaining JavaScript scope and closures
jQuery for JavaScript programmers
Improve your jQuery - 25 excellent tips
5 Tips for Better jQuery Code

Libraries and frameworks for my new Web 2.0 project: Yii Framework

Web Development 2 Comments »

For years I’ve been wanting to develop a certain Web 2.0 application I have designed in my mind but I’ve never found the time to do it … until now. It’s not that I have more time these days, but I just can’t stand living without it anymore… Yes, I want to use this application so badly that I can’t stop myself from writing it anymore :)

I’ve decided to blog my experiences developing this application, beginning with how I chose the technology to build it on.

First item: Which PHP framework?

Why a PHP framework and not Rails? Well, I’ve used Rails before and it was my first exposure to the “convention over configuration” concept applied to an MVC framework.

My previous experience in MVC frameworks before Rails was Struts and a proprietary J2EE framework that was used in a project I worked on when I was at Accenture. Using Struts and that framework was XML configuration hell. (Side note: My experience with these frameworks taught me that XML should never be used for anything that might require hand-editing. Especially configuration files!)

After that Rails was (almost) heaven. The thing that Rails (and the newer frameworks) give you is the ability to code websites incredibly fast while at the same time keeping your code well structured. But the downside of Rails (for me) was it uses Ruby.

I found learning Ruby on Rails was learning 2 things at the same time. Ruby AND Rails. I put the hours into learning it properly, first learning Ruby, then Rails and I got pretty competent with it. But then I imagined how hard it would be to find and train employees to use Ruby on Rails. Where I’m at (Thailand) it’s hard enough to find good programmers. I would guess it’s almost impossible to find good Ruby programmers.

PHP on the other hand .. well everyone knows PHP.

Back in 2007 I had to find a framework for developing so I started evaluating PHP frameworks. At that time there were many new PHP frameworks popping up. I started with Symfony .. but I just didn’t “get” it’s beginning example. It all seemed complicated somehow and I just couldn’t get into it. No offense to Symfony though, it was probably just me. The other leading framework at that time was CakePHP. So I started learning it and quickly fell in love with it. Here was a framework that took Ruby on Rails’ ideas, applied it to PHP and made it even better! In the end was built using CakePHP and training employees to use CakePHP was painless.

I still love CakePHP, but for my new Web 2.0 project, I decided to see if there was anything a little more “lightweight”. I discovered the Yii framework. It’s biggest selling point for me was it’s performance .. just take a look at this performance benchmark. While the benchmark is just a Hello World benchmark, it is still significant for me as my new project is almost 100% AJAX which means it will require lots of small requests and the server should respond to each request very quickly for a good user experience. Since Yii only loads parts of itself that’s required in each request as needed (instead of the whole thing as in some other frameworks) it is very fast for small simple requests and I think it should be a great fit for AJAX applications. CakePHP on the other hand is better fitted for large websites where each request is a whole web page as it has lots of cool stuff to help with generating HTML responses.

While Yii’s performance is what first convinced me to try it, after using it I’ve found that it is also a very well structured library and easy to use. I haven’t had as much experience with it as I had with CakePHP, but so far it fits my needs very well.

So that’s my choice for the server side technology, Yii.

Design by j david WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Login