The most successful people in any walks of lives may not be the most talented ones but are definately the most passionate & dedicated ones.

Tuesday, May 29, 2012



Life at a swirl – from Noida to KalaAmb via Jamshedpur
(next is what ?)

A lazy looking guy (presumably boring) with substantial mass J, one who thinks a lot, loves to sleep, hates to share his food ‘n’ wine, on the verge of tying knot embarked on a journey around a year ago a which doesn’t seem to end.
Those who were out of touch and who didn’t got till know that who this person is (errr…) , that’s me.
As I logged-out of CSC in search of a lot of things (not to forgot the night-out with my Juniors), it wasn’t all that easy and frankly speaking, to my discomfort it was hell difficult.
The first month at XL was insanely jam-packed. If my memory doesn’t ditches me, some of us were shown the door by a Prof (see I remmeber the name but not writing it deliberatly J) in the three day orientation program itself without actually being at fault. And my sleeping pattern started right from the orientation program from the seemingly never-ending Economics lecture.
Though I am kindaa reserve type of person but somehow I feel that I am able to think independently and figure out things in my own way. And I didn’t dissappoint myself in that and soon after term-I and I was able to figure out how to tackle the barmy acedemic schedule at XL. At this point, I could recollect feedback from one of my best buddies – RV, when he mentioned that “no course is his favouriate, he hates all courses equally”.
International immersion was amongst the most memorable part of this journey which gave me an opportunity to step into foreign soil.
After a few of missed chances, I landed up into a job which I possibily I had never thought off. Decent money, a nearby location but still I kinda feel that I could have done better and rather I feel that I deserved better. At present, I am at a nice place (what the heck; this place sucks.. mountains, fresh air and a long walk ‘n’ that’s all L ) though not sure for how long I would be here though.
As I am on the verge of loosing but “single” status, I feel anxious, stressed, sometimes excited and I hope the new innings would be a special one.
Wish me good luck and god bless everyone!!!

Sunday, November 27, 2011

FDI in retail at this juncture -- complementary measures



The government's decision to allow foreign direct investment in the business of retail distribution of produce is welcome. Right now, it remains a token of the government's ability to make a rational choice defying Opposition clamour.

This is, indeed, valuable.


However, for the proposed liberalisation to have any impact on the ground, this needs to be seen.


Organised retail will precipitate a whole lot of manufacturing FDI by small labels, who can produce quality stuff but lack the financial muscle to build a distribution network on their own. These, too, will produce additional jobs, incomes and consumer choice. Some small shops will be displaced in the bigger towns, but new organised jobs will be created. The overall social gains far outweigh the costs.


The move is emphatically welcome.


Cheers !!!

And the journey called life continues…


Just when one feel that it can’t get better than this, at that very point god reminds us that he’s the supreme power with stamped authority and one needs to accept it rather than pondering over it.

Today I feel that I too learnt the similar lesson but then as one grows old [‘n’ hopefully wise :P too], I have the courage to accept it with a smile beneath which lies a big heart to reinforce
it.

Assimilate it, feel it ‘n’ move on is the name of the game in contemporary times.

And yeah its kindaa difficult but then when one’s mind decides to do something, half of the battle is already won & as I learnt from my father, its never too late to make a start and put in your best effort and I am up for it man.

Well if the above stuff is too much of an abstraction to you, I would say that I have deliberately kept it that way [without the background context] to keep certain feelings in check. If you didn’t understand every bit of it, let me affirm that the onus lied on me & not always “human beings” live up to expectations.


Keep exploring your potential.


Cheers !!!

Saturday, June 18, 2011

Expecting the unexpected

"I started to scale the cliff,
Without my usual harness,
Using only my hands and feet,
I climbed up and into darkness.

Scrabbling for a crack,
Or a foothold to stop and rest,
I dug my nails into the rock,
Heart hammering in my chest.

It was as if the rock gave way,
Dismayed I found twas true,
For as my feet began falling,
The rest of my body did too.

Grabbing for the safety line,
I knew instinctively wasn't there,
I plummeted at a sickening rate,
Through the rushing air.

My head hit the ground,
With a resounding crack,
I found that I was lying dazed,
............................................. "


Cheers to the uncertainity of life !!!

Tuesday, May 31, 2011

Taking Right Decisions @ The Right Time… My Experiences



The only way to have a life is to commit to it like crazy!!!


Most of the times life moves at a brisk pace ‘n’ at the blink of the eye, each moment passes by. So it’s imperative for us to take some time out and look at the events in our lives that changed the course or have the potential of changing the course of our lives.


Since I am no exception of this phenomenon [yeps this is a deliberate choice of word], I too have taken decisions and have missed out on some or the others ‘n’ hence the aim of this write-up is to sum up those decisions and to keep a track that at which point the circle-of-life approximately is. [Again ‘approximately’ is a deliberate choice of word since if one knows the exact precision of the circle-of-life, the flavor of uncertainty from lives goes missingJ]


Always remember that life is full of choices but the important thing is to make the right choice at the right time.


Broadly I feel that we can classify decisions into two categories viz. conscious and un-conscious decisions


Decision not taken by myself...

Unconscious decisions -- Sadly not many of my decisions a conscious no and that’s how I learnt the harder way that whenever possible make the decisions even if the result is in future because a reviewed decision is always better than the one reached at the last moment.


When I look back at the last 10 years of my life, I reminisce the following checkpoints viz. trying for the SSB Interview at AFSB Dehradoon, joining engineering course, joining Satyam. The common pattern in all of these unconscious one’s were passion, lack of ground work / knowledge, lack of appropriate amount of openness to discuss things and to an extent lack of alternative choices.


An unsolicited suggestion to those “alike me” is that one need to be open to discuss things with peers, seniors ‘n’ even juniors and if you get this thing right, other will follow for sure.

These unconscious decisions also made me realize that raw talent can carry you forward to an extent or at max gets you one chance but beyond that it’s all about focus, determination and hard work.


Decision taken by myself...

Conscious decisions – By the end of 2008 for me [‘n’ others as well], I realized that “we always have a choice: to plow new ground or let the weeds grow.” This got reflected in some of my decisions viz. joining CSC, to renaissance my post graduation aspirations and a few personal decisions.


The common pattern [in java, we term it as ‘design pattern’ and a manager would want to term it as correlationJ] is that there were some sort of planning ‘n’ informed decisions which were missing earlier all the way.


This also made me realize that careful planning coupled with passion, hard work and quest for learning not only makes one realize their potential professionally life but enriches personal life as well.


Another good thing that I realized is the power of reading. I felt some kindaa change in myself while reading good quality stuff which contributed to understanding of one’s own strength ‘n’ keeps you focused ‘n’ motivated and working northwards towards the goal.


I think the time doesn’t permit me to write further so I will wrap-it-up by mentioning a few lines….


In masks outrageous and austere, The years go by in single file;
But none has merited my fear, And none has quite escaped my smile.


Cheers to life !!!

Tuesday, March 22, 2011

Emotions

I think this is the word that seperates animals from human beings ,Morever the ability to express emotions which makes us civilized and at times uncivilized too!!!
So I think, albeit we come across frequently, it is worth to know our emotions. Researchers on emotions mostly agree on the existence of two types of human emotions:

1) Primary emotions
2) Secondary emotions

A primary human emotion types are the one triggered in response to an event, for example: Anger.

A Secondary human emotions types are the group of emotions that follow that types of emotions . If we experience fear , the secondary emotions would be : feel threatened or feel anger, depending on the situation we are experiencing.


Here is a list of positive [in general] human emotions:-
Love , Appreciation , Happiness , Hope , Enthusiasm , Vitality , Confidence , Gratitude , Patient , Trust , Vulnerable , Optimistic , Appreciative , Ashamed , Astonished

Here is a list of negative [in general] human emotions:-
Fear , Anger , Guilt , Depression , Pride , Jealousy , Self-pity , Anxiety , Resentment , Envy , Frustration , Shame , Denial , Offended , Negative , Regret , Resentful , Sad , Worried , Grief

Final thoughts...
Always remember that there are so many types of emotions out there. A life filled with emotions is a rich life.

Now go out there and enjoy every experience you have.


Cheers !!!

Tuesday, March 15, 2011

Why to override HashCode and equals methods in java usually together?

The Java super class java.lang.Object has two very important methods defined in it. They are -

public boolean equals(Object obj)
public int hashCode()

public boolean equals(Object obj)

This method checks if some other object passed to it as an argument is equal to the object on which this method is invoked. The default implementation of this method in Object class simply checks if two object references x and y refer to the same object. i.e. It checks if x == y. This particular comparison is also known as "shallow comparison". However, the classes providing their own implementations of the equals method are supposed to perform a "deep comparison"; by actually comparing the relevant data members. Since Object class has no data members that define its state, it simply performs shallow comparison.

The equals method implements an equivalence relation:
  • It is reflexive: for any reference value x, x.equals(x) should return true.
  • It is symmetric: for any reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the object is modified.
  • For any non-null reference value x, x.equals(null) should return false.

The meaning of each of the above statement is elaborated below:-
  1. Reflexive - It simply means that the object must be equal to itself, which it would be at any given instance; unless you intentionally override the equals method to behave otherwise.
  2. Symmetric - It means that if object of one class is equal to another class object, the other class object must be equal to this class object. In other words, one object can not unilaterally decide whether it is equal to another object; two objects, and consequently the classes to which they belong, must bilaterally decide if they are equal or not. They BOTH must agree.
    Hence, it is improper and incorrect to have your own class with equals method that has comparison with an object of java.lang.String class, or with any other built-in Java class for that matter. It is very important to understand this requirement properly, because it is quite likely that a naive implementation of equals method may violate this requirement which would result in undesired consequences.
  3. Transitive - It means that if the first object is equal to the second object and the second object is equal to the third object; then the first object is equal to the third object. In other words, if two objects agree that they are equal, and follow the symmetry principle, one of them can not decide to have a similar contract with another object of different class. All three must agree and follow symmetry principle for various permutations of these three classes.
    Consider this example - A, B and C are three classes. A and B both implement the equals method in such a way that it provides comparison for objects of class A and class B. Now, if author of class B decides to modify its equals method such that it would also provide equality comparison with class C; he would be violating the transitivity principle. Because, no proper equals comparison mechanism would exist for class A and class C objects.
  4. Consistent - It means that if two objects are equal, they must remain equal as long as they are not modified. Likewise, if they are not equal, they must remain non-equal as long as they are not modified. The modification may take place in any one of them or in both of them.

public int hashCode()

This method returns the hash code value for the object on which this method is invoked. This method returns the hash code value as an integer and is supported for the benefit of hashing based collection classes such as Hashtable, HashMap, HashSet etc.
This method must be overridden in every class that overrides the equals method.


The general contract of hashCode is:
  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application. This is the reason we override hasCode() method if we override equals() method.
  • If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hashtables.

Implementation Example

1. public class Test
2. {
3. private int num;
4. private String data;
5.
6. public boolean equals(Object obj)
7. {
8. if(this == obj)
9. return true;
10. if((obj == null) || (obj.getClass() != this.getClass()))
11. return false;
12. // object must be Test at this point
13. Test test = (Test)obj;
14. return num == test.num &&
15. (data == test.data || (data != null && data.equals(test.data)));
16. }
17.
18. public int hashCode()
19. {
20. int hash = 7;
21. hash = 31 * hash + num;
22. hash = 31 * hash + (null == data ? 0 : data.hashCode());
23. return hash;
24. }
25.
26. // other methods
27. }

Now, let's examine why this implementation is the correct implementation. The class Test has two member variables - num and data. These two variables define state of the object and they also participate in the equals comparison for the objects of this class. Hence, they should also be involved in calculating the hash codes of this class objects.

Consider the equals method first. We can see that at line 8, the passed object reference is compared with this object itself, this approach usually saves time if both the object references are referring to the same object on the heap and if the equals comparison is expensive. Next, the if condition at line 10 first checks if the argument is null, if not, then (due to the short-circuit nature of the OR || operator) it checks if the argument is of type Test by comparing the classes of the argument and this object. This is done by invoking the getClass() method on both the references. If either of these conditions fails, then false is returned. This is done by the following code -
if((obj == null) || (obj.getClass() != this.getClass())) return false; // prefer
This conditional check should be preferred instead of the conditional check given by -
if(!(obj instanceof Test)) return false; // avoid
This is because, the first condition (code in blue) ensures that it will return false if the argument is a subclass of the class Test. However, in case of the second condition (code in red) it fails. The instanceof operator condition fails to return false if the argument is a subclass of the class Test. Thus, it might violate the symmetry requirement of the contract. The instanceof check is correct only if the class is final, so that no subclass would exist.


Useful guidelines for implementing the equals method correctly.
  1. Use the equality == operator to check if the argument is the reference to this object, if yes. return true. This saves time when actual comparison is costly.
  2. Use the following condition to check that the argument is not null and it is of the correct type, if not then return false.
    if((obj == null) || (obj.getClass() != this.getClass())) return false;
    Note that, correct type does not mean the same type or class as shown in the example above. It could be any class or interface that one or more classes agree to implement for providing the comparison.
  3. Cast the method argument to the correct type. Again, the correct type may not be the same class. Also, since this step is done after the above type-check condition, it will not result in a ClassCastException.
  4. Compare significant variables of both, the argument object and this object and check if they are equal. If *all* of them are equal then return true, otherwise return false. Again, as mentioned earlier, while comparing these class members/variables; primitive variables can be compared directly with an equality operator (==) after performing any necessary conversions (Such as float to Float.floatToIntBits or double to Double.doubleToLongBits). Whereas, object references can be compared by invoking their equals method recursively. You also need to ensure that invoking equals method on these object references does not result in a NullPointerException, as shown in the example above (Line 15).
    It is neither necessary, nor advisable to include those class members in this comparison which can be calculated from other variables, hence the word "significant variables". This certainly improves the performance of the equals method. Only you can decide which class members are significant and which are not.
  5. Do not change the type of the argument of the equals method. It takes a java.lang.Object as an argument, do not use your own class instead. If you do that, you will not be overriding the equals method, but you will be overloading it instead; which would cause problems. It is a very common mistake, and since it does not result in a compile time error, it becomes quite difficult to figure out why the code is not working properly.
  6. Review your equals method to verify that it fulfills all the requirements stated by the general contract of the equals method.
  7. Lastly, do not forget to override the hashCode method whenever you override the equals method, that's unpardonable. ;)