Archive for August, 2008

VirtualBox vs VMWare

Although I run Ubuntu, I seriously need Windows simulation for some reasons, such as running my company VPN client. So I’ve been looking at VMWare which I used to run Windows as guest on a Windows box. I’m resisting to building software myself, as I’m trying to use Ubuntu as a Windows user — and Windows people don’t build software (as in compile themselves). So I had problems with VMWare. I looked at WINE briefly, but I didn’t install it as I was not convinced that its model would allow me to run my VPN client on Ubuntu. I checked out alternative VPN solutions (vpnc) but it didn’t work out.

Today I found a preferable alternative: VirtualBox. Its free, open source, and light. I attempted to install it from Synaptic, but I couldn’t start the VM due to this error: “kernel driver not installed” and prompted me to install virtualbox-ose-modules-generic. I tried to do that but it wouldn’t allow me, saying its dependency was not fulfilled.

By luck I went to check my kernel version with “uname -r” and found that my kernel is “2.6.24-19-generic”, and Synaptic was trying to install “2.6.24-20-generic”, as the default module installs the latest, which is 20. I manually selected and install the “virtualbox-ose-modules-2.6.24-19-generic”, and it worked!

(Note: some additional steps I took were to add myself to the vboxusers group and relogin before start VirtualBox, and to mount the CD after starting up the VM. I write this in case the next time I reinstall my OS I forgot what I did)

So while I’m waiting for XP to install I’m noting all these down. At the minimum I know I will have XP running as guest on my Ubuntu.

Comments

getdeb

My aMSN wouldn’t login today. Went to aMSN forums, and read that MSN has changed its server protocol, and they had released patches in 0.97.2 to address that.

My aMSN was installed using Synaptic, but when I tried to update it, it says I already have the newest built version 0.97. I understood that they could not release the new version just as fast as the source, and they need someone to build and test it, before they can announce it available on the “official” repository.

Fortunately I found a site which bridges that gap. It sacrifices possible quality issues for a faster release (so that I don’t have to build the updates from source). http://www.getdeb.net/ produces Ubuntu builds for new applications that has not been released in the official repository yet. Best of all, it is released as debs which integrates into the package manager beautifully. The almost one-click process takes me through removing the older aMSN, replaces it with the new one, and retains my settings (my email id on the login screen and chat history were intact and accessible). Of course, I was able to log in peacefully after the upgrade.

+1 for Ubuntu.

Comments

Refactoring

I’ve been refactoring some code, and just have some thoughts on common things I’m fixing.

  1. Do the same thing at the same place. If the same snippet of code appears more than twice, e.g. checks if the user is logged in and redirects the user to the login page, it should be extracted. The fewer the control points, the easier it is to debug or change its implementation. IDEs will also allow you to easily trace who is using this functionality, which may help you access the risk of change. “More than twice” is a general guideline. You might see the potential of extraction even if the code only appears once or twice. Sometimes its not suitable for extraction even if it appears more than twice.
  2. Reduce condition nesting by quickly eliminating alternative flows. Leave the rest of the method for the happy/main flow. e.g. If you detect the user is not logged in, call the redirect and return. Using the return avoids needing an “else” after the if. Adding a comment here helps to understand the alternative condition (see point 5).
  3. Learn the lazy loading pattern. Helps reduce nesting as well if you understand how to apply ifs.
  4. Coherence and Coupling. Standard OOAD.
  5. Comments. Not easy to see good commented code. School only tell us to write comments. Who teaches how to write good comments at appropriate places? There’s no need to comment every line. Nor is it good to be comment-less.

Comments