Keystroke savers Posted by Swapnil Pathare on Jul 31

A peek at creating the Django Admin interface for any model has floored me completely. I did make a feeble attempt to create something similar for this in Java way back in 2005, but it is quite a daunting task.

The integration offered by Django and RoR really makes one feel that not using these frameworks is just the thing why software developers are in demand today. Hire fifteen to do a job in php which two could do using Django.

Some may say these facilities are just keystroke-savers. Agreed. The important question is why do you not want to save those keystrokes :) . A common application development (without the right kind of framework) spends a significant amount of time (I’d hazard a guess of more than 25%) doing plumbing work. Lets take a Java example for an “edit” screen, which shows the user already stored data, and allows him to make changes:

  • Take data from repository, probably as a generic List
    • Oh yeah, connect to the DB first, and run a DB Statement in a try-catch block, right within your business logic
  • Populate a data bean with all the data. All manually. If the DB cursor contains 25 columns, have a object with 25 attributes, 25 getters, 25 setters and populate all attributes one by one.
  • Send the data bean to the view
  • In the view, have hard-coded UI components for each attribute of the data bean to be displayed. For any related queries to be executed, hard code page links which will fetch those.
  • On event of user clicking OK, program a set of validations to ensure user has not entered bad values. Most of these are not business validations, but checks to ensure no bad characters are present in the input.
  • Populate user entered values obtained through form into a data bean
  • Code a SQL Update script which will take each value from the data bean and update the backend
  • commit (don’t forget that!)
  • Rinse-and-repeat for all related queries

Any framework support (struts, spring, hibernate) is a keystroke saver in addition to being responsible for formalizing (a subset of) the programming for the application. Django and RoR simply take the integration between MVC to the next level. I had mailed a friend a few months ago about what Rails has:

1. Integration with AJAX: You see whether the type of request from the client (browser) is ajax or plain HTTP. You use those conditions to provide a specific response. In case it is an ajax request, you can play directly with elements rendered in the browser (e.g. Put text “Saved Successfully” in the information bar and blink it once). This integration, and resulting 5 lines of code is far faster than anything we would do by ourselves. (client side use ajax-specific library functions to send request, then check XML returned and perform activities in browser using javascript again). This integration is thanks to use of inbuilt prototype and scriptaculous libraries

2. Test Integration: I know that if a nice high-level test framework didn’t exist already, we would never get serious about writing real automated tests. It would always be like “lets develop this cool feature now that we have time… we’ll check out tests later”. Fortunately, tests are easy to write, and we can start small. (full page tests and all can be written later). We can also write Model level tests for ensuring relationships etc. N e a t.

3. MVC Integration: Neat MVC code, easy to write. Controllers and views nicely integrated. All variables declared in controller are directly available to views. Which should have always been the case, but in other barebones J2EE/php, you need to pass a data object explicitly, because MVC is not mandated.

4. Fixtures: Stuff to fill your “Test” database with data. Easy to write YAML (byebye XML). This will auto-run when you run tests, so your test database is ready with required data. If you don’t know yet, Rails will auto-create dev, test, prod databases for easy demarcation. Rails will also auto-clone the dev database schema to test database prior to loading fixtures.

The learning curve is a bit high, and I am spending a lot more time understanding the components in comparison to J2EE. Yet, given the benefits, I think it is well worth the effort.

Google Wave: Information organizing outsourced Posted by Swapnil Pathare on Jun 2

Some may say that it is too late to blog about Google Wave. The applause which started on May 28 can still be heard and the Internet community has done everything but go down on their knees and bow to the awesome concept.

For those who couldn’t manage time to watch the Wave preview, here are just some of the things it does :

  • Acts like email when the recipient is offline
  • Acts like a realtime chat when the recipient is online
  • Maintains a common structure in one place (visible to, and editable by all concerned parties) instead of having copies in every person’s account
  • Allows you to add other recipients to a subset of a Wave or the whole Wave.The new folks can “Playback” how messages were exchanged
  • Allows visual plugins which can take the form of games, polls, etc. For example, instead of sending messages to each other, you can send Chess Moves which the plugin happily records and the game proceeds
  • Allows realtime collaboration on documents with changes tracked. Again, a common copy of document is maintained.

While some skeptical glances are surely cast as to whether people will “embrace” this new concept of communication (as they are still stuck to SNDMSG program and have not been able to comprehend any other way to communicate all these years), the overall mood is that of joy, on having seen something truly profound, and having been promised that this will be available to everyone, for FREE, later this year.

The most obvious thing that hit me while seeing the preview was the way Google relentlessly pursues its mission. Remember Google’s Mission statement?

Google’s mission is to organize the world’s information and make it universally accessible and useful.

This is the way Google earns money: By targeting advertisements suited to your interests. How does it understand your interests? By organizing information about you.

So while the mission is technically about helping the world, it is also a lot about making profit. Of course, there is nothing wrong whatsoever in making profit by developing something which provides value to the user. Microsoft earns by asking users to buy the product, Google earns by providing relevant advertisements.

Thus started the long journey of organizing the world’s information. First they gathered some trends of what we search based on cookie information. GMail was the next big boost as a lot of personal emails meant a lot of personal information. Orkut, Blogger, Google Talk, Docs, Sites, Reader, Youtube; each product added to its suite targets nothing but collection of information from users in exchange for some great services, for free.

Yet, Google would still require to organize bits of information from different applications to understand the “complete picture”. Google Wave, in a lot of ways, has removed that additional effort.

Wave is a communication structure that can be used anywhere. (Potentially) integrated throughout Google Applications and beyond, it provides a single point of communication. Email, chat, organization of albums, blogging, collaborating on documents, everything is either available in the Wave structure or can be derived out of it (by creating a new Wave and importing some specific elements). So now, Google does not need to  organize information about you. You yourself will organize it all using Wave. It is safe to assume that information which might have been dispersed around on a dozen different websites online (Google or others) will now be collected in a common Wave. With little or no effort, your whole life (henceforth) is likely to be captured in a handful of waves. I shudder just thinking of the advertising avenues that follow.

Google, you evil genius, you!

Jaunty: some problems and workarounds Posted by Swapnil Pathare on May 27

OK, so lets have a quick round of what could go wrong post-upgrade to Ubuntu Jaunty and how to fix it, fast. These are some of the problems I faced, and found all the solutions by googling. Just listing them out here. Hope this helps some of you.

1. Proprietary ATI drivers

The first thing we come across is the video drivers which never were. The moment you try to install proprietary ATI drivers for “old” cards (my ATI RadeonExpress 1250 happens to be one of those), you will get a system freeze. No graphics, no inputs, just some random colors on screen, which aren’t very pretty either.

Solution here:

sudo /usr/share/ati/fglrx-uninstall.sh  # (if it exists)
  sudo apt-get remove --purge fglrx*
  sudo apt-get remove --purge xserver-xorg-video-ati xserver-xorg-video-radeon
  sudo apt-get install xserver-xorg-video-ati
  sudo apt-get install --reinstall libgl1-mesa-glx libgl1-mesa-dri xserver-xorg-core
  dpkg-reconfigure xserver-xorg

You could probably create a script of this sort and save it in your home directory, so that when the system does fail, you can easily get into recovery mode (use the “Recovery mode” listed in Grub) and just run this script rather than attempt googling through Lynx, which I almost always end up doing. In case you plan to run this script in recovery mode, you don’t need the “sudo” command for any line since you will be “root” already.

2. Screen Freeze with Compiz

The open source drivers you install for ATI are known to create hassles for 3D graphics. Jaunty does allow you to enable Compiz (System Appearance -> Effects -> Normal / Best). However, I had a complete system freeze lot of times while I gave Compiz a try. I could easily reproduce the strace gedit bug while 3D effects were enabled.

Solution: Disable Compiz (or downgrade :) )

3. VirtualBox fails to start

The Virtualbox kernel module needs to be recompiled for the newer kernel in Jaunty. This problem is not specific to Jaunty (or even Ubuntu), but no harm in listing it here.

sudo apt-get install linux-headers-$(uname -r)
sudo /etc/init.d/vboxdrv setup

The first line downloads appropriate Kernel Headers for the latest Kernel, which will be used by the “vboxdrv setup” command.

« Previous Entries