31 August 2010

Software Design Puzzle #4 - Building A Flexible Weather Station

The puzzle is on building a flexible weather station. This weather station's main job is to provide instantaneous updates to its clients on various weather conditions like temperature, atmospheric pressure, wind speed, pollution levels and a forecast on the rain. The clients are heterogeneous starting from a full blown weather forecasting websites which are interested in all updates (everything from temperature to rain forecast that are available time to time) to a roaming marketing guys who just want forecast of rain to plan their travel. The point is there are few clients that want all updates, few wanting all except few conditions and many wanting only few conditions. The clients will also be requesting for more weather parameters dynamically.

The requirement is to identify design pattern(s) that will suit these requirements. Model the class diagrams focusing on important aspects of the design. The following is a just a sample client (thanks to Google).

A question that comes to my mind on these puzzles. Does it really help me to build my OO expertise?

An honest answer is it depends. The idea of posting these puzzles is not make us OO guru with few hundred puzzles and in fact OO requires naked thinking. I feel that a lot of thinking can be stimulated by these examples. Memorizing a design doesn't help though. Just skim through the puzzle and solve it. When you are solving think about abstraction. Abstraction is your ability to see sand in a beach as a thin line when you are flying few thousand feet above and view them as a mighty rock when seeing through microscope.

30 August 2010

Verify Everything - Feel It Before Accepting

The self realization has never been a group work. It is an individual's efforts towards knowing himself. The object painted by society is just the view of the society. It is framed by people like you and me. So, there is every possibility that it is wrong. Because, human errors are natural. However the society makes every attempt to make you to accept its view and to be ingrained in its view leading to deep conditioning. The society (may it be the society we live, work, party, religion and many other groups) has a deep conspiracy. The conspiracy of not to allow us to think. Society says to man, I will allow you to think but you have to think the way I want you to think.

As man grows, his views about world widens. He becomes knowledge base and his knowledge is dangerous because his knowledge was never verified/validated by him. But he simply endorse it. He conditions you and then he comes to you with a group, the group conditions you. Because, the group feels the majority makes them right. So, he conditions you. If you get conditioned the society wins, you lose and if you don't condition yourself the society loses and you win. It is all about survival of the stronger. So far, mostly the man lost.

When you are a child, you questioned everything. You didn't think about the relevance of a question. But you just question. You get worldly experience by asking questions on the things you perceive through your senses. When you are a child, you verify everything. You give very first hand information. When you say, the fire will be hot, you experienced by touching it and you say with confidence. Thats why the child never say there exists a God (but the parents make him to say so). Verification is key to contemporary thinking. If you don't verify something, you cannot endorse it. If you endorse something without verification then it is conditioning. 

Verification is key to self realization.

Have a Great Monday and Fantastic Week.

29 August 2010

Notion of Best Practice - Does It Make Sense?

Most often we say that something is a best practice or at worst someone (who generally doesn't know anything about the problem you are trying to solve) asks you to follow a best practice. First, the very notion of best practice is wrong. The term "best" signifies that it is the superior and no other better option is available. In reality we, the human being, have not perfected any system with such an accuracy and deeper knowledge so as to say something is best. Most of the systems and processes are still evolving.

Assume that there is already a known best way of solving a problem and even there exists a proof to conclude that it is the best way of solving problems. The proof says about the best way and various other known ways of solving problems. It compares the known existing methods. For example, while there are numerous ways of sorting a given set, we can pick a efficient method to a job. But the proofs do not talk anything about other possible but unknown ways of solving problems. What happens if there exists a solution that is better than the best?

In the context of problem solving and thinking, the term Good Practice makes a better sense than Best Practice. The notion of best practice is wrong and the "best practice" thinking arrests productive thinking.

Have a Super Sundae.

28 August 2010

Don't Just Scream

Many times, we see people who just scream (aka articulations, speeches and anything that boils down to inaction). They scream at cockroaches, the politicians who never work in public interest, someone in traffic who just zipped across on to their way, their teammate who doesn't understand what is work, their managers who is root cause of all their problems, the wall they dashed at. They have all sort of things and whole a lot of time to scream, just scream (at different places, volumes and languages, like this one ;-) ).

Screams are not tools. Screams are just annoying thing and negativity. Actions are tools for correction, action is positive, action brings in change, action leads to transformation, action leads to evolution, action leads to natural growth. Scream can't just bring anything but high blood pressure. When you are acting on a problem, the scream is "ok" and people will bear with you or relate to you. For some people scream is natural when they focus. A star tennis player screams when she plays a difficult shot, when she stretches a lot and she screams because of pain and the pain gives her energy to focus. But not just screams. Screams are just shit. So, please show something in action when you scream. If you do that, you look lovely.

Have a Fantastic Saturday

26 August 2010

I Have Found My Deadliest Enemy, What About You?

I have found my enemy who always cheats me, stops me from driving towards excellence, he is the one who is making me lazy, he betrays me, he gives me lame excuses to not to do something, he spoils my consistency, he always questions my unconventional thoughts and he stands as a hurdle when I want to take the road that is less traveled or never traveled, he asks me not to take risks, he asks me adventures spoils happiness, he highly conditions me and passes a judgement that I can do only this much, he stamps me as a software engineer, he stops me from growing human, he says where is the time, he makes me to sleep in couch like a lazy potato (pig?), I m addicted to his way of thinking, I don't want to think like him but yet he wins. Who is that? He is "Me".

Many of us would have been in the scenario of failing and would have blamed someone or something other than us. But the real fact is that it is "us" who is responsible for the failure. The responsibility doesn't stop at failure but rather starts after we fail. When someone says that he will take responsibility of a failure, it should mean that he will fix the root cause of the failure. The pain of failure is far lesser than the pain that will arise due to lack of awareness or ignorance. If you take ten things that you wanted to do but never did and analyze what is the root cause of the problem, you will simply see the truth.

For example, I was trying to jog for past few months (years?) and never did consistently. One day, I had work, the other day there was drizzle, another there was a relative at home, yet another day I was not feeling well but certainly I didn't have a single day in life without an activity so that I can jog. When I gave excuses, I fail. I dont really know whether I can say that as failure. Because failure comes when you do an activity. When you don't do the activity, it is not a failure. It is lack of thinking and awareness.

So, I have found my deadliest enemy and it is "Me". what about you?

Have a Super Duper Day (yeah, weekend is arriving).

25 August 2010

Ethics - What Is It?

We say that we think a lot. We say that we are taking decisions after deliberation. We say that we are trying to be ethical without knowing what is ethics, why one needs to be ethical, what is an extent to which one can be ethical. We prove time and again that we talk about ethics when our survival is not under question and the ethics takes a back seat when our survival is under question. This is one of the reasons why we have business cycles, recessions, depressions (both economic and psychological) etc. A specific economic indicators like dropping housing market is not the cause for recession. But the indicators, as the name implies, indicates a systemic failure and one of the reasons is lack of ethics.

Here are the points that comes to my mind when I think about ethics (why am i thinking about ethics now is another big question). Well, I haven't proven it yet and hence all the points can be debated to bring in more clarity.

I have been trying to understand what is ethics by observing people. The first mistake I did is trying to copy ethics from others. If i try to copy from others, my ethics is very subjective. After watching many people, friends and thinking about how I lead life so far, I feel that ethics is a framework. The framework is quite flexible and one can draw his/her own boundaries. Ethics is set of standards that is beyond law and society. It is quite difficult to measure ethics and hence no one can certify you that you are ethical. It is unique to each one of us. Ethics is personal, you can customize it and you can keep customizing it.

Ethics is awareness and introspection. While ethics is personal, if you violate the boundary, you have to pay the price (either your conscience hurts you or you will be in a situation in which you ought to pay the price and that boils down to experience). Ethics is awareness and looking inwards. Ethics is a system. A best possible self correcting system.

Mahatma Gandhi has a very high ethics. If one reads, "My experiments with Truth", it is quite visible that Mahatma Gandhi was not the same in his early days. He needed a street play to ignite his passion. How he reached there? How a thief turned himself to a saint Valmiki? Ethics is all about life experiences and daily introspection. Quite often, we need to do the introspection to make the framework of ethics wider and bigger, more meaningful and more sensible. I feel that this is central premise of building ethics (If you believe Hindu mythology, you would question how can thief be a saint. We have been told that we will be punished when we committed a sin and we are less told about introspection and awareness that occur due to punishment. If one can introspect, the punishment can be avoided. Actually, it is the introspection and awareness which can nullify the Karma). Clever people expand their ethics. Every day, they become more ethical. Ethics is ever expanding/evolving entity, it has no boundary. But one sure thing is that it can be made better every day even when you are in death bed.

You walk on the road and suddenly fall down. You expect that someone will lift you and help you. To your disappointment, you find no helping hands. The next day, you walk in the same street but this time you are very careful of the small pit that made you fall down yesterday. Near by the same place, you find an old woman asking your help to cross the road. It is the same road you traveled yesterday. Out of joy, you help the grandma to cross the street so as to make this world a better place. You prove that human beings evolve. Ethics is something you do (with joy) irrespective what is been done to you.

Have a Super Day.

24 August 2010

Don't Search Information But Seek Knowledge

There is no doubt that this world has a lot of information and by now most of the information that we seek are already indexed by search engines. One needs to just search it and start reading. As information is available 24X7, many of us fail to understand the importance of seeking knowledge. We don't want to undergo even slightest labor to experiment and write our own HOWTOs. Sometimes laziness puts us off and sometimes someone says "don't reinvent the wheel". We spend time by searching. If we are unlucky, we find the piece of information. I m saying that we are unlucky simply because it stops us from experimenting. Generally, we are not of exploratory in nature but according to nature we are supposed to be exploratory of nature (what an irony?). If we don't find some material, we give up and knock the doors of experts. Searching is sick.

Seeking is quite different from searching. Seeking involves searching but not vice versa. While a student is seeking for knowledge, he never cares about amount of time he spends on searching and experimenting. He enjoys the hard work. If he doesn't find information, he creates it by experimentation. Seeking student never tries to get all information from someone. He just asks for directions and puts in efforts. He is self made man. Once he seeks knowledge in a particular domain, he understands and masters the process of acquiring knowledge in other domains. His knowledge base expands. Seeking is powerful.

So, let us stop searching information and let us seek knowledge (and wisdom).

Looking forward to hear your opinions

Have a Fantastic Day.

We can certainly use NPTEL video lectures as a starting point to seek knowledge in Engineering. For more info, please refer my older post on contribution by IIT/IISc - NPTEL.

23 August 2010

NPTEL - Videos for Enhanced Learning in Engineering

If we want to learn anything, today, we have abundance of resources online in multiple forms - EBooks, tutorials, Howtos, and videos in websites like Youtube. A year back, IITs and IISC started an initiative NPTEL - National Programme on Technology Enhanced Learning covering most of the areas of engineering. The eminent professors and researchers from IITs and IISc take lectures on many areas and these lectures recordings are made online. I happen to hear one such lecture by Professor Kamala Krithivasan on "Discrete Structures". It was a good learning experience and most importantly many of the courses are interlinked. 

A consistent effort will help us to understand the subject better. Already there are over 125 courses available online and many of the lectures are video lectures. Each course consisting of many modules can be received as CD for a nominal fee of 200 rupees (just for the sake of production and distribution charges). or accessed free of cost in Youtube. Now, there is another good news. NPTEL has started Phase 2 covering many more topics. I m looking forward for Phase 2 videos/lectures.

All the videos are available in YouTube NPTEL Channel and the website of NPTEL can be accessed here.

Hope this helps.

Happy Learning.

22 August 2010

Chrome OS - Oversimplified

When Google announced about Chromium OS sometime last year, I didn't pay much attention to it. If there is only one reason why I should pay attention is because of its Linux link. I was thinking that it is going to be yet another distribution of Linux from Google. I asked myself a question, why you need another distribution? Why can't it be Ubuntu? Of course, Ubuntu has come a long way in being a most preferred desktop Linux OS and it is evolving everyday. Will Google answer this to community?

A couple of weeks back, I read about Chromium again. Chrome OS is Linux based OS that are initially targeted for netbooks. One cannot install any applications apart from pre-installed Chromium browser. The users of netbooks can't install any software and for everything they have to go online. We are far from accessing everything online. Even if I have everything online, still I would like to prefer to have something in my gadget. Another important thing is that Chrome OS has new security model to make netbook secured. May be a value add here on security front.

Out of curiosity, I searched for Chrome OS download and found a VMware image which of 300MB+ size. Downloaded it and loaded in my VMWare player. Within 20 seconds, login screen was thrown at me and I had to enter my Gmail username/password. Login is fast and neat (but this is not a selling point. Chrome OS is lightweight and so this is very basic requirement). After login, Chrome web browser was launched. There isn't much to write about Chrome OS. After login, Chrome browser is Chrome OS. Is it a trick by Google to capture Internet Explorer market? I don't think, with the current features, Chrome OS go near to Ubuntu. I feel that Google's target is IE market :-). Waiting for Chrome OS release to see what it finally offers. Overall, I feel that prototype of Chrome OS is oversimplified.

Here is the screenshots that are taken from my Vmware Player.






20 August 2010

Software Design Puzzle #3 - Modeling TCP/IP Stack

You would have heard about TCP/IP Stack in Networking (if you haven't or want help in refreshing, please refer here). The puzzle to identify and come up with set of classes with properties and functionalities to represent TCP/IP model using object oriented principles. Also, identify the list of design patterns that can be used while you are designing the classes.

The answers to previous two puzzles on algorithm is out. Please check out all the puzzles here. Will be publishing the answers to all outstanding puzzles this weekend.

Also, please do let me know your comments/feedback/suggestions.

18 August 2010

Puzzle - "Find Common Parent"

Puzzle

There is a binary tree. Each node has id, left and right as data. The id is unique integer representing the node, left and right are pointers/references points to left and right child respectively. Given two integers, write an algorithm/program to find the lowest common parent node.

Example:
Input - {15, 10}, Output should be {2}
Input - {19, 15}, Output should be {4}
Input - {6, 20}, Output should be {}


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