Monday, June 20, 2016

Story of a little wave

There is one book which never fails to remind me every time the whole passion of my human spirit, my silent shoulder of solace amongst all the chaos and mayhem of life.

Excerpt from "Tuesdays With Morrie" by Mitch Albom:

“I heard a nice little story the other day,” Morrie says. He closes his eyes for a moment and I wait. “Okay. The story is about a little wave, bobbing along in the ocean, having a grand old time. He’s enjoying the wind and the fresh air—until he notices the other waves in front of him, crashing against the shore. “‘My God, this is terrible,’ the wave says. ‘Look what’s going to happen to me!’ “Then along comes another wave. It sees the first wave, looking grim, and it says to him, ‘Why do you look so sad?’ “The first wave says, ‘You don’t understand! We’re all going to crash! All of us waves are going to be nothing! Isn’t it terrible?’ “The second wave says, ‘No, you don’t understand. You’re not a wave, you’re part of the ocean.’” I smile. Morrie closes his eyes again. “Part of the ocean,” he says, “part of the ocean. “I watch him breathe, in and out, in and out.”

I have my own interpretation. What does it mean to you, it's up to you to think. I can't really suggest.

Wednesday, April 13, 2016

I Choose Violence

04.24.16 So the agony is almost over, the Game of Thrones Season 6 premiere night is just around the corner. Since the Red wedding, have been waiting for someone to avenge Lady Stark. Lord, I sedately adored her. That's the enigma with watching a series like GOT, obsession seems normal. Even, recently a professor introduced a Game of thrones edition course, have to admit that he is way beyond cool.

Though I am more concerned about my newborn affection for Cersai after Mother's Mercy. It would be so ruffling if I fall for her. But since when life has followed linear equations. We don’t get to choose who we love, do we? I just wish her to be a little bit less Cersai though. But again Cersai being Cersai, I know she will kick arse, that I want.

Anyway, after a long winter finally, summer has arrived. Check it out and don't worry Jon Snow will be resurrected.

Wednesday, March 16, 2016

Final weeks - Let's keep calm!

Me: Isn't 1000+ slides too much prof?


Professor: Don't worry, questions in final will be easy given you aren't dumb.


Me: LOL, That's how you failed 75% of class last year :-/

Update [May 2017, a year later]: Well, failed that examination by 0.3 (passed:15.625%, it didn't really feel so bad when ~84% of the class failed :-/). Funny thing, a few months later, applied one of prof technique at work and dude was it a riot, eventually, a whole module adopted that same implication.

Looking back: One of the best course ever taken ... It's totally okay to fail sometimes:D
Mother used to say, "Every Hard-fought Struggle Pays For What It’s Worth, Someday. You Just Don’t Know Which Day, Yet!"

Wednesday, December 16, 2015

My Infinite Playlist - '15

'15 you are truly insane. There were times when I hated you most for your stubbornness. Those waking up in the early morning, those late night struggles with sleep and slides, those schedules - almost all of your traits were crazy enough to drive me insane with your excuses. I sometimes hated you for your bullying gut. You almost dragged me to some amazing places where you wanted us to go but I was shy to explore. You inspired me to be good, to do something good with life, gave me a purpose. You are more than a friend to me.

I guess there were times too when you hated me too for my lazy ass. But believe me, I sincerely worked everyday to prove you that I was worth of your love and affection. My dearest, I grew with you every passing single moment. I despised you and the same time loved you. I truly loved messing with you, I know sometimes it made you annoyed but you patiently bore with a broad smile on your face. I fell in love with our awkward beautiful bonding.

Now as the time to say Goodbye is under the horizon, I want to say something to you even though I can't find anything that can properly express my feeling and our relationship but there is something I want to dedicate to you that says something about us - "The relation of growing together".


Most probably this is my last post directed towards bidding adieu to passing years.

Tuesday, December 2, 2014

Life As I Know It - Cheerio '14

As this year is almost over, I want to share some thoughts with you Jedis. Don't take failures as a stumbling block in your life. It's ok if you got things messed up, it's ok if you were rejected like hell, it's ok if you made yourself ashamed and ridiculed of yourself, it's ok if a low point came in your life and it's ok to allow yourself some time to heal before you take that next step. But remember that life is not a staircase, it's a maze. You can modify and alter your journey along the way. Be flexible and open to alternative pathways. It may lead you down some wonderful roads. Keep up the fighting spirit and know that it's not over until it's over!

And now to my '14: 
My sweetheart '14 before we say Goodbye, I want you to know something, even though you know it already my brave Lady. You will always stay loved and remembered. Here something dedicated to you.

                                                                 Happy new year!!

Thursday, November 20, 2014

Inheritance – “A type of” relation NOT “contains” relation

Many times people confuse inheritance with “contains” relationship, which is not correct at all. Inheritance is “A type of” relationship not “contains” relationship. So a child is a superset of Parent’s abilities.

Example: Each fox is an Animal. But the other way is not always true (Not every Animal is Fox). Hence, Fox is a type of Animal.

class  Animal{

                                    1.   Ability of walking

}

class Fox extends Animal{

                         1.   Inherited abilities: Ability of Animal (walking)

                         2.    It’s own abilities (like hunting)

}

Now let's try to digest few concepts here.
When I write this :  Animal  a = new Fox(). What does it mean?
It means Fox is also an Animal or  every Fox is a type of Animal which makes sense too.

What about :   Fox  f = new Animal() 
It means Animal is a type of Fox or every Animal is a Fox, which is absolutely incorrect.

So "Fox is an Animal" is fine but the reverse doesn't make sense. For example, Apple is a Fruit, Car is a Vehicle etc. Remember inheritance is uni-directional. For example, House is a Building. But Building is not a House.

Let's formulate our finding in terms of coding: A reference to child class object can't refer to the parent class object. Whereas a reference to parent class object can refer to child class object.

Example 1: 
       Animal a =  new Fox();     //True
       Fox  f = new Animal();      //False (Compilation error)

Example 2:
       Animal a = new Animal();
       Fox f = new Fox();
       a = f;               //True
       f = a;               //False (Compilation error)

So we learned few things here: 
A child class object is inherently a parent class object. In simple terms, objects/reference of parent class can hold objects of child class but the reverse is not true.

Example 3:
public class TestMain {

       public static void main(String[] args) {

              Animal a = new Fox();

              a.walk();

              ((Fox)a).hunt(); //need to typecast because reference "a" doesn't hold "hunt" method

       }

}



class Animal{

       void walk(){

              System.out.println("Animal can walk");

       }

}



class Fox extends Animal{

       void hunt(){

              System.out.println("Fox can hunt");

       }
} 

Output:
Animal can walk
Fox can hunt


Few points to mention here:
1.  A subclass can't inherit private members of Superclass obviously.
2. Try to keep all variables private or protected and use public accessor(set/get) methods to access them.
3. On a light note: Initially don't try to learn this concept with "child" and "parent" example as you might get confused. Playing with a dog or a cat is safe and easier. :)

Tuesday, November 18, 2014

Difference between method overloading and method overriding

Method overloading in Java occurs when two or more methods in the same class have the exact same name but different parameters.  Overloading is a compile time (static) phenomenon because the compiler is aware of exactly which method you are calling based on the number/type of parameters.
 
class Animal{
       void test(){
              System.out.println("Inside Animal class with no aruguments");
       }
      
       void test(int a){
              System.out.println("Inside Animal class with int aruguments");
       }
}

public class TestMain {
       public static void main(String[] args) {
              Animal a = new Animal();
              a.test();
              a.test(5);
       }

Output:
Inside Animal class with no aruguments
Inside Animal class with int aruguments

In this case, the compiler knows exactly which “test” method we are calling, based on the number/type of parameters.

Overriding methods is completely different from overloading methods. If a derived class requires a different definition for an inherited method, then that method can be redefined in the derived class. This would be considered overriding. An overridden method would have the exact same method name, return type, number of parameters, and types of parameters as the method in the parent class, and the only difference would be the definition of the method. Overriding is an example of dynamic (run-time) polymorphism. This is due to the fact that the compiler doesn't necessarily know what type of object is being passed in at compile-time.

class Animal{
       void test(){
              System.out.println("Inside Animal class with no aruguments");
       }
      
       void test(int a){
              System.out.println("Inside Animal class with int aruguments");
       }
}

class Dog extends Animal{
       void test(){
              System.out.println("Inside Dog class with no arguments");
       }
}

public class TestMain {
       public static void main(String[] args) {
              Animal a = new Dog();
              a.test();
              a.test(5);
       }

}

Output:
Inside Dog class with no aruguments
Inside Animal class with int aruguments

Here, method dispatching is performed in two steps:
  • The first one is done at compile time with the static information available, the compiler will emit a call for the signature that matches best your current method parameters among the list of overloaded methods in the declared type of the object the method is invoked upon.
  • The second step is performed at run time, given the method signature that should be called (previous step), the JVM will dispatch it to the most concrete overridden version in the actual type of receiver object.