ARCHIVE: March, 2006

Windows command console is quite primitive, it is good to have the power of Unix console on your Windows. If you are like me, you could have installed Cygwin and you probably have installed Ruby using One-Click Ruby Installer, but encountered some problems running ruby, rails and other ruby-related commands on Cygwin.

Well, same here, and I think it is easier to install a seperate copy of Ruby under Cygwin. Fixing the path differences between Windows and Cygwin consoles can be messy, here are some tips to install RoR on Cygwin:

  1. Install a seperate copy of Ruby using Cygwin setup wizard. Expand All > Devel and select ruby and proceed with the setup.

  2. After you have installed Ruby, download Ruby Gems, extract the setup files to a temporary directory, and when you try to run the setup, you probably will encounter an error.

    ruby setup.rb
    ruby: No such file to load -- ubygems (LoadError)

    Tips:

    When you install Ruby using One-Click installer, it will set an environment variable RUBYOPT=rubygems. It tells ruby to load rubygems library when running a ruby file. You have not installed Rugy Gems, thus the setup.rb execution failed.

    Just unset RUBYOPT variable and re-run the Ruby Gems setup:

    unset RUBYOPT
    ruby setup.rb

  3. Then you can install Rails using Ruby Gems by running:

    gem install rails --include-dependencies

  4. You have irb configuration file (.irbrc file) under your windows home directory, and you still want to use it in Cygwin, create a symbolic link to the file in Cygwin home directory

    cd $HOME
    ln -s [/path/to/windows-user/homepath/].irbrc .irbrc

I’m a New Ruby Convert

MON, 27 MAR 2006

Human being always craves for something better, if you are staying in rented room, you wish for a flat, when you have the flat, you wish for a condo.

It’s the same with software development, we, the developers, mere mortals that have becomed slaves of computers, always wish for a better programming language. A more efficient and easier to maintain codes. Object oriented (OO) programming language especially Java and C# have been gaining lots of adoption for the past few years because it is easier to maintain your codes in object oriented ways.

Though OO programming language is good, it still lacks the agility of scripting language. With customers demand more for each dollar spent, I too, was pushed to yearn for something better. And today I find Ruby; it somehow manages to combine the goods of OO and agility of scripting language. And in today’s context, it simply makes sense, and I’ve decided to be a new Ruby convert.

The DRY (Don’t Repeat Yourself) principle is just too right to be true. It’s amazing to see how few lines your codes can be. The other principle “Convention Over Configuration” saves much of your trouble if you are to try to figure them out yourself. And the best part is all Rubyists speak the same conventions.

Though Ruby is still young, it has been gaining lots of momentum and it will absolutely be the NEXT BIG THING.

Testing with Ruby On Rails

WED, 22 MAR 2006

Remember those days when you fixed a bug only to introduce more bugs in return? That’s what testing is all about, to be more specific is incremental testing. When you write some procudures, you should also write the test procedures. So when a procedure is modified, you retest all the procedures available, then your codes will be less breakable.

Ruby On Rails (RoR) is built with incremental testing in mind, it supports unit testing, functional testing, mock object, performance testing, benchmarking and test data loading support. In java you will have to look at different components such as JUnit, Canoo WebTest, JMock/Easy Mock, JMeter, and DBUnit, not to mention many other libraries trying to do similar things. The problem is the learning curve is high and the components are not as cohesive as RoR test framework.

Here are some points that I like most about RoR test framework compared to Java framework:

Test Templates
It supports auto creation of test templates for controller and model class.
Test Data Format:
Thank God it’s not xml, it’s called YAML (YML Ain’t XML) or “fixtures” the term used in RoR. It’s very easy and intuitive, and hell ya, you can even include ruby codes in there, e.g.
user_supervisor:
        id:             supervisor
        name:           Clark Kent
        date_available: <%= 1.day.from_now.strftime("%Y-%m-%d %H:%M:%S") %>

<% for i in 1..20 %>
user_<%= i %>:
        id:             <%= i %>
        name:           User <%= i %>
<% end %>
Unit Test
In your test code, you can refer to the test data using @user_supervisor, which is very important to create a more flexible test code that caters to changes in test data without breaking your test procedures. e.g.
test_load_supervisor:
        ....
        assert_equal user.name, @user_supervisor.name
end
Rake Command
Rake command is Ant’s brother in Java, they do similar things, only Rake has built-in useful options for developer. I love “rake recent” to test recent updated unit tests (updated in last 10 mintues).
Fewer Lines of Codes
I just can’t resist repeating this point!!!

Ruby On Rails Maybe God Sent

MON, 20 MAR 2006

Last weekend I decided to get my hands dirty on Ruy On Rails. I bought Agile Web Development with Rails book and got hooked immediately.

I studied Visual Basic during my Uni days, but fell in love with Java after my first job. And I’ve been faithful every since, Java has tought me the beauty of object oriented programming, design patterns and frameworks. But due to its flexibility and large number of open source projects. It prones to entangle developers into a mesh best practices to adopt.

For web framework itself, it ranges from request-based (Struts, Web Work, Spring MVC) to component based frameworks (JSF, Tapestry, Wicket), and the combination of both (Stripes) to full-stack framework like RIFE and Appfuse. I used Struts before and when I was looking for a better framework I have to read up JSF, Tapestry and Spring MVC. And I finally settled with Spring MVC, though each framework have its own good and bad points. How about persistence framework (Hibernate, EJB, JDO, iBATIS)?

Learning Ruby On Rails is a different experience, it felt  like sailing through a calm sea with warm sun light and breezy wind. Maybe my bakground in Java and web development industry helps. But it is also mainly due to Ruby’s main guiding principles,  “Don’t Repeat Yourself” and “Convention Over Configuration.” So things are laid for you, chosen and decided. No questions asked. The codes are short, clean, and there are lots of shortcuts. It may look weird at first, but you’ll get used to it.

Compared to Java, Ruby is still very young, but being young, it is able to learn from the mistakes made by its predecessors Java and other languages. And coming from different perspectives to improve developers productivity, and with higher customer expectation each day for each dollar spent, especially in Asia, Ruby may be God sent. I’ve yet to further explore Ruby and to complete the other half of the book; there could be some quirks, but I hope there won’t be many.

Getting Real

THU, 16 MAR 2006

If you are a web enthusiast, by now you should have heard of 37 Signals. It is one of the hottest web solution provider company right now. They are known for the simple and intuitive web applications that they have developed such as Basecamp, Ta-Da List, and Writeboard.

I’ve just finished reading “Getting Real“, the recent book that they’ve just relased (only available in PDF version). I am happy with how personal, inspiring and entertaining the book is. This is an example of a book where every word has its purpose. It shares their experience on getting real when developing web applications. Cut down beauracratic documentations and unnecessary meetings. How with only a small team — e.g. the developer, the designer, the sweeper (one that roam within both worlds), you can also develop a great application.

I remember how I pulled my hair, once my client asked me to fix a spelling error in a functional specification document before we could proceed with the other tasks. Being flexible and agile are some of the points preached. User interface design and simplicity are points that should not be ignored.

The quotes by prominent figures, such as Steve Job and the others at the end of each section are very fun and inspiring as well. I think this book is NOT to be missed. Great stuff in there. And I shall leave you with a quote from Steve, a snippet from the book. And let’s get real!!!

[Innovation] comes from saying no to 1,000 things to make sure we don’t get on the wrong track or try to do too much. We’re always thinking about new markets we could enter, but it’s only by saying no that you can concentrate on the things that are really important.

- Steve Jobs, CEO, Apple ( from The Seed of Apple’s Innovation)

Other Editions Phew…After a few days working on xISBN service to allow BookJetty to probe other book editions, this afternoon I’m glad that the feature is finally up. 

Other EditionsWith xISBN service, BookJetty is now able to tell how many editions are available for each book. So if the latest addition is not found, you can now probe all the other editions too!!

I’ve also added del.icio.us and digg it shortcuts. If you like this site, add BookJetty as your bookmark in del.icio.us, and come on…., DIGG IT! DIGG IT! :)

I’ve also improved the NLB session pooling mechanism. Now, it checks the session validity before borrowing from the pool, if it’s no longer valid, it will create a new session. Let me know if you still encounter some issues with it.

It is not an easy decision to strive on your own, being an enterpreneur in a competitive country like Singapore. And before you start, the Enterpreneurial Proverbs summarises very beautifully how it’s like to be an enterpreneur.

Bookjetty.comBookjetty.com is my first initiative to release an application for the public. I found myself doing repetitive tasks of finding good books in Amazon, and checking each book if they are available in Singapore National Library (NLB).

The chore was quite time consuming, so I decided to create a search engine that combines both results under one roof. The concept is not new, but lately famously known as Mashup, a website that combines the result from multiple sources seamlessly. A9.com search engine is an example of that, Bezurk.com, a travel search engine, is another example; and one of awes me is Trulia.com, it combines the search results from real estate sites and merged them into Google Map.

Stunning, isnt’ it? Thanks to the advancement in Javascript lately, the introduction of AJAX and browser suport for DOM document manipulations, all these Web 2.0 experience are made possible.

The site was designed from library user perspective. It aims to help user to find good books as fast as possible in the library.

  • Popup is  used to avoid unnecessary clicking.
  • Catalogue location is grouped for easy visibility.
  • Sorted by “Not On Loan” groups on the top, as that group matters most.
  • Book locations are grouped for easy readability.
  • Total books, Total Available books, Total Not On Loan books in the listing, for a quick view of book availability.
  • Short description for each book on mouse over for those who don’t have time to read too much.
  • Print catalogue to bring it as a reference to the library.
  • Sales ranking and customer average reviews for quick assesment of the book quality.

Bookjetty.com is still at its infancy, sometimes the listing by amazon only shows the latest edition of a book, and the latest edition may not be found in the library, but other editions may be available. This was due to the Amazon webservices Application Programming Interface (API) does not provide other editions information. But thanks to another online book service, called xISBN service, which provides other book editions list. The list will then be matched back to retrieve book information from Amazon and NLB.

I will be working on this feature this week. So stay tune. Thanks to those who have find this site useful and thanks to many who have sent in their feedback too. Please help to spread it to your friends, family or your kids too.

Note that currently the site is hosted on a shared server in the States, so the response maybe a bit slow at night.

New Look and New Beginning

MON, 6 MAR 2006

I’ve just upgraded Pluit Solutions site to incorporate blogging. The previous design seems to be out dated, as it was done in a rush mid last year.

I decided to use Wordpress, but I was also considering using Typo, with all the AJAX features, I thought, it would be cool too have. But at the end I decided to stick with Wordpress, coz my current server does not support Ruby, and to migrate is just too much hassle. Besides Wordpress has been around for quite some time and loads of plugins available and very well documented.

With the new look to match the spirit of Web 2.0. This year I’ll be focussing on developing applications with Web 2.0 features.