Search

Sunday, December 9, 2012

Global Day of Code Retreat 8th Dec - 2012

The Global Day of Code Retreat - Mumbai on  Saturday, 8th Dec, 2012. Agile India Global day of Code Retreat. The event was organized by ASCI and facilitated by Dhaval Dalal (@softwareartisan).

Agile Software Community of India
This was truly global event where 3200 developers from entire world met at 150 different locations for the entire day making this event successful.

The agenda for the entire day was simple. We divide entire day in multiple 45 minutes coding sessions. We have been given a problem (Snakes And Ladders) in the form of set of "problem statements" and we need to develop the same. This looks simple enough right ? The answer is NO. We need to develop the code using Test Driven Development (TDD)  and with pair (Pair programming).

In Pair programming, two persons tries to solve the given problem together. One person is coding the solution(called driver) and another person (called navigator) is constantly monitoring him and the code he is writing. This would become interesting because there are two minds approaching to solve single problem. There are many cases where you make obvious mistakes whether its syntactical or logical. You only come to know them once you compile and actually run the code. The navigator always thinks about the code simultaneously with driver so possibility of bugs reduces a lot.

After 45 minutes there would be a timer bell which will ring. Every pair has to get up at that time and come to a close circle for analyzing what they have done in last 45 minutes.

1) Explain their design approach and they started from which problem statement ?
2) What they did really good ?
3) What they think they should improve on ?

Different pair can start solving the problem with different problem statement. The goal at the end of 45 minutes is not to complete the problem but to analyze what they have achieved in that time and how to improve their skills.

Interesting thing for every new session is that after every 45 minutes you have to DELETE your code. Yes you are not allowed to keep continuing from any of the part you have designed in earlier session. Also you have to switch the pairs. You will start again afresh with a new pair. And guess what, every new time you will be treated with a new set of constraints which you have to keep in mind while coding.

Some of the constraints are as follows:

  • No Getters / Setters
  • No Primitive Datatypes
  • No more than 4 lines of code per method.
  • Only constant variables and methods in the classes we design. (No mutable objects)
  • Only const parameters to be passed.
  • No addition of a new class unless you require it.
These constraints made all of us think a lot. Every time there is a new constraint imposed.. We have to re-think the solution entirely different way. This helps us lot about many such issues which are present in our production code but we never really think they even exists.

There are many good approaches came out by different pairs to solve the same problem. Some of them include:
  • Combining snake and ladder in a generalized class which just specifies (start point, end point) pair. and reduce maintenance of one extra data-structure.
  • Using event driven mechanism where if any player reaches any snake or ladder, an event will be raised to change the position of the player. This will help reducing the number of checks to be made for every move.
  • By imposing only const data members we came up with a design for changing the entire "world" (Game class) for every state change. Going towards truly functional programming.

This made us realize that how much our code "Sucks" and how much we still have to improve on. If we start applying various constraints like this to our actual code, the output would be fully tested code which is of very high quality. We never over-engineer anything unless its needed. In our design we never created "Board" class which would have been the very first class which will come to our mind while designing the game.

Also at the end we discussed practical usage of TDD. Most of us are working on so called "Legacy code" and only very few will have luxury to start a project from scratch. How do we use the TDD to our advantage on this kind of scenario. In most cases we should start with functional tests and behavioral tests of our code and then later to go deeper to have unit tests like this.

We had lot of fun during the entire day.. I am sure that everybody who attended this sessions worldwide would have enjoyed it.

Saturday, February 13, 2010

Werewolf Game

Few days back one of my colleague had came up with Werewolf Game commonly known as Mafia Game. We were around 6-8 of us on the very first day of the game. As described in Wiki its a Game of Werewolf versus Villager.

In a particular game we have few people as Villager and few people as Werewolf. There is one Sheriff and The Narrator (We call him God).

There are two phases of the game (Day & Night).

* In Night time all the werewolf wake up and pick a victim from all the villagers. God takes note of the same.

* In the Day time god wakes up everybody. He informs all the participants about who got killed. Now all the villagers and werewolfs (villagers does not know who all are the werewolfs) chooses a person (who is the most prominent candidate for being a werewolf) and Hangs Him out. In this process they may end up killing an innocent Villager (We call him POV - plain old villager. a term derived from POJO - plain old java object).

The interesting part of the game is at any point of time people can bluff / lie whatever they want. The person who has the most convincing power can direct the game to winning of their appropriate team.

At the end of the game, the team in which the last survivor of the game belongs to, wins.

The game becomes more interesting when we introduce various other personalities into picture. There are few other personalities which may or may not be present in the game. Their roles are described below:

Sheriff is the person in the village who holds two voting powers. His power is inversely proportional to the number of people in the game. The end of the game is generally decided by sheriff. When any sheriff dies he hands over his power to any person in the village.

Special personalities at villagers side.

Cobbler is the person who wins alone if he is hung on the very first Day.

Goth Girl is the person who is a villager but he wants/helps werewolfs to win.

Infected is the person, if beaten by werewolfs, does not die but become a werewolf starting from following night.

Sick Villager is the person, if he is killed by werewolfs at night, they cannot kill anybody in the following night.

Seer is the person who wakes up at a separate time in the night and can ask God to reveal any person's identity.

Bodyguard is the person who wakes up at a separate time in the night. He can protect a person. The person will not be killed by Werewolfs in that night. Bodyguard cannot protect same person in two consecutive nights. Bodyguard cannot protect himself.

Magician is the person who wakes up at a separate time in the night. God asks him about weather he want to save the person who is going to be dead in that night. (killed by werewolfs). if not.. he can pick a random person and kill him. He can use his power only once in a lifetime.

Special personalities at werewolf side.

Werecub is the person who is a normal werewolf but if he is hanged by people, werewolf can kill two villagers in the following night.

Lone-Wolf is the person who wins the game if he is the last survivor of the game. He will be seen as villager by the Seer.


Generally in the game number of werewolfs are less compared to number of villagers. This game requires mastery in bluffing and convincing people. We played few games, every time there is a new challenge coming against us. Playing the game being a werewolf is totally different compared to being a villager. Holding special powers and using them to help respective team members to win is really a challenging task.

We started from 6 people, now we are around 20+ people. This itself shows the popularity of the game. A particular game lasts around 30-40 mins. The time also depends on the number of powerful people who can bluff/throw arguments.

P.S. Some more useful links about understanding how Werewolf works.

http://www.eblong.com/zarf/werewolf.html

Indian Derby 2010

Every year, first Sunday of February is the "Derby Day".

On 4th February, 2010 there was "Derby 2010" at Mahalaxmi race course, Mumbai. I had decided to visit the same.



I heard a lot about various events happening at race course. I wanted to learn about various betting types and how it works. I heard that millions of ruppes are bet on various horses. Derby was the biggest event in the Indian race course.

There were 10 races on the Derby-day starting from 12:30 p.m. The races were of different distance starting from 1000 meters to 2400 meters. The race gets completed in around 1-3 minutes, after completion of each race the winner of the race gets trophy/winning prize. The 9th race at 5:15 p.m. was the "McDowell Signature India Derby". The winning horse of the derby this year won sum of Rs. 2.25 Crore (Rs. 22.5 Million). This is the biggest ever winning prize for any game in India.

I was excited about learning how the betting works at Derby. I reached there around 1:30 p.m. I decided to observe the next few matches and get some idea about betting types and strategies.

I got a book called "Race-Card TURF" which contains all the details about various races, the horses participating in each of them, the favorite horses etc. I found out information about various different types of betting including "WIN", "PLACE", "TANALA" etc. "WIN" and "PLACE" These are the simplest types of betting. I decided to try my luck on the horses (just for fun). One can bet on various horses starting from Rs. 10.

I have started with "PLACE" and "WIN" bet on the favorite horses. In some of the games it worked for me. I won a few bets. Though at the end it was "no win no loss" situation. It was a great fun betting on various horses and earning/losing money on them. People are betting crazy amount of money on various horses.


Apart from races there are various other events like dance performance, magic shows, tarot card readings, etc. for entertainment. In total it was fun enjoying various races and other events at Mahalaxmi Race Course. Looking forward to visit the same next year.

Thursday, January 28, 2010

Laser Graffiti @ directiplex

After a long break again I am back to blogging. Yesterday evening it was a great event @ my workplace "Directiplex". We had a live show of "Laser Graffiti". We all were very excited about this event.

Here is our CEO Bhavin's post.

It started around 11:15 pm. We were standing at road-side, the projection was on one of the wall of Directiplex. Initially the projection was not very clear. We can feel the lag of around half a second in the projection. Soon this was been fixed and we were able to see various drawings clearly.

Initially we started with some of the chinese characters (representing "welcome to Directiplex", blah, blah, hehe). We tried writing "Directi", "Bhavin" and other texts, though the text were not clearly visible. Then we started drawing various things like a small house, a tree, flowers, swastik, packman, cat-woman, duck aka dinosaur, clouds and couple of other drawings. I had also a chance to show my excellence in drawing. ;) I have done couple of drawings which includes a rose, a boat, a kite, a firki (manja) etc. Soon will post photos/videos of the event.

It was fun drawing on the building wall as compared to drawing on a white sheet.

Saturday, November 28, 2009

tribute to 26/11 heros and victims

Same time, around a year back we all were shocked by the terrorist attack and praying god for helping the hostages. There were many people like me who are just fortunate enough to leave the place. see here.

On the first annivarsary I pay tribute to all the heros and victims of 26/11.

Spreading violence has not broken peace in the country but it has brought people of India more closer. We Indians are united. There is no country in the world where people follow as many religions as compared to India. We speak more than 18 different languages in 35(28 + 7) different States and Union Territories. We are proud to be Indians.

"Jai Hind !!"

Monday, August 31, 2009

Micchami Dukkadam !!

Knowingly or unknowingly, by action or by speech, by words or by deeds, If I have ever hurt you then please accept my apologies.

This is our eight days religious festival "Paryushana". The heart of the festival is "Kshamapana"(forgiveness). We believe that a person is courageous if he is able to ask forgiveness for his deeds which might have hurt-ed others and the real great people are the one who forgives others.

The heart of "Jainism" lies in two things. one is "Kshamapana" (forgiveness) and second is "Jiv-daya". Jainism believes that all things in universe has spirits. One should act in a way that honors them all to the best of one's ability.

Tuesday, July 14, 2009

First day driving my car !!

It’s been around 4 weeks; I was driving the Driving Institute’s car. In this car I had a tutor sitting next to me and having control over the “clutch” and “break”. The tutor can control the car if I drive improperly. I cleared driving test at Vadala RTO and got the license last week.



Last Sunday, I got a chance to drive my own car. This was first time when I was sitting in the driving seat and had full control over the car. I asked my tutor to come with me as I didn’t want to take risk of damaging my car. I drove for around an hour. There were some basic mistakes which he pointed which I need to improve on. Some of them are taking care of people walking on the road, (In India, Mumbai, This is pretty common.), the vehicles overtaking and the signals. I do have judgment about most of them but having a small mistake will lead to an accident. All these will definitely come through more and more driving.

In the afternoon I went for another drive with my friends Punit and Rishin. I drove till Bandra. The roads in BKC are really good. I drove with maximum speed of around 80 KMPH. Punit’s driving is also good; he was my tutor for the whole ride though he was slightly scared.
In total my first driving experience was adventurous. I got to learn lots of minor things, avoiding them, may cause major damages. The understanding of all these will only be possible through experience.