Tuesday, December 9, 2008

Debugging Vs Unit Testing

We developers need to win this battle. Ofcource I am on the Unit Testing side and thatz the reason for this battle. We want to improve. We want to stop debugging, or we may call it post coding or post delivery nightmare.

  • How may of us are fond of SOPs? [System.out.println]
  • How many of us are good a putting / reading log files?
  • How many of us are good at using the debugger? Looking up the values inside objects at runtime?

We all are. Because thatz what we do most often. The percentage of time we
spend on debugging is far more than coding.

Every programmer knows they should write tests for their code. Few do. The universal response to "Why not?" is "I'm in too much of a hurry." This quickly becomes a vicious cycle- the more pressure you feel, the fewer tests you write. The fewer tests you write, the less productive you are and the less stable you code becomes. The less productive and accurate you are, the more pressure you feel.

  • Programmers burn out from just such cycles. Breaking out requires an outside influence.
  • The best way to convince you of the value of writing your own tests would be to sit down with you and do a bit of development.
  • Along the way, we would encounter new bugs, catch them with tests, fix them, have them come back, fix them again, and so on.

Wednesday, December 3, 2008

Do we have enough time for testing?

Thatz the first question I hear while talking to a developer who is not writing tests for his/her code.
"Delivering Code Without Tests Is A Sin"
This is a punch line by Bob-Martin, I heard in one of his sessions I attended. We already are wasting/investing huge amount of time in injecting bad design and bugs into our applications. So I want to ask this question again -
Do we have enough time for testing?
My question to this question is - Do we have anything to lose?

Lets start writing tests...

Tuesday, December 2, 2008

Post Horrible Mumbai terror attack 26/11..

Lots of aggression all around.. questions.. blames.. resignations..
Some groups, citizen showing a high sense of responsibility.. of worrying about the state of country and people..
Some very irresponsible.. thick skinned..
Everyone around me.. at my work, my friends, my family.. express frustration in various ways about such barbaric terror acts..
I've been thinking around all these thoughts, information revealed.. discussions..
I am a lazy person.. And I know this very well, I publicly accept this. This actually is very helpful in always being aware of this negative quality of mine. As it helps me remain alert at many times. But generally I am lazy about many things..
- my health,
- my plans towards my career,
- maintaining documents,
- filing my tax returns,
- playing with my kid,
- calling my friends,
- wishing my friends happy birthday,
The list goes on..
But still I am leading a very responsible and efficient daily life. I continue taking care of my health, my family, my social responsibilities, my career, my documents... list goes on.
I am part of Cycle Of Life. The way I understand it is, there is a threshold, for every negligence, every ignorance, every selfish act, every uncaring attitude. As soon as the threshold is reached, the alarm goes ringing. I dont really care at the first alarm. But there are series of alarms well set, which keep going on with increasing threshold values. And a time comes when a blast is triggered. The blast is very harmful all the time. I have to pay heavy penalty to my bank for not taking care of my documents, I catch cold/fewer for neglecting my health, my kid starts becomming cranky and unstoppable because I am not paying attention to him...
After the first instance of each blast I start taking care to avoid it to repeat.

Our society behaves in exactly the same way. People all around the world become selfish, irresponsible, careless. If they do not listen to warning alarms they suffer thru the blasts. In the news / papers, I can read a lot about various agencies across different countries showing irresponsible behaviour in executing there duties. Of-course they are all headed by human beings who commit mistakes.

If we see the current scenario around the world, the number of alarm blasts is very high.
- multiple economies going down
- financial crisis
- terrorist activities
- etc...
This will cause damage at various levels. And bring the world below the threshold level of alarms.

I believe, the divine power can help us at the micro-est level to take care of preventing us from doing any negative act.
I wish we sahajayogis are able to convey the vision of Sahajayoga to the world.
Sahajayoga principles are the only way we can always remain below the threshold and keep growing continuously in positive direction.

By Sahayoga principles I mean -
- How can I avoid lying?
- How can I get more strength to forgive?
- How can I only love and never hate?

A beautiful world visioned by Shri Mataji Nirmala Devi. You'll see this coming true if you meet with a group of Sahajayogis.

Sunday, November 30, 2008

Plan Of Action - TDD

  • Install the measurement tools, like emma, clover, Cobertura, CodeCover
  • Learn/understand the project code. Each project may have unique requirements in terms of writing unit tests, like struts, database, containers API, any other API.
  • Use FindBug & CheckStyle reports to improve the quality of code.
  • Build the initial required framework for writing unit tests, for the ease of rest of team.
  • Move from [Code - Test - Debug] => [Test - Code - Refactor] Mode
  • Achieve the state of -- Writing a new test should not introduce more overhead than the test itself.

Writing a test makes you ask a lot of questions related to the requirements as well as implementation, which eventually is very helpful to filter out any bugs which may be introduced in the appications otherwise.

What I want to do?

This is a letter I wrote to the management I work for -

Fortunately I got opportunities to work with & learn from industry experts like Bob Martin, Michael Feathers and Brian Marrick during my tenure in US. All of them and all the software industry experts strongly recommend test driven development as a key approach to improve software deliverables and creating very efficient and highly maintainable software.

We, in our projects, even today try to promote test driven development by writing test cases for the deliverables before we start any development. But unfortunately we write tests in XL sheets and Word documents or even worst we don’t write them at all. Having tests written in documents makes them dead and they eventually get buried in some central document repository. That’s where the dead things go. It is nothing better than not having it.

Due to these reasons the industry experts strongly recommend executable unit tests which can be run in an automated fashion. It requires a great mindset change to start writing tests before the code. We may not see clear benefits until we have at least 30% of code coverage. But still I think we have nothing to lose, as we are already in such a bad shape with the kind of software we build.

So my question to the group is -- should we allow someone to completely dedicatedly focus on this problem?

Now Bob Martin, Michael Feathers and Brian Marrick are not going to come and write code for us. We ourselves have to do it. Fortunately I got opportunities to work with & learn from Bob Martin, Michael Feathers and Brian Marrick during my tenure in US. I can at least talk about, write and demonstrate the importance of Unit testing, what I have learnt from them and then also experienced it myself.

I request the group to give me an opportunity to work for this initiative.

Thank you for reading till this point, a few more points ahead…

What I want to do?
· Be a Unit & Automated Testing Champion
· Spread best practices across projects in ODC
· Work with different team on improving development practices
· Take sessions on TDD, Automated Testing, Checklists, FindBugs, CheckStyle, CI, Emma, Design Patterns, Java, Struts, Hibernate, Spring
· Increase test coverage of each project that I work on.
· Keep continuous track of latest technologies
· Publish ideas in forums like Arch CoE, Wiki
· Contribute to various groups, open source.

My Quantifiable Goals [in 3 months]:
· Increase test coverage of 2 projects by/to 50%
· Conduct at least 5 sessions on software development best practices
· Initiate 5 techies to participate in knowledge sharing
· Share the achievements/learning once a week in Architecture CoE

What am I doing right now?
· Deployments, PRD & QA. Thankfully we have automated deployments for INT.
· Resolve technical queries of team.
· Complete Stories & bug fixes.
· Lots of Coordination activities, part of leading the team.
· Perform all the thankless activities of a Tech-lead.
· Use TDD for whatever I code and spread the word in team.
· Talk about Testing practices informally whenever I get a chance.
· Work with some proactive people to help them with any doubts related to testing practices.
· A few PL related activities like appraisals.
· I have also been told that I am a scrum master for CTB team.

Thank you for reading this, please send your comments.

Sunday, November 23, 2008

Used Car Buying Tips - India :)

Questions to ask --
-Mumbai reg?
-Reason for selling?
-First owner?
-How old is Battery?
-Tyres/Stepny - Have they been changed / or are they original?
-Leaks - check the tyre rims, showing any leakage signs?
-Serviced on time? Have Records?
-Music System? Audio CD player /USB
-Kilometers run?
-Who drives it?
-Price negotiable?
-Suspension - Press / push the car down with your hands and try to shake it a bit. If the suspensions are good it will move the least. You may also use this to validate the meter reading. If the suspension are good then low meter reading is valid.

TDD Articles




Saturday, April 26, 2008

Who is a Sahajayogi?

One -
1. Who loves truth.
2. Evaluates all his/her actions based on truth.
3. Is able to maintain balance every moment and is trying to think of ways to achieve it.
4. Has 0% ego.
5. Believes in giving.
6. Accepts the fact that one needs to exhale whatever he/she inhales.
7. Has won over anger.
8. Is forgiving.
9. Is able to take care of his/her health.

As per my personal experience & understanding, all the above seem very idealistic and unachievable qualities for a human being leading a normal life. But the only hope is as explained by SahajaYoga -- Be Connected To Divine. How? Only through meditation.

Only meditation gives the opportunity to calm the mind and get connected to divine power. And only with this power one can achieve balance. Balance is the key. Excitement and depression are the two extreme sides of balance. The most difficult thing to decide is what exactly is the center line of balance? You can understand it only in a state of meditation. Which comes by practice.

Just try not to lie to yourself each day and each minute and you can attain the state of meditation. And you'll get the strength for this by meditation. Both of these ideas go hand in hand and help each other.

IBN 7 & CNN-IBN salute the 'real heroes' of our nation


A precious gift on my marriage

Following poem written by my Babaji(Grandpa) :

मन में,तन में, जीवन में वसंत है छाया
यह वासंती मौसम, उस पर ठंड गुलाबी,
बहका मन ज्यों बिना पिए ही हुआ शराबी
वेद ऋचाओं को दोहरातें रहें भले ही,
उनसे मिल पता है केवल ज्ञान किताबी
उनकी पावनता का हो जीवन में अनुभव,
यही सोच कर ऋजु - ऋचा परिणय करवाया
जीवन में वसंत है छाया

कुछ निर्वाह करें कुछ बदलें रिवाज अब,
ऐसा सफल प्रयास किया संभव
उत्सव में दिन की शादी बिना चढ़त के बिना बैंड के,
दिखलाया ऐसा अभिनव करतब उत्सव में
जैन और कंसल परिवारों की सहमति से,
नई प्रथाओं का था सूत्रपात करवाया
जीवन में वसंत है छाया

नौ फरवरी नवल इतिहास बनाती आई,
सबके मन में नव उल्लास जगाती आइ
जिस दिन 'आभा' ने थी जयमाला पहनाई,
ठीक उसी दिन बजी 'ऋचा' द्वार शहनाई
हो 'विनोद' या 'ऋजु' बने दोनों ही वर,
सास बहू ने परिणय उत्सव साथ मनाया
यह अपूर्व संयोग देख मन हरषाया,

धीर और गंभीर पिता जैसा स्वभाव पा,
ऋजु ने जीवन जीना मां से ही था
शिक्षित और सुंसंस्कृत सहधर्मिणी मिली है,
कार्य क्षेत्र नवयुग प्रतीक मुम्बई सरीखा
तीन महानगरों का मिलन त्रिकोण बनाकर,
दो धर्मों ने है अंतर्संबंध बनाया, देख कर मन हरषाया
परम्पराओं की धरती पर पाँव टिका कर,
ऋजु सफलता का आकाश तुम्हे छूना है
ऋचा प्रेरणा पा उन्नति के शिखर छुओ तुम,
जीवन पथ पर गति उत्साह हुआ दूना है
रहे हाथ में हाथ, न ही घर में बाहर भी,
कहें सभी जीवन तुमने आदर्श बनाया
जीवन में वसंत है छाया

- आर्याभुषण गर्ग

Wednesday, April 23, 2008

Strength of Gandhiji's ideas

I recently learnt or understood, why Gandhiji's ideas became successful and helped us acheive freedom. People say that there were many other revolutionists who deserve the credit. But what I have learnt is, historically it is proven that things happening in large numbers are more visible and have larger impact.

This is the basic idea I believe behind Gandhiji's movement. He thought of common man. What can be possible for every person easily. What is relatively easy to trigger inside a common man who doesnt know anything about Gun or Bullets? It was easy to make them realize the power of truth. The power of masses. The power of unity. Just by burning clothes. Making Salt. The people came together. And the British got afraid.

So the idea is what is easy for masses to understand?
Is there a way people of India realize the importance of education?
Is there a way that everybody thinks it is the most important thing?

Education is most important

Indian industry is autonomous. In competing for customers it has been expanding supply at breakneck speed. In March, India achieved a miraculous 300 million mobile phone customers in a country of 200 million households. Before liberalization, we had five million phones in 1990. No one talks about quotas for telephones any more because the market has raised both supply and quality. The same thing could happen to education. Prosperity doesn't trickle down; it goes down like a flood.

An extract from following article: