Wednesday, December 30, 2009

Axis bank programming error or deliberate prank

Look at the number 4 in front of each menu item and the ) in front of logout.

Even the signon page has a -) in the title. Not sure if it was some easter egg as both the pages seems to be functional in all respects.

Saturday, December 26, 2009

Holy Cow Google is crawling my site real time

I submitted a post and it was searcheable on Google index within minutes. I wonder this is because the blogger I am using is owned by google.

Premature optimization

I have been assigned the task to increase the the performance of the application in my last 2 companies and from my past experience I believe in 80-20 code execution rule, i.e. in production most of the time its the 20% of the code that is being executed and the rest 80% is used rarely. Therefore before you embark on increasing the performance of the website
  1. You should know your customers
  2. You should know their usage patterns
  3. You should first collect statistics about what are the features that customers are using heavily
Don't try to guess which features are used, do a quantitative analysis and focus on only those features that are used heavily. Apache/Tomcat access logs can be your buddies in reaching the goal, take daily logs from last 2-3 months put them in mysql or any DB using some simple python/perl script and create some excel graphs and do a trend analysis. For example in the below graph of webdav usage, I would rather focus on optimizing the PROPFINDs first then other operations.

Writing simple code is hard, following KISS ( is tough, whenever you try to increase performance of a feature you compromise simplicity and make the code a bit more complex then it was before. Therefore I don't believe in premature optimization, Donald Knuth had said "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil".

Every programmer should follow some basic programming guidelines for performance when writing code but he shouldn't be too obsessive about performance when writing code, I have seen people writing Java code like C. They would not use Java's Date datatype or ArrayList and will use long to store dates and arrays instead of arraylist everywhere. Now tell me this if you are developing some Admin screens,user profile screens for a website or you are developing some internal application to be used by a handful of people making 100-200 request in an hour, why would you spend so much time making the code worse and complex by optimizing it prematurely. Analyze your apache logs insanely and focus on features that are used by customers heavily. Take the first 10 culprits optimize them and then repeat the process till you feel no more juice can be squeezed from the lemon.To optimize the top culprits if you have to compromise simplicity then its ok but don't make the job for the guy who is going to maintain the code after you leave hard by prematurely optimizing the whole code base.

Ofcourse if you are designing a new feature in an application and you foresee that it's going to be used heavily then  keep scalability and performance in mind when architecting the application but keep the code simple and before releasing it do some load testing using Jmeter or Load Runner and profile the code using some tool like JProfiler and optimize only the hotspots (code that is being executed 80% of the time ;) ).

Tuesday, December 22, 2009

Brother MFC490CW printer offline issue

Bought a new Brother printer on Thanksgiving day sale, though the reviews for a 1 year old version were better I bought this one thinking that it would be more better, but this is worse. The printer has no issues connecting for the first time and I was able to scan,print, copy through it but after 2-3 weeks I had to print a document and the printer would show offline in systray.One design flaw I see straight away in printer was no Ethernet port, WTF and it had only a USB port(at 10 in the night I didn't wanted to go shop for a USB port). Googling on it I somehow found that if you reinstall the printer it would work, later I found that there is no need to reinstall as my router is DHCP and I hadn't given a static IP to the printer it was getting a different IP so I had to go to printer properties and change the port.

After 1 week I had to scan a document for my wife's Math assignment and the printer in systray was showing offline, changing printer properties also wouldn't work as the scanner software was different. I did remote setup, reinstall the software but nothing happened. Again Googling someone told me to install a DNS server, I did nslookup on my printer name and it was resolving to some ip on internet, no wonder it would show me offline, I use roadrunner DNS. No way I wanted to install a DNS server for a freaking printer so I just managed to create a host entry and it worked like a charm. The issue turned out to be brother printer software only understand host name and doesn't go by IP address though you had given IP address, adding a host entry in c:\windows\system32\drives\etc\hosts file fixed the issue.

Net net the point I want to make for Hardware/Software companies is to understand the customer and design keeping the real world scenario in mind. Brother should know that 90% of its customer base is non-techy.I am in technical field I can understand this jargon, it was a troubleshooting issue and it was intimidating and I could spend 3-4 hours fixing it(complex bugs create a curiosity in engineers). A non technical guy who doesn't understand this jargon would simply just give up or call tech support guys. For tech support guys it would be nightmare getting repetitive calls every time. At least brother should put it as a FAQ on their site. Didn't brother guys tested this scenario of restarting the printer and testing again when it got a new DHCP IP address?

Saturday, December 19, 2009

Importance of Community support when evaluating open source software

In my previous company we were evaluating ExtJS v/s SmartClient, we did lots of comparisons and SmartClient had lots of cool features and was up to the par with ExtJS but the only thing that was lacking here was traction in the community, finally we decided on ExtJS. When evaluating an open source product I give lots of importance to open source community around that product, namely I look for
  1. Does this product has a mailing list, how active is the mailing list? how many messages are posted by users per month and are there enough discussions going on?
  2. How frequent are releases for this product?
  3. How many users have written blogs and tutorials about this product?
  4. Are there any books from OReilly or Manning about this product (I rate Manning and Oreilly books better then other and I hate the SAMS 24 days books)
  5. How many bugs are closed,Open,In QA for this product
  6. How old is this product? Old product have their own baggage so if a newer kid is on the block with a vibrant community I would compare features and go for it.
That is the same reason I would prefer ExtJs over SmartClient, Struts over JSF, Hibernate over JDO.

Making Windows 7 programmer friendly

My build suddenly started taking a long time(15 mins) one day and the reason was disk related. I started digging into it then thought of creating another smaller partition for just codebase so that I can defrag it at a higher frequency. When I created the partition and tried moving my source code it took more then an hour to copy 5G of data from one drive to other drive and I thought it was some Virus or my AntiVirus software and for some reason I right click on the drive and I accidentally found that windows by default indexing content of files.

Unchecking this and then Disabling the windows search service entirely from my maching made my build time from 15 min to 6 mins. It looked like when my build was copying files around in tomcat stupid windows was indexing my files. This was happening even when my content was on c:. Anyways now I am happy. Even 6 mins of build time is killing. I share a virtual box folder to my ubuntu VM to do the build. Virtual box shared folder performance sucks so hoping that they release a new version which fixes this issue. If I run this same build on some cruise box it takes just 1 min.

Though this has a side effect that I can no longer use the Fast Search in outlook as I disabled the windows search service, but hey outlook search anyways sucks that's why I like Gmail.

Monday, December 14, 2009

Food Inc.

If you see this movie you won't like to eat your food. They have made a factory out of processing food.  and

I am glad being a vegetarian I am less affected by it as most of the stuff in this movie is related to processing meat for Fast food joints. No wonder so many fast food joints can afford to have a dollar menu.

Sunday, December 13, 2009

Being Lazy

Not sure if anyone also feel like me but I really get annoyed when I have to think about things I shouldn't have in first place. Below are few examples of things that  I get really annoyed at:
  1. Like this blog If I am pasting xml code I have to convert it to xml entities instead of copy paste. This blogger should take care of it.
  2. When you enter credit card information some sites use expiration month names instead of numbers. The credit card itself shows the expiration month as a digit then why the hack I have to convert it to a word when I enter it, instead  of entering 7/11 I have to think oh yaa 7 is Jun and I have to select June 11.
  3. Like the Grouping function in Windows task bar. if I have 4 Firefox windows open I have to click first on the taskbar on FF icon then think oh which window I have to open. I usually disable that feature.
  4. I use this tool called as HotKey Plus that will allow me to type CTRL+ALT+F to open FF. But when I go to other developer machine to debug I hate when this combination doesnt work as I have to open start menu and then search it. Atleast windows7 allows me to search through the available programs by start typing.
  5. Like everytime I start tomcat I have to tail the log so why type two commands. Finally I stared using unix and started using aliases :). Looks like I hate when I have to repeat some thing manually that can be automated.
  6. Consistency is the Key. Like the ordering of buttons on ui is always OK then Cancel button. I was swiping my credit card and hit the first button after signing and damn the first button was cancel and I had to swipe the card again. So again I had to look and think oh yaa whats the order of buttons.
  7. Damn each key board maker shuffle keys and make then small or big and every laptop has different key set, its Qwerty but the order of keys is diff for numlock,delete and insert (I hate to make typing mistakes when I use my wife laptop as I am used to my keyboard, we both have Dell laptops but though the keyboards are different). Why does I have to again look at the keys and think when my subconscious mind had made the decision that this position is delete keys.

Friday, December 4, 2009

Implementing a Simple Http server within Java client

I have to implement BDB replication for backup purpose. We cant afford to miss any commits. we do checkpoint every 2 mins but loosing even 2 mins of data can be catastrophic, therefore we are going to use a simple Java client that will open BDB as a replica and Master will sync every change to this guy and only then it will commit.

Now the challenge was to verify the replication I wanted to print something from this replica or I wanted to stop this replica gracefully. Implementing a shutdown hook wasn't working because kill -9 wasn't calling it and I have to implement some other operations on this Java client. Instead of juggling around with commandline or some RPC I used a simple Http server from Java.
private void init() {
        InetSocketAddress addr = new InetSocketAddress(httpServerPort);
        httpServer = HttpServer.create(addr, 0);
        HttpContext context = httpServer.createContext("/", new AdminOpsHandler());
        context.getFilters().add(new HttpParameterFilter());
        httpServer.start();"Server is listening on http port " + httpServerPort);

    class AdminOpsHandler implements HttpHandler {
        public void handle(HttpExchange exchange) throws IOException {
            String requestMethod = exchange.getRequestMethod();
  "Processing http request");
            if (requestMethod.equalsIgnoreCase("GET")) {
                Map params = (Map) exchange.getAttribute("parameters");
                String command = (String) params.get("cmd");
                Headers responseHeaders = exchange.getResponseHeaders();
                exchange.sendResponseHeaders(200, 0);
                PrintWriter responseBody = new PrintWriter(exchange.getResponseBody());
                responseHeaders.set("Content-Type", "text/plain");
                if ("stop".equals(command)) {
                    responseBody.write("Triggering stop of client");
          "Triggering stop of client");
                    try {
                    } catch (ApplicationException e) {
                        throw new IOException(e);

                } else if ("print".equals(command)) {
                    String workgroupId = (String) params.get("wgid");
                    responseBody.write("Printing workgroupId" + workgroupId);

The challenge was to fetch request parameters from the HttpExchange and then this post from a fellow programmer came handy. Looks like I am becoming Google programmer ;).