Saturday, 2 June 2018

Living is like Coding

Our Life is also just like our #codes.
1) You miss your base conditions(exercise and hygiene) , one day your code (life) will throw a null pointer exception or will show a very abrupt behavior (Medical Issues).

2) You run into an infinite loop (thinking about past) , your code will get stuck their forever and will surely show a StackOverFlow error ( you will go into depression)

3) You don't debug ( act without thinking or dont check your word) your code is going to fail and is not going to meet your client's expectation ( is going to hurt your near and dear one's).

4) If your code's complexity ( attitude) is bad or average , it will not be liked much. Less people will favor it.

5) And If you give up on your coding (life) , then ultimately you are going to lose your job (You will lose your happiness) .

So ,
while( (--LIFE) > 0) {
StayHappy();
SpreadHappiness();
CarryPositiveAttitude();
AlwaysHaveHope();
FightForYourDreams();
LoveLaughLive();
LoveEveryone();
ValueRelations();
NeverGiveUp();
ThinkThenAct();
GiveTimeToNearDearOnes();
MakeFriends();
ShareMemory();
CareForEachOther();
KnowImportanceOfFamily();
AndAlwayLoveYourSelf();
}

A very neat and clean code for living life.

Facade Design Pattern

Facade Design Pattern ??
Lets understand this in very layman language.

Suppose you are very lazy . You have to open lights of a room , television , ac , oven and etc. 
What you can do is that you can
1)First get up switch on the light.
2)Then switch on the tv , look for the remote open it.
3)Go to your kitchen switch on your oven.
4)Search for ac remote and then you have to press the button.

That means you have to do the task in 4 steps. But as I said you are lazy ,  you don't like these many steps . So you go out in a market and purchase a 'MAGICAL REMOTE'.

Now , the purpose of this remote is that , once you press on button of this remote , your ac , tv , lights , oven etc. is switched on automatically. 
You did not take above mentioned 4 steps . Just one click and your work is done.

This is basically how Facade pattern works.

Take example of goibibo or makemytrip.

You book a package and you just select a package and on the backend 
1) your flight
2) hotels rooms
3) cabs
4) tourist spots

All are booked by clicking on the package. This is facade pattern.

References :
http://techytuts.in/facade-design-pattern-with-real-world-example-booking-system/

Keep Learning , Keep Growing and Keep Reading.

Thanks alot.

-Anurag Srivastava