Author: Shailesh Hegde

Seven habits of highly ineffective software engineers

I have come across many instances of engineers develop these habits over the years without realising the negative effects.

1. Design? What design?

Let me just bang the code out in a few hours, and we shall see what happens. I don’t need a whiteboard. I don’t need a design spec. I can visualise it all in my head. I am a genius.


What usually ends up happening is that folks need to continuously rework the code because they missed a major detail somewhere, thus increasing the overall development and test duration.


Writing or drawing out a basic design for a fairly large problem and having it vetted by peers goes a long way in ensuring that one spends their coding time effectively.

2. Over optimistic => Over promise => Over deadline

I do not foresee any problems coming my way when I implement the 5 features I plan to work on this month. Nothing comes in my way. I am an optimist.


You run into dead ends with a particular feature, and you need to get help from a colleague in a different time zone, resulting in adding X number of hours into the schedule. And then you scramble and roll out crappy code, or simply miss the deadline.


Scoping is one of the more harder skills of being a software engineer, so better to be safe than sorry. If you finish what you said you would, then roll out a couple more items. Under-promise and over-deliver!

3. Reinvent the wheel

I am not going to waste my googling to check if someone has already implemented a library. Why waste time when I can write code. Isn’t that what I am paid to do?


Spend a few hours writing code, when you could have spent a few minutes using a standard library or a suggestion by someone on


If it seems like something that someone might have come across, there must be a way to handle it, without starting from scratch.

4. I don’t need to run tests

I am only changing a few lines of code in ‘my’ class and ‘my’ function. Why would anybody else be affected. The tests will definitely pass. I am a rockstar.


Expecting the code to run correctly without running tests is suicidal. Just makes for more work when the breakage is detected and panic sets in a day before the release.


Have your tests ready before your code, and run your tests even if you believe your code is not going to break another parts of the system. If all tests were assumed to pass, why have them in the first place?

5. Naming Variables i, ii, iii

I know what the variables denote. I don’t care if its not obvious to others. I am a (wo)man of few words (or letters in this case).


People reading your code have no idea what the variables denote thus making it harder to understand it. And if there are no comments, it only makes things worse.


Use descriptive variables names as far as possible.

6. Complex is better than simple

I am so good that I will make the code complex. People who read it will not get it, and think highly of me. I am a champion.


Sorry, people will be pissed off. Simple is beautiful.

Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live.
— Anonymous


Make it only as complex as it needs to be. Choose simplicity whenever possible. It just makes everyone’s life easier. And there will be many opportunities to develop a solution for a complex problem.

Programming can be fun, so can cryptography; however they should not be combined.
Kreitzberg and Shneiderman

7. Ctrl-C + Ctrl-V

Let me just copy this code and use it where I want. Who cares about duplication. I am lazy.


Duplication. Double updates. Multiple copies of mostly similar looking code adding to the maintenance nightmare.


Factor out common parts into a more generic function. Re-factor now rather than later. Run tests to make sure everything still works.

This happens more often than one would like. A little more big-picture thinking on part of developers would help matters. But I strongly believe the following to be true:

One principle problem of educating software engineers is that they will not use a new method until they believe it works and, more importantly, that they will not believe the method will work until they see it for themselves.
–Humphrey, W.S., “The Personal Software Process”


Peru – The land of Macchu Pichu, Pisco sour and Llamas

It took months of planning, conference calls, flight searches, and a handful of vaccinations before we could set forth on a trip to South America. Seven people – lets call them SS, AJ, TK, AK, VP, AP and me, were debating between Brazil, Peru, Argentina and Bolivia for a 10-12 day trip over the Christmas vacation of 2012. We finally chose Peru, primarily for Macchu Pichu, and Brazil, for its beaches and the Amazon forest.

We uninhibitedly chose December 21st, 2012 as the day of departure from our respective cities. After my airport adventure that afternoon, I met VP and AP at the Miami airport. We were to fly to Lima, and then reach Cusco the following morning. I had taken a few weeks of online Spanish lessons for basics like asking for directions and talking to the cab driver, the hotel receptionist, shopkeepers etc. And now it was time to put them to use with the lady at the taxi counter at Cusco airport. After a couple of minutes of price negotiations in broken Spanish, we hopped into a taxi for a 2 hour scenic drive to Ollantaytambo (Oll–yaan–taay–taambo). The cab driver was quite talkative and we tried our best to follow him. He was very happy to know that we were from India because he loved the Maruti Alto. And there were Altos all around us on the roads! While we were on our way to O, the others coming from the West coast encountered long flight delays and ended up reaching that evening, exhausted from the additional 15-hour ordeal.

We checked into hotel El Albergue, which is quite strangely, placed right beside the platform at the train station there. It’s a lovely little rustic hotel and it was great to be able to relax after the long journey.

Station next to El Albergue

Station next to El Albergue

Outside the station

Outside the station


O is a really small but extremely scenic town, with the Urubamba river flowing by through the mountains, and greenery all around. At a distance we were able to spot a few ruins too. We returned to the hotel, and booked a couple of tours for the next day. In the evening, we were looking forward to taste a few local drinks and food! We started off with Pisco Sour, which is a refreshing drink made up of Brandy, lime juice, egg white and Angostura bitters. After a few drinks, we found ourselves sharing stories from college, laughing out loud and most likely disturbing the other guests! This carried on for a couple of hours, and after dinner we retreated back to get some sleep and be ready for a fun day of touring the places around O.

Our guide and driver for the day did not speak English – Spanish lessons to the rescue! Our first stop was the salt ponds of Maras. The views on the way were breath-taking, and reminded me of the Bajaj Avenger advertisement shot in Ladakh! Taking a detour onto a dirt road, we reached the entrance to the salt ponds. They are terraced on a hill and were used by the Incas to gather salt from the deposits after evaporation. We walked right down to the area, balancing along the edges and a couple of people also tasted a bit of the salt!

On the way to Maras

On the way to Maras

















Next stop was a set of ruins at Moray. These concentric circles of terraced walls were used for farming and made for great views from the top.




It was noon and we headed out for lunch to a popular buffet place at Urubamba. The spread was huge, with all kinds of meat and Peruvian delicacies. SS tried out some Guinea Pig meat!

We got back to the hotel, packed our bags, checked out and stored our bags at the Peru Rail counter because they did not let us carry more than 5 kgs per person on the train! Quite a silly policy to enforce on tourists but nevertheless, we were okay with it as long as they agreed to keep our extra luggage. Also, they were kind enough to put us on an earlier train which meant we would be able to travel during day time and enjoy the views, and get to Aguas Calientes (A.C.) reasonably early.

Once at A.C., we walked through a market and shopped for some knick-knacks. At one of these shops, when the lady told me that the price of two things I picked up was going to be 25 Soles, I mistakenly asked both for 5 (cinco) in Spanish, where as  I meant 15 (quince)! Major gaffe! She rattled off a few curse words while everyone around burst into laughter. I apologized and finally got the stuff for 20. Phew!

A.C. is bigger than O and unique because it has a river flowing right in the center of the city dividing it into two, with bridges every few metres on its main road! We spotted a bakery and were keen to eat a popular variety of bread, which is what the locals buy a lot during the Christmas season. Next, we bought bus tickets for our ride to the Macchu Pichu site. We also hired a guide for the M.P tour the next morning. We checked into our hotel, and went out for dinner. Most of the streets in A.C. are just steps that go up and down a hill. We took the easy way down, and got into a bar. After sufficiently toxicating ourselves and playing darts and Jenga, we looked for some food. Similar to hawkers in India asking tourists to buy stuff, waiters in Peru restaurants stand outside inviting people, and offering free drinks. TK was accosted by one such guy earlier, so we decided to head there for grub.

Next morning, as usual TK and AK were late. We started calling them the late-latif couple! We met our guide Paul and left the hotel around 6:45 in the morning, and were late for the bus considering we were to assemble at MP for the 7 am hike. Upon arriving at the bus stop we realized that our MP entry tickets were just reservations, and that we needed to get real tickets from the city center!! We scampered and got them and finally boarded the 7:30 bus. The bus ride was through a narrow set of curves up the hill, and getting us almost into the clouds. It was drizzling a bit, and quite serene all around. We got to the MP site around 8:15, and rushed towards the entry. We had planned to hike the Huyana Pichu mountain and were in the 7-8 batch for entry. We just made it to the hike entry gate at 7:55.

Up ahead was a tough, exciting and sometimes nerve-wracking hike. Huyana Pichu is a mountain to the north of the MP site. The trail was made up of stone steps laid out steeply and curving around one side of the mountain with a rope railing on the side at times, and few feet of drop on the other side. To add to it is the constant rain making conditions slippery. Plus the altitude of the place is about 15,000 feet which means oxygen is quite depleted. The key was to hike slowly, take frequent breaks, and just enjoy the views as we climbed upwards. AK was feeling sick because of the altitude, and Paul asked her to pop in a Diamox (medicine for altitude sickness) and a banana, and within a few minutes she was all set. As we reached closer to the top, we had to crawl in through a cave. Time for body contortions! When we did get to the top after about 75 minutes of hiking, the views were spectacular – totally worth the hike! It was like we were in the middle of clouds and as they parted MP made its majestic appearance.

At the top of MP

At the top of MP



Macchu Pichu

Macchu Pichu













We spent a couple of hours at the top admiring the beauty of our surroundings, taking pictures, and  trying not to slip and fall!

Around 11, we decided to climb down. This didn’t turn out to be very easy, especially for me, given that the steps were steep and if you missed one there was a pretty big and hard fall to take! I probably took more time to get down than going up 😉

Paul took us around the MP site, stopping at the important places, explaining how people lived here many centuries ago. We saw the Inca houses, their irrigation system, temples, and understood how they built stuff, their trapezoidal windows, stones cut at specific angles, customs and beliefs. I found it fascinating, while few others felt sleepy ;). Paul also spoke about the various Inca kings who ruled, legends about how MP was “discovered” by Hiram Bingham and how some myths exist about the Incas being involved in human sacrifice. It was like a history lesson, but we were right in the middle of where it all happened, and I was constantly thinking about how it would have been to live there in those times!

We took a break for lunch and went back to explore some more. We took the bus back to A.C and had a train to catch in the evening to Cusco. Paul left soon after and was going to meet us at Cusco the next morning. Remember we had stored our bags at the Peru Rail counter at O, so we had to pick those, and with the train stopping at O for just 3 minutes, we were required to be super fast. As we approached O, we got ready to jump out, and rush to the counter. As we ran, from the corner of my eye I could spot a few bags laid out in a straight line against the wall. Screeeech…! We stopped, and found that the awesome people at Peru Rail had kept our bags outside so that we could just pick them up. So thoughtful of them to do that, and that’s why I nominate them as the best customer service company – EVER! 🙂

We reached Poroy station at night fall, bargained with the cab drivers and reached Cusco city center in a few minutes. The street where the hotel was located was bustling with people – it reminded me of Bangalore’s Brigade Road, with shops on either side, and a sea of people, minus the cars! We checked in, and found out about good places to go get dinner nearby. By this time SS had developed a cold, so a couple of us went to try and buy some medicines. We had fun explaining to the chemist girl what we needed, and ended up enacting a person blowing their nose! 😉 On the way back we passed by several groups of people surrounding tables and seem to be playing a game. We peeked in and saw a gambling frenzy going on with kids, youngsters and elderly all having fun. They were basically playing the Peruvian version of roulette, minus the wheel. People placed bets on images of animals, and based on the cards dealt would either lose everything or multiply what they bet. It was fun to watch! Later we went to a nice restaurant called Tupananchis.

Next day was Cusco city tour. Paul met us at our hotel, and we first visited the Cusco market.


Fruit stalls

Fruit stalls

Chicken Soup

Chicken Soup

Special Bread

Special Bread

All kinds of meat

All kinds of meat


Back at Cusco center, the beautiful cathedral was closed, so we could not go inside. However, there was a local cultural procession going on.



Pachukuti, a famous Inca

Pachukuti, a famous Inca




By this time we were hungry souls but had to walk quite a distance for food, because most restaurants were closed. Paul knew about a local place, so we headed there. On the way, met some llamas too!










We arrived at a restuarant called La Cusquenita. Here, we had some more Pisco sour and other local drinks. The food looked and tasted delicious, and we all over ate. The after effects were to be felt later!

We then took a cab to see Saqsaywaman (saak–saay–waa–mun, not sexy woman ;)). It is a smaller replica of the Christ the Redeemer status in Rio de Janeiro.










And we also got some great views of Cusco from there.


We started heading back to the city center. Paul took us to a chocolate museum, which was interesting. And we said our goodbyes to him. He was very helpful to us on the trip, and made it a lot of fun and informative. A good, English speaking guide is highly recommended!

Next morning we had flights to catch to Sao Paulo. So we had dinner, spent some time at Cusco center which was brilliantly lit for Christmas, and felt a touch sad about leaving Peru – its beautiful locales and extremely friendly people. At the same time excited about visiting a new country – Brazil. That will be the next post.

“Randomly” selected at Logan airport

So I was looking forward to traveling to South America, and was flying off to Miami from Logan Airport, Boston to take a connection to Lima, Peru. The excitement began at the security check itself, really. After I cleared security, I was asked by a TSA officer to step aside as there was an additional step of security that day. I wondered why I was the “chosen” one – it was quite obvious since I was the only south-asian guy in the long queue.

First, another TSA guy frisked me. He explained in detail how he was going to perform the check, and I obliged. After the frisk, he ran his gloves through a detector, which seemed odd. Later I would find out that it was an explosives detector. Wow!

Now it was time for the fun part – questioning! The orignal TSA officer had a side-kick who began searching my carry on back-pack, while the main guy starting asking me questions. Some were normal, some weird, and some outright amusing. Here is how the conversation went:

TSA: How did you get to the airport?

Me: My friend dropped me here.

TSA: Have you had anything to eat?

Me: Yes, I had lunch a couple of hours ago.

TSA: Can I see your documentation?

Me: Yes (I showed him my passport)

TSA: How long did you take to pack your bags?

Me: A little amused, I said a few days.

TSA: So you have been planning this trip to India for a while now?

Me: Again a little amused about his assumption, I said I was  not traveling to India but Peru.

He and his side-kick exchanged glances, and smiled, and acted as if they had never heard of Peru. To keep it light, I continued to say that I was meeting friends there, and we were planning to go to Brazil too.

He smiled, and seemed convinced, but I could sense he was getting a little desperate.


TSA: How do you react to caffeine?

Me: (This cracked me up) I hardly drink any coffee, so I don’t know how I react. But I did have a cup of coffee today.

He mumbled something about he can look at the person, and tell whether they had coffee or not.

TSA: How do feel about flying?

Me: (Now a little irritated) If you are asking me if I’m scared of flying, then I’m not!

He laughed, so did his yes-man side-kick.

TSA: How do you feel about airport security?

Me: I’m okay with it, but this is the first time I’ve been asked to step out. Do whatever you need to do.

TSA: Why are you carrying cash in your bag?

Me: I need the money to convert into local currency once I get to Peru and Brazil. Am I allowed to carry it?

TSA: Oh yes, that’s no problem.

By this time the side-kick had finished removing and checking each item in my carry-on with the explosives detector. So it was time for them to say goodbye. They did seem annoyed that they could not find anything. There was no “thank you” or “sorry for the inconvenience”. And they just walked off teling me that I could go ahead.

I wanted to ask for a feedback form to ask the reason why I was picked, and if there were extra steps for security that day then why wasn’t everyone searched the way I was. But I suppose all that would fall on deaf ears anyway. I was not stopped elsewhere on my journey, so that was good. Turns out its a new ‘behavior detection’ initiative by TSA that borders on racial profiling to justify the program according to this article.

And, I now know how SRK felt! 😉

The Spartan Race Experience

English: Starting Line

English: Starting Line (Photo credit: Wikipedia)

I was bored with my gym routine. It had become monotonous, and I wasn’t enjoying it any more. Enter Spartan Race and CrossFit. My colleague told me about the former; he had come across an ad on Youtube, and in a hurried moment of inspiration, had decided to register for it. I loved it when I heard about it, and registered immediately. Think after you act – that’s what I did. So now it was time to get down to business.

I had always passed by a place called Crossfit down the road where I live, but never found what it was. When I did, it was just what I needed to prepare for the race. So I joined the place within a few days. And was it fun or what?! Also a lot of sweat and pain. I was no longer doing the same routines. Each WOD (workout of the day) improved some part of the body. Every warm up before a WOD was taxing in itself. Overall, great fun! I trained for 3 days every week at CrossFit, and did a 4-5 mile run on most Sundays. I could see improvements in my strength, and I was able to run better, which has always been my weak area. Two weeks before the race, however, I sprained my upper arm while doing a snatch. I rested for a few days, but could not resist the urge to get back. And so I did. Bad decision. The pain got worse, so I took several days off right until the day of the race. On race day, it still felt sore, but I knew that adrenalin would get me through it.

Race Day – We arrived at the Amesbury Sports Park at 7 am. Our heat was to begin at 8. It rained! We expected the terrain to be slippery. First we had to run up a hill for about 100 yards.

Then one by one, these were the obstacles we did:

1. Pits of water – About waist height, jump in, climb out. Slippery, muddy.

2. Over-under-through – Climb over a wall, then under a wall, then through a window in a wall. This was there 2-3 times along the course.

3. Herculean Hoist – Rope attached to a cement block, and going through a pulley at the top of a tree. Pull rope from the ground, and hoist the block until it reaches the pulley and bring it down slowly.

4. Balancing act – Thin logs of wood dug in vertically, and placed in a line. Walk from one to the other. I could not. 30 burpees.

5. Rope climb – Jump into a pit of water. Knotted rope going from ground to a bell about 25 ft in the air. Had the most fun doing this, because I had worked on it during CrossFit.

6. Parallel bar traverse – Series of parallel bars about 7 ft high. Monkey jump using your arms from one to the next. I slipped 2 bars before the end! 30 burpees.

7. Slippery Wall – Walk along narrow steps attached to a wall. Very slippery. Big toes. Fail. 30 burpees.

8. Fire – Jump over a few pieces of wood on fire. Nothing great, just adds to the drama!

9. Rope ladder – Climb up a rope ladder, and get down on the other side. Shaky.

10. Tire flips – Flip over a tractor tire twice forward, twice back. Takes some doing.

11. Cement block drag – Drag the chain attached to a cement block, around a small field.

12. Sandbag carry – 40 lb bag, on shoulder. Walk up the hill we first climbed, and walk down. Takes a lot out of you.

13. Slanted wall climb – Slippery wall at 45 deg. angle, use rope attached from the top to pull yourself. Then climb down from the other side.

14. Vertical wall climbs – There were several of these. 5 ft was a breeze. 6 ft took some effort. 7 ft one had a small step, so it was not so bad either.

15. Barbed wire crawl – Mud  + Water. 2 feet high barbed wire. Crawl, roll,struggle. Then another one, this time sloping! Fun though 🙂

The terrain was mostly slippery, and muddy, with rocks. Overall it was a great experience. Not as tough as I first thought. CrossFit definitely helped. Time to rest and recover my arm back to normal. Until the next one!

Exporting iPhone contacts on Mac

This seemed simple at first but wasn’t very obvious when I tried using iTunes. I had iCloud enabled which meant that I was not able to sync my iPhone contacts with my Mac Address Book. So, I switched off Contacts in the iCloud settings on the phone. Next I connected the iPhone, and via itunes, hit on Sync Contacts. This brought all the contacts into the Address Book.

Next, I exported all the contacts as a vCard file.

Then, logged into Gmail, and selected the ‘Contacts’ section. Used the import feature, supplied the file path, and saw that all contacts appeared.

Since I upgraded to an HTC Titan Windows Mango phone, logging into Gmail on it and syncing, automagically brought in all the contacts from Gmail into the new phone. And I was all set.

Took some time before I could figure all this out. iTunes+iCloud is not very straightforward when it comes to simple things.

Reactive Documents

Recently, I came across Bret Victor who wrote about an idea about Reactive documents – that is web articles that a reader may be able to interact with. An example would be a user being able to change the numbers and analyze an article about environmental effects of coal, if it contains statistics about the number of coal factories, the amount of pollution caused by them etc. One will be able to modify numbers inline in these documents, plot charts and be able to verify assumptions and results mentioned.

It seemed like a great idea to me where a reader is able to check whether the author has really put in the effort to bring in authentic arguments in the article. Basically, it will help the reader understand the material better, and challenge any assumptions made. Also this technology would help benefit students a lot as they usually read statistically oriented articles, and interacting with such stats comprehensively will enhance their understanding of the topic.

He also has written a Javascript library that a user may include on their site, and allow readers use the ideas mentioned above.

For more details, visit his project called Ten Brighter Ideas.

Innovation or Imitation

I have always thought that the Indian software industry must become more product-oriented rather than service, as going forward making stuff is going to help us stand on our own feet. Majority of our firms today do maintenance of products that have been created elsewhere and need looking-after for customers. I came across as article that talked about Indian entrepreneurs who have jumped into the product bandwagon and it seemed encouraging. The article Indian Product Entrepreneurs: Your Time Has Come mentions some products like Zoho that seem to be counterparts to products already present in the market, but are much cheaper. So it looks like people have made their own versions of existing products, with a few improvements and are able to sell them at lower prices largely because the development cost is lower in India. Some would say we are just ripping off existing products, but that argument might not hold good if we make those systems better, for example Facebook came after Orkut and MySpace but it was way better, thus it caught on. Having said that, more importantly we need to build things that are really innovative going forward, now that we have experienced professionals in our ranks too. We must use the price advantage, no doubt, but also think long term to create something disruptive.

Rails and Postgresql on Mac Snow Leopard, Heroku

I was looking to use Sphinx which is a search plugin for Rails but requires Postgresql as the database containing the data to search. Since I have been using Sqlite3 on my development setup, this meant making a shift into the Postgres world. Installing it was pretty straightforward on the Mac.

1. Install Mac ports. This utility is similar to ‘apt’ on Debian or ‘yum’ on RedHat. After installing, run ‘which port’ to see that it was successful.

$ which port

2. Using Mac ports, install postgresql 8.4 using the following:

sudo port install postgresql84 postgresql84-server

3. Make a location for a default database

$ sudo mkdir -p /opt/local/var/db/postgresql84/defaultdb

4. Make its owner as user ‘postgres’

$ sudo chown postgres:postgres /opt/local/var/db/postgresql84/defaultdb

5. Run ‘initdb’ to initialize it once

$ sudo su postgres -c '/opt/local/lib/postgresql84/bin/initdb -D \

6. To make it run always, enter

sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql84-server.plist

7. Start the db server using:

sudo launchctl start org.macports.postgresql84-server

8. Create a user called ‘postgres’ using your system admin username:

createuser --superuser <admin_username> -U postgres

9. Now try creating and removing a db to test if everything worked:

createdb temp
psql temp - this should take you into a db sql prompt
dropdb temp

10. Now install the ‘pg’ gem which acts as an adapter between your Rails app and the postgres db. The best way to install is to include it in your Rails app’s Gemfile and run ‘bundle install’.

11. Next, create a new app temporarily in order to know the format of your new database.yml file for the postgresql db that will be created.

rails new temp_app -d postgresql

Open and view the ‘config/database.yml’ file. Take a back up of your sqlite3 database.yml and copy this newly created file to your Rails app into ‘config/’. Change the username and database names accordingly as it would be set to ‘temp_app’ and ‘temp_app_development’. Other values can stay the same.

12. Create the database with the name you set in the above database.yml file

createdb myapp_development

13. Now run ‘rake db:migrate’ to create the tables according to the schema.rb file. This will create the same tables as your sqlite3 database in the new postgres database.

14. If your sqlite3 db has data, get its dump using:

sqlite3 db/development.sqlite3 .dump > sqlite3-db.dump

15. I read somewhere that one should be able to import this dump into the postgres database but that did not work for me. A simple script should be able to run the ‘INSERT’ commands listed in the dump file into your new postgres db (psql into the db, run INSERT commands). Make sure that you use single quotes around any numbers that are present in the sqlite3 dump data, such as IDs. You might also have to make sure your IDs are unique.

16. Restart your app and now your new data should be getting inserted into the Postgres database.

17. If you use Heroku, then push in all the changes to the files. Then, run the following:

:myapp$ heroku rake db:migrate

Install the gem ‘taps’ that will allow pushing your local data to the Heroku server (which will now also use Postgresql!)

:myapp$ heroku db:push


PS: If you see a segmentation fault issue upon access to the Postgres database, then set the following env. variable:

export RUBYOPT='-r openssl'