Saturday, 31 January 2009

A simple approach to setting up a maven repository

At last, after I dont know how long I decided to try maven. I knew it is there and it is good,but I guess the final push for me to use this came from that fact that I wanted to manage my jar files better between all my personal projects. I had the trouble of syncing my Linux and Windows systems to the same version of jars while working on Console4Jython, so I decided to wisen up as I tried to finally kick start the other two projects.

Setting up maven locally was simple, and I am happy that now I can just depend on the maven central repository to get all the jars downloaded between my two boxes. I couldn't wait to migrate Console4Jython to Maven - but then I realized that there are jars that I want and are not available on the repository. One way would have been to search for the repositories for these and add them, but thankfully, I decided to set up my own repository and learn. Here is how it is:

  • Get a HTTP server somewhere on the network - I am using my web hosting on the internet
  • Create a folder called "myrepo" in the HTTP root of the server.
  • Inside this "myrepo" , create a folder called "m2-repo"
  • Check that you can access this from all the machines where you will work from, this might be necessary of your repo is on the internet and you might have to configure a proxy. I had to set up the web proxy
Now, I am assuming you have installed the jar to your local repository, if not you can do it by typing a command like

mvn install:install-file -Dfile=jyaml-1.3.jar -DgroupId=yaml -DartifactId=jyaml -Dversion=1.3 -DlocalRepositoryPath=C:\Users\hari\.m2\repository -Dpackaging=jar


Here I am trying to install the JYaml library. For further details you can refer to the maven documentation.

Once you have done this, you can go to your local repository and you will find a folder ~/.m2/repository/yaml. To set up the remote repository you will need to copy this structure to the m2-repo folder that you created previously. But before that you need to geneate an md5 for each file in this directory structure. I used the md5 for Windows tool from here.

Using this create the md5 files for all the files in the directory except the files names *.sha*.

Once that is done, copy the top level folder, in this case yaml, to the m2-repo folder. If you access the url http://myserver:port/myrepo/m2-repo, you should see the following structure

Now add this repository URL to your POM - it should be able to update the jar files.

Thursday, 29 January 2009

Software bugs in my daily life - #1

I am not a big fan of online shopping, but of late due to lack of any other option and partly due to my being in London, I am doing a bit of online shopping. And this is where I found a bug today, and this idea of documenting software bugs in my daily life.

Tomorrow is my mom's 50th birthday, and among other things that I did, the plan was to send her some flowers. So I went to the website of one of the well known florists in Hyderabad,India and logged in. Few minutes later, I had my choice ready and in the shopping cart. As I proceeded through the checkout, I was asked to enter a message on the enclosing card. I typed in a small message - and that is when the fun began.

The page now showed two next buttons. Normally I would expect "Add" or "Save" for the message, and a "Next" to proceed to the next page. Seeing two buttons labeled "Next", I was sort of surprised. I assumed, wrongly, that both mean the same thing - go to next page. So, wrongly again, I clicked the button at the bottom of the page. I was taken promptly to the next page. It looked OK, except that the message on the card as blank!

I looked around and found a back button. I click that, and am faced with a dialog saying page expired, resend data? I clicked OK and am taken to the same page from where I was trying to go back. The message obviously is still blank. But I notice that the delivery charge has doubled.Hmmm ... out of curiosity I hit back again and after hitting OK on the same dialog, I see the page and now the delivery charge is three times what it should be - the cost of the bouquet is still the same.Hmmm ... this time I hit F5 - and bingo the amount is now 4 times the original!

Being a developer myself I can imagine what kind of mistake the chap who coded it might have made. But nonetheless the page doesn't seem to have been tested properly.If it was not for my nitpicking habit if treble checking the costs on every purchase, I would not have caught this.

Thats not the end by the way. Because of the above error I decided to close the session and log in again. Thankfully they do not save the shopping cart between sessions. This time, they offered to load my pre-entered address. I was not really hoping anything here, but the form did get filled up incorrectly. Fields 1 to 4 were OK, 5 and 6 were blank and the 5 went into the 7 field. So fields 9 and 10 never got filled up and fields 5 to 10 are wrong.Hmmm ... by now I am hoping they dont reallys crew up something on my card details.

From then it was pretty much uneventful except for a minor issue with the mandatory form fields.

What appals me in this entire episode is the lack of quality. If it is a student who did this as a part time job, then poor chap is not being taught properly and needs to learn best practices;If it was a professional who was paid full time for this, then he is really bad and I would not trust anything in his hands. I am sure the florist does not have the resources or knowledge to test this stuff and must have trusted the guy who built it - and he did a not so neat job.

There will be guys doing mediocre jobs for as long as we have software, but we must atleast try to avoid mistakes, and if we need to really make a mistake, make a quality one - one that shouts, OK this could not have been foreseen!

Saturday, 3 January 2009

Deja Vu

For the last two weeks I have been working on a project that I left 2 years ago. Back then I was a bit player in a complex web of a project and never made any friends with the client team. I had issues with my manager who - lets be frank - was a complete screw up. I left after a few months when there was no need for me. And like any project that did not bring joy or learning, I blanked it from my brain.

But last two weeks were fun. I remember a few names and faces, but thats it. I was standing outside the office in the freezing London cold and a tall guy walks past me looking at me like he knows me. I start to try and recollect his name, but by the time it strikes me he is long gone. Later in the day I go up to meet the implementation team and this guy is sitting there. Even before I say anything he says - "I know this guy ... ". I smile and tell him I was around two years ago.

Again today I walk up to his colleague - I remember this guy, no way I can forget him, his knowledge is too good - and even before I tell him my name, he says "from Infosys ... " - I could only smile.

There are about 10 to 20 faces I know, pretty ladies I used to keep an eye out for etc etc and it is both funny in a way that I know so many things about the place. Its the first time in life that I am working a second time at the same place. I am enjoying it - and am hoping I have a happier ending this time around in this project.

Checks and validations

The year 2000 bug was the thing that helped draw me towards programming. Thousands od programmers from India and all over the world worked to fix the issue and avoid a tragedy that thankfully never happened. When my cousin explained the issue to me, it seemed trivial, but nevertheless it made me realize how important having a suitable value or variable is.

On 31 Dec, I was busy most of the day working in the office - now new years bash for me, I was bashing a few issues in our first end to end connectivity test for the new application. The first end to end test is always painful. In the middle of all this bug bashing,a friend pointed me to a post about Microsoft Zune just dying - by thousands all over the world. As I learnt more details of the issue, it seemed stupid to me that such a stupid mistake as leap year check could happen. Well today when I saw the code here , I was laughing my ass off.


I see these bugs quite often in the work that I review and when I point it out, the other guy can just laugh. Once I had this guy in my team who built a portal for us. On his last day on the contract he wrote a fix and deployed it to UAT. He left and we never really bothered about the fix for a few weeks. Then one day we got abug saying that the hyperlink for the error detail was failing. It seemed silly - but when I looked deeper I found that it was failing only when the link text was alphanuneric - it would work when the link text was only numeric, whcih was 98% of the times. I called the guy and asked him - he was a pal, so the talk was fiendly. He laughed it off and told me which line to fix, I knew that already, but it seemed a sad state of affairs that something so silly and so obvious was left out - the guy could have paid some more attention and it would have saved us a bug.

In another case, we had a .NET application which did not have a dedicated support team - I was handling it alongside my other responsibilities. Most of the issues we ever got were due to lack of user training.So one evening when I get a call from the first line support saying they cannot export the data grid, I was inclined to push it back as a user error. But the pal on the other end was sure it was weird. So I go to look. I go there, open the grid and run a query that returned about 100 rows and export - OK. I run a query that returns 0 rows and export - I get a blank XML. Cool! Then he asked me to export 1,2 and 3 rows. One and three rows works fine, but 2 fails!!! It works for all n rows where n!=2! I still havent figured where it is going wrong!

Is it so hard to put some checks and validations in your code? Is it so hard to figure all the corner or conditional cases upfront? Its not hard, but it needs some effort - effort which might be easy but we are lazy to put in or effort that gets negelcted because we are running to meet an impossible deadline. Sometimes it is about another big issue that obershadows the main issue. Recently we did a major production rollout that impacted all users and broke compatibility. We had to lock out all users. The impact of failing to lock out all users and a user polluting the system due to a wrong version of the code was much much greater than a wrong fix, so I spent 3 hours making a fix, testing and releasing it to a few users in a controlled manner and one week planning the lock out strategy and fixning small leaks in our lock out code. The fix ran for a week with those few users without any issue - so we were happy. We had issues in the release to DEV but that was my Cruise Control scripts misbehaving. So three weeks and 2 pizza nights in the office we are there ! Except that the fix had a small validation error that screwed up three users. In the shadow of the lock out and with the aim of avoiding the lock out debacle, we screwed up the validation :(

Putting proper validations in code is not tough - if you make it a habit. Making it a habit is the pain.
Once you get into habit, its like riding a bike - you never forget.


LinkLink