17 August 2010

Design Patterns - Tool to Think in Objects

There are many reasons to know and experience design patterns like finding answer to well known problems that are tested by time, it is a common language that can used for effective communication and many more. While getting exposed to design patterns helps us find solution, the experience of analyzing design patterns helps us to build a ever expanding knowledge base. It changes our perspective of seeking solution.

If one can analyze few design patterns, then it becomes all the more easy for someone to comprehend other design patterns. While learning and analyzing patters, without our conscious efforts, it helps us to see problem from objects point of view. Our structured thinking goes away step by step and we tend to "think" objects and "design" objects.

One of the key benefits of learning design patterns is "object thinking"

The answers for puzzles posted last week were published. Please visit Puzzle and Puzzle. Watch out for the next puzzle on "Binary Tree".

16 August 2010

Work From Home - Next Level of Outsourcing and True Global Organization

Software Engineering and Outsourcing is slightly getting a new route. Until now, predominantly there are two ways of outsourcing jobs - outsource to a services company in India or set up a development center in India. Many companies follow both ways. They outsource part of work to few Indian IT services company and another part of the work to their India Development Center. 

There is a good amount of traction in another form of outsourcing. The smaller companies which do not want to set up development centers because of higher operating costs, outsource work to individuals who can work from home. This is totally different from outsourcing to a different company. These employees are part of the company's payroll. Each of them have been given high speed broadband connection, phone and other gadgets to work from home. They setup a home office and work in US/European timezone.  No, I m not talking about data entry jobs. Now, the companies recruiting software developers, testers, documentation specialists and even Engineering Managers. Many companies that are in open source are doing this quite well. As the technology improves, I strongly feel that the others to follow and this is going to be "the way of truly global organization". The days are not so far apart to reach there.

15 August 2010

Puzzle - Find the Unique Number

There are two arrays - a and b. One of the arrays contains one element more than the other. The extra element is unique and all other elements are same but in different order. Find the element that is unique.

For example
a -> {10,2,3,4,6,5,8,7,9,1}
b -> a -> {1,2,3,4,5,6,7,8,9}
Unique element is {10}

Answer

public static int getUniqueKey(int[] bigger, int[] smaller) {    
    
    if(bigger == null || smaller == null || Math.abs(bigger.length - smaller.length!= 1) {
      throw new ArithmeticException("arguments passed is null.");
    }        
    
    // Till now, bigger is not necessarily bigger. let us make it bigger
    
    if(bigger.length < smaller.length) {
      int[] temp = smaller;
      smaller = bigger;
      bigger = temp;          
    }
    
    int biggerValue = 0;
    int smallerValue = 0;
    
    for(int i = 0; i < smaller.length; ++i) {
      biggerValue += bigger[i];
      smallerValue += smaller[i];
    }      
    biggerValue += bigger[bigger.length - 1];
    
    return biggerValue - smallerValue;
  }


Let us discuss one more puzzle in upcoming days in this week.

11 August 2010

Puzzle - "Binary Addition"

Puzzle:
There are two arrays of size "n". Each array represent a number in binary form meaning that each index has "0" or "1". Write an algorithm(program) to add both the array and store the result in the third array of size "n+1". This is an exercise in Coremen et al "Introduction to Algorithms".

Example:
array1 = {1, 0 , 1}
array2 = { 1, 0 , 0)
array3 = {1, 0, 0, 1}

Variation 1
As a next step, can you write an algorithm to handle input arrays of unequal size. For example, one array has "111" and another array has "10001". Find the binary sum for the arrays of unequal size.

Variation 2
Another variation is to generalize the above algorithm (Variation 1) for any base. In previous problem statements, we did it for binary. We need to make a generic algorithm that works for any base (even base 11, base 21 etc).

Example
array1 = { 1, 0, 1}
array2 = {1, 0, 0, 1}
array3 = {1, 1, 1, 0}

Answer (see comments on how we arrived at the solution)


public static int[] binaryAddVariationNoConditional(int [] bigger, int[] smaller, int base) {
    
    if(bigger == null || smaller == null || base <= 1) {
      throw new ArithmeticException("arguments passed is null.");
    }    
    
    int max = Math.max(bigger.length, smaller.length);    
    int[] sum = new int[max + 1];
    
    // Till now, bigger is not necessarily bigger. let us make it bigger
    
    if(bigger.length < smaller.length) {
      int[] temp = smaller;
      smaller = bigger;
      bigger = temp;          
    }
    
    int biggerIndex = bigger.length - 1;
    int smallerIndex = smaller.length - 1;
    int sumIndex = sum.length - 1;
    
    
    for(; smallerIndex >= 0; biggerIndex--, smallerIndex--, sumIndex--){
      sum[sumIndex= sum[sumIndex+ bigger[biggerIndex+ smaller[smallerIndex];
      sum [sumIndex - 1= sum[sumIndex]/base;
      sum[sumIndex= sum[sumIndex% base;
    }
    
    for(; biggerIndex >=0; biggerIndex--, sumIndex--) {
      sum[sumIndex= sum[sumIndex+ bigger[biggerIndex];
      sum [sumIndex - 1= sum[sumIndex]/base;
      sum[sumIndex= sum[sumIndex% base;
    }
    
    return sum;
  }

09 August 2010

Get out of the Shell, Mr. Chick

There was a interesting message from one of my connections in LinkedIn. It says, "In an egg, when an internal force is applied, leads to a life. An external force leads to omelette" . What a way to articulate the importance of internal focus/force. The internal force that propels oneself is passion. All other external forces are reasonably to close to carbon-dioxide. All other external forces are noise and pollution. The passion is divinity, soul, ecstasy, blissfulness, and life. Why obliging to an external factors like salary, promotion, recognition is near to death? If you ask anyone that you know who run after all those external stimulus (and i feel that everyone at some point of time run towards something), they will tell you that they miss something in life. There is no proper interconnection between what they do and what they want to do. They want to do something but end up doing something else. They continue to do something else simply because they get trapped in the conspiracy. The rewards often used as a tool to conspire against you. It is a attempt to make a system to appear big. A system will ever become big when it tries to appear big. The system will be successful only when all its parts are successful. If a part of a system is unproductive, the whole system is unproductive. The external factors are tools, just tools to make you fake. If you don't realize that it is fake, you are dead and hence obliging to an external factors is close to death.

Have you seen a system that challenges the superlative? Unless the system questions or challenges the superlative, the system cannot be progressive. While theoretically it may be possible to imagine a system that challenges the superlative, it is fair to assume that it is practically impossible. For such a system to exist, the system should stop focusing on itself and start focusing on its parts. Since in this world, every system has a vested interest and some benefits have to derived out of the system, "challenging the superlative" must stop at some point of time. So, the system is progressive within a limit. What if that limit is too narrow? You are caught within the limits. That is where when you feel that you are not properly used. You seek out to be productive and to be happy which is pointless. The basic and only thing that a system must do is to hold the laws of nature. Nothing more, nothing less. 

If something has to be good, its parts has to be better. When your inner self (ego) is in perfect rhythm, you tend to defocus from all those external factors and focus on your evolution. The monkeys evolved to human beings, the human beings continue to evolve and in similar fashion the nature nurtures you and incubates your evolution (evolution is much bigger than growth. Growth doesn't include time but evolution does include time and it is definitive). After all, the nature creates a world for you within you and makes sure that it brings in equilibrium and evolution.

So, You have to break your shell and don't let the external forces to touch you.

The post is more of a confession than a suggestion/advice. A reflection of my past and how I could have done much better.

08 August 2010

Love at First Sight - Ubuntu

WOW. What a feeling? I never seen such a beauty and elegance. Having been using Windows XP every day for the past eight years, I never looked at Linux as Desktop system. Throughout my career, my interactions with Linux were limited to text mode as I predominantly write programs using "vi". I missed to live life with Ubuntu. Six months back, I installed Ubuntu in my laptop using VMWare. Yesterday, as I was feeling boredom, I tried to play with my Ubuntu VM. I did a bit of customization and my heart says Ubuntu is much better than Windows in experience (my personal view). I think, my long wish of buying a Macbook for a classic graphics and user experience is partially fulfilled by Ubuntu. My programming for sure going to become more artistic. There is no surprise if I assemble a desktop specifically for Ubuntu. BTW, all the webpages look great including my blogs :-)

Kudos to Ubuntu team for putting together a FANtastic distribution on top of CLASSIC kernel. You are awesome. Now, I can't wait for next version of Ubuntu. Ubuntu is rocking.



PS: The picture is the screenshot taken from by Ubuntu VM

17 July 2010

Trying my Hands in Investing/Trading

There are many that trade in stock market. Most of us lose the money and few of us win it and go to an extent of writing a book. I always invested in mutual funds, life insurance and pension funds thinking that I will get a fat corpus when I retire and start to do something I cherish to do. Seems like that is a horizon. Horizon is always a horizon how fast you travel towards it. I got in between pragmatism and ambition. I was like a calm river, taking life as it comes and not trying to change my course on the "money" part of life. I don't wish to jump to a higher paying job just for the sake of money. Rather, I want to find new ways of multiplying the money and also invest on myself to get an alternate source of income/business/investment/whatever we call it.

As a first step, having lost big deal of money (ok, it is not so much :-)), I started to invest on myself. Everyday, I m learning something like investment psychology, technical analysis, economy and try to connect with people who already made quite a sum (of knowledge, discipline and money). Slowly, I will be starting to post on finance (more specifically my experiences with stock markets, my learning on the subject). I hope that will be of use to some of you who also aspire to make big business. I continue to believe that stock market is not a place to make money but a place to run business.

With a big aspiration, I have started my journey towards setting up my business in my laptop and head with my friends and friends to be. Will keep you posted if something good opens up.

27 May 2010

Do We Really Need To Focus on Collaboration?

These days, Collaboration, a misnomer, often used by people who really don't want to do any work but to make themselves in a center stage. Collaboration or team work is something that we shouldn't do it knowingly. Collaboration is all about understanding the responsibilities, exercising actions and being accountable. Collaboration doesn't originate in a meeting room. Collaboration is there in our minds - the openness to accept others and the openness in letting others as they are.

Collaboration, in simple terms, is mere responsibility. Do all the needles in a clock collaborate? Of course, yes. But every second, does the seconds needle trying to sneak peek into the work of minutes and hours  needle or do they always say that they collaborate? Of course, no. How do they collaborate? They just do their job and do it well. All those needles don't need a manager. They conduct themselves. There is a conspiracy. A conspiracy to make individuals as replaceable cogs, a conspiracy to make you dispensable, a conspiracy to make you untrue and a conspiracy to make you to do disservice to yourself.

You will get the benefit of team work only when you know your responsibilities. Without responsibility, collaboration is just a nice quotation in your hoarding or a catchy but yet vague idea in your dummies toolkit. If I still don't make sense, pardon me. These guys show what is collaboration and what is responsibility?

Gung Ho.



23 May 2010

Collaboration - When It Is Fruitless Encounter

It was a cold night. Many folks are sleepless not because of chillness that prevailed through the air but due to sounds of gun shots at the battlefield. They are sleepless and at the same time they aren't just staying in bed. They are in battlefield, fiercely fighting out the intruders. Unperturbed by loss of their friends and friends in death bed, they are fiercely fighting, heeding the commands of their captain. They spread across the area of more than 20 kilometers with only one thought in mind - to regroup after ten hours to attack the intruders in unison. They dismantled themselves to reunite. They call "dismantling" as collaboration. The collaboration is a coordinated action strongly focused on the vision with everyone willing to give their share of breathe. After ten hours, you either find them there or dead somewhere else. They are true collaborators. They make sure that they win as a team or fail as individuals. For true collaborators, accuracy and precision are what that matter. For them, the collaboration is not certainly another form of escapism to hide their incompetency.

The corporate drama in the name of revenues, net margins, gross margins, profit & loss and the series of actions in the name of collaboration is shocking or very least far away from my comprehension. People, time and again, prove that we fail as community. In many organizations, you can find many dead communities. Are those communities died because of plausible reasons. Most of the communities fail because of few individuals - key guys that involve in drama. When someone starts a community, I get a question, when will it die? when it will die pathetically? My question gives me answer. When will you die? when you do evolve. This applies even to community. You cannot stay there, you got to be better every second. When you collaborate, you got to be better than you a day before. You always feel that the value the group adds to you is more than the value you add to the group and you try to match your value with that of the group every time. In a fruitful collaboration, everyone gets their own deserved share of joy, recognition and of course peace of mind. When there is no fairness, the community starts to deteriorate and starts to move to general ward, then slowly to intensive care unit and finally declared dead.

When my friend (Karuna) and I had a discussion on this, he shares his experience. These days, as the economy is recovering, what you bring to the table is very less (or rather far less) than what you take from the table. I see you in the playground, I see you rolling your sleeves up but I cant see your hands or cuffs go dirt or you don't allow me to influence the group. It remembers of the election manifesto and electoral public meeting. You bring your share of sweat and I will bring mine. Have you ever thought about this. What if everyone brings less value than the value they take from the table. It is death by (lack of) collaboration. If you ask me to choose one between non-collaboration and death, I will choose non-collaboration. If i have choice between speaking up & getting hurt and keeping silence & not getting hurt, I will choose speaking up & getting hurt. If you say that my attitude is wrong if I stop (or reduce) giving when I see you don't bring the value to the table consistently, it doesn't sound like a killer idea and it sounds more like a moron's speech. Then, why call it a great deed when Gandhiji led non-co-operation movement? Well said, Karuna.

What do you feel?

21 May 2010

Experience is

Experience is a wonderful idea. Experience is not just a thing that you gain when you do things. What you do and how you do, not just once but consistently shows your experience. Experience is sum of higher learning, total commitment, observation of events, our awareness on how our decisions affects the entire system, trying to pass on the knowledge that we gained through experience and overall it is all about the quality of life we live through. But not just years and years of being in a place or state. Experience is both physics and chemistry :-)

Usain Bolt knocks off a millisecond in every sports meet, Sachin Tendulkar keeps doing something phenomenal in every tournament and Steve Jobs mesmerizes the market with a launch of each product. All these people keep adding year to their experience every year. But every year, they make sure that they raise the ceiling when they hit the ceiling. They observe things, they understand each event is unique, they understand each second is connected to minute, each minute to hour, each hour to day, each day is connected to year. They EXPERIENCE every second when they work. They elevate themselves before someone elevates them. It is true that EXPERIENCE gives elevation but not just years :-)

09 May 2010

Sense of Urgency

These days I m trying hard to get rid of my poor vocabulary and slow reading. Sometimes, I find it very hard to pen my ideas thoughtfully and often I find myself searching for better words. In the reading front, I just read few pages and sleep in my bed only to find that I forget whole a lot of ideas and thoughts. The metaphor that I would like to use is that of a deck of cards. As soon as I read the next page, what I read in previous page vanishes off like the deck of cards. My reading comprehension is very poor. In order to bail me out (rather badly), I bought two books by Norman Lewis - Word Power Made Easy and How to Read Better & Faster.
I m currently reading "How to Read Better & Faster" and working out exercises. I feel that the first technique, "creating a sense of urgency" improves reading speed and comprehension. I quite experience the fact that by slow reading not only leads to waste of time but also leads to reduced comprehension. Between sentences, I have time to travel to moon or think about something that happened during my childhood. By creating the sense of urgency alone, I m able to bring my entire focus and purpose on single thing - to read and understand the text before me. It works. I m able to increase my speed by 10% and comprehension by 5%. Most importantly, I live in the present and enjoy the moment.

I feel that this sense of urgency can help in our life too. Rather than approaching work/life so causally (and ultimately losing focus), the sense of urgency will create a focus that breeds natural interest on the tasks we do (of course, you will be able to move things off your plate that is not of interest to you). This sense of urgency isn't doing things in a hurry. The sense of urgency is about fixing a time limit during which you will challenge yourself. It is small steps to make yourself a better person  than your current state. Like small drops make ocean, these tiny improvements created by authentic self-challenge increase the personal effectiveness.

It also gives a sense of accomplishment as any work done in short time with lot of focus will be an invaluable experience and creates a wow moment in life. We always see ourselves growing and improving than the past. There is gradual progression and evolution - from monkey to mankind or from mankind to god or man of no realization to man of self-realization. Our usual days are filled with wow moments and these wows make life very interesting, really very interesting, satisfying and enriching.