Friday, April 12, 2013

Thursday, October 6, 2011

Why every employee is important, every employee.

For a successful product to be launched the key ingredients are
  • Passion
  • Brand
  • Innovation
  • Technology
  • Care
and the most important and commonly ignored one is
  • EVERY employee
I'm not going to expand on the other terms, as the words are self-explanatory. 

Let me share an incident that happened to me recently-the reason behind writing this blog. I recently planned to buy a headphones, and quite excited from the reviews went ahead to buy it from a mall near by.  From the brand value, I expected a warm welcome to the valuable customer, who is about to buy their innovation. My apparel was casual and hence I was blaunt and did not make a great impression for a warm welcome or at least welcome. There were two sales men and both of them were talking to a customer-a well dressed old man. I could make from his body language that he is not going to buy the product-ofcourse not my job. I waited for ten minutes and requested for an attention. 

One sales man came to me after five minutes and I requested for a demo for the product I am going to buy. He shuffled the products that he had and left. For a second, I was feeling like Dr. Malcolm Crowe in Sixth Sense, unnoticed. I asked him twice and he did not mind to give an attention. 

The moral, "every employee is important" and I walked away.  Sales men are not the only ones, every employee is important. Just think of situations where your friends working for an organization gives a bad review on how it treats employees,  where a person annoys you in an interview, a single 404 page during a transaction (referring to the employee who is responsible for it),  a new joinee give a bad review of the previous employer, etc. 

So, even if every employee gives their best for the product and one employee does anything bad, customers walk away. 

Wednesday, June 1, 2011

Site performance tuning using jMeter and jVisualVm

I recently had to work on a requirement where I had to support (response time  less than 5 seconds) for   500 concurrent users, with 10 million users in database and a single server. I tried going through many forums and open source tools, from which I finalized on jMeter for performance testing and jVisualVm for finding bottlenecks.

This was my approach:
  1. Make sure that the server (hardware can be as per the staging/production requirements) has no other installations that can affect the performance. 
  2. For setting up the users in DB, a procedure can be used and can be called as a part of jmeter test plan.
  3. Install jmeter on a separate machine, so that jmeter won't affect the performance. 
  4. Create a test plan in jmeter (as shown in the figure 1) for all the uri's, with response checking and timer based requests.  
  5. Take the initial benchmark, using jmeter.
  6. Check for the low performance uri's. These are the points to expect for bottlenecks.
  7. Try different options for performance improvement, but focus on only one bottleneck at a time. Some of them can be 
    1. Database index. Use the DB server logging to find the slow queries, use explain plan and improve the sql statements.
    2. Check the configuration parameters for any third party tools.
    3. Check if there are any dead locks (can be checked with jVisualVM as shown in Figure 2).
    4. Profiling the application using jVisualVm(can be checked with jVisualVM as shown in Figure 3).
    5. Data structures, algorithms and loops.
    6. UI components, try advices from YSlow. Try streaming, caching, etc.
    7. Read the hardware configuration and try for any options like cpu cache, jvm tuning, paging, etc. This step does not include hardware scaling.
    8. Check for memory leaks using jVisualVm.
  8. Try any one fix from step 6 and then take an benchmark. If there is any improvement commit the changes and repeat from step 5. Otherwise revert and try for any other options from step 6.
  9. The next step would be to use load balancing, hardware scaling, clustering, etc. This may include some physical setup and hardware/software cost. Give the results with the scalability options.
jMeter test plan
Figure 1: jMeter test plan

jVisualVM run for a sample deadlock program.

Figure 2: jVisualVM shows Thread 1 and 2 waiting for the monitor
Figure 3: jVisualVm showing profile results for memory

Results:

In the end it is better to prepare a complete report from the benchmarks and finally define the performance with details of the hardware, software, maximum db load, maximum number of concurrent users supported(users active every 2 seconds), maximum number of sessions, changes made and the improvement achieved.  Any unimplemented changes can be suggested for improvement, so that the effort to find the bottleneck is improved.


Saturday, December 11, 2010

Originality

I believe the most powerful tool that human beings possess is the mind, that can ignite imagination. Every possible creation in the world is a tangible idea. Every possible idea is the outcome of all or some of the senses, passed through may be a single or billions of neural schemas (referring to the brain). 

Any idea can be referred to some part of the nature (at Universal level). When someone says an idea is original, what is it? I don't understand.  Take for instance, Google search, don't you think it is a matured idea of the search that we do everyday; Facebook, is it not a virtual social network; Virtualization, complete simulation of a natural concept; Photography, light captured with a particular setting (do you own the light or the setting?); Music, captured sound at some desired frequencies; etc. 

I still don't understand, the noun originality, is it the first idea preceding all others in time? In such case, it belongs to the nature. Or is it the first one to file a patent or register it, or is it the first one to show it to the world. Or is it the first one who comes out with some tangible output. What if someone had the idea for long time and could not come with an output or did not express it.

Understanding this, I do understand the considerable amount of work someone puts for coming out with  an idea, which we all feel new. I still wonder if the newness or freshness can be considered as original. I take the concept of wall (which itself is taken from a broadcast or something else) and come out with a specification of wall with only 150 characters max, inclusive all characters and call it twitter (just an example, which is considered as a great idea). Is this original? But, I understand the effort that is put for developing this and the ego of so many developers, and may be testers too.

Why all the software is not made open source? Is it because of security reasons or is it because of the ego of the investors or ego of all the developers, who don't want someone else to directly copy it or reuse it. 

So, definition of originality or original-idea (as it is used) is the ego of the hard-work to build an idea, which creates the feeling of some newness or freshness and belongs to the first one who expresses/shows it to the world.

Actually, originality is nature.

Disclaimer:  I do not copy nor encourage some one to copy any idea, but just sharing my thoughts on my confusion on originality. This is my understanding and welcome your definitions or ideas. 


Tuesday, April 6, 2010

Inherent Variability: A Major Difference Between Man and Machines


Image (a)
Image (b)
Image (a) shows my attempt to write alphabet 'a' the same way four times. Image (b) shows how a machine does the same. Obviously, we can see the machine is precise in doing this. A loud applause for the machine!

Image (c)


Image (c) shows a hand written word, in two different ways. The word can, obviously, be recognized by any human reader. How good is the machine in doing the same task? This is how a captcha differentiates man and machines (though it is not exactly written by human beings, but some algorithm that can generate and display words with some distortion, which is difficult to be recognized by machines and can be easily recognized by humans).


Any written alphabet, spoken word, action performed by a human being is a stochastic process; i.e., it is an output of a random function. Apart from the variability in doing things, we are built with an inherent ability to recognize and learn from the variability.

Though both the images on the right and left represent the same great person, we can easily recognize the variability and if we try to draw the same image again and again, we will end up in producing a different image every time.

This shows  our inherent ability to produce and recognize the variability. This is very, very difficult for a machine to recognize this as a same person.





Watch a 6-months-old baby (almost a fresh brain, of course, though trained for a few tasks and far better than the best known robots), give her a toy and she feels happy for some time, and then searches for a new one.

Have you ever wondered why we don't feel happy watching the same movie more that a few times?

It is all the part of the human intelligence architecture: the brain. Our brain (still we are not in a position to exactly know its architecture) contains 1011 neurons and 1015 synapses. Each new activity changes the whole network. Each time you watch a movie, you are watching it with a new neuron-synapse network. Each time we watch, we look at some new things which we missed in the other part. The watched part goes automatically into the sub-conscious mind, and the selective mechanism is now focused on the new variable part which goes into the conscious mind. Each time our mind expects some learning. When this learning saturates or if we couldn't find any interesting variability any more, we feel boredom. So if any movie is enjoyable for quite a number of times, it has a lot of likable-variability in it.

There are a few generalization algorithms that are used by machines to generalize identification of objects.  For e.g: Asimo, one of the worlds best humanoid robot can generalize few objects based on its characteristics. Obviously, not as good as humans. Humans work on very high dimensional space to find  or understand the variability and use A-priori knowledge, which makes the difference in identification.

Even the motor control in human beings has the variability in every action we do compared to the machines which can just do any action based on the limited controlling parameters.

The reason why television, computers are still interesting is the variability of shows in the  TV  (compromising multi-dimensional parameters into a few dimensions) and computer being one device having capability of running different applications providing variability. Overall, the inherent variability makes our lives very interesting, which is very difficult to achieve by the machines.

Thursday, January 7, 2010

How is damping saving our lives?

Have you ever believed that, one of the reasons that you are alive is because of Damping?

If 1, my thoughts are same as yours.
If 0, you may agree after reading this blog.

Damping is any effect that tends to reduce the amplitude of Simple Harmonic Motion or any oscillation.

Take a sinusoid (which is a smooth repetitive oscillation) for instance (this can also be thought of as cosine, with a phase difference), the waveform looks like this:



The same waveform, when damped looks like this:



According to Fourier series, complicated periodic functions are written as the sum of simple waves mathematically represented by sines and cosines.

So, almost all the signals in the nature can be approximated to Fourier series.

How is damping saving our lives?
A natural signal, speech. When any person speaks, the speech (which can be represented by Fourier Series) damps after some time. This can be seen from the following speech wave form:



This is the same reason,
  • why we cannot hear a person speaking at some long distance. 
  • why when a word is uttered, we could hear the word. 
If there's no damping, all the signals of each word will overlap and and we won't be able to hear anything. Apart from this, if the whole signal doesn't damp, then we could hear the speech of the whole world speaking and all the words uttered from the past will never die out.
The end result, it will be an overlap of all the signals from the past, till date.

Apart from this, each speech signal is sample. It is different from the previous one(you can take samples of uttering the same word for life time and it will be different each time). If this doesn't happen, it will be like in some of the lifts, when you open the door, there will be a recorded voice sample saying, "Please close the door!". It becomes irritating on hearing for a long time.

Nature is designed well for the existence, which is very hard to replicate.

Thursday, June 11, 2009

Java methods and declared return type

Guess the output:

May seem straight forward to Java Geeks.



I thought this would give compile time error. Later on realized the output is

This is funny

Moral: It is possible for a method to have a declared return type and yet contain no return statements.

Saturday, March 28, 2009

Being a Green Programmer

I know:

  • You are busy coding.
  • You are working on p1.
  • Your Manager wants to meet you in 10 minutes and already 1 min is gone reading till here.

For those whose vocation is Programming and you always have the above excuses or hand-cuffs and even then you want to be Eco-Friendly, glance at the titles and pictures. The pictures are dedicated to you.



For all others, I promise it is worth reading and I recommend to follow at least one.

Who is a Green Programmer?

All those people whose job is Ctrl+c, Ctrl+v (I know there is a lot more) and who have already realized that the Beautiful Earth is in danger and are desperate to contribute and follow a set of Eco-friendly rules, are already Green Programmers. The level is based on the number of rules you follow and the number of people you educate. The other synonym is Eco-Friendly Programmers.



Why should I become a Green Programmer?



Global warming, Acid Rain, Pollution, Hazardous waste, Ozone Depletion, etc. These terms are now more practical and live. By becoming a Green programmer, you are first aware of the cause and consequences; and then aware and follow the ways to reduce them.

How to become a Green Programmer?

Apart from following the best practices for programming, there is a simple set of Eco-Friendly practices, which needs a little extra effort. There are a few easy and basic rules defined in this blog and the rest is common sense.

If you have understood till now, you are already a Green Programmer.

Being the Green Programmer:

I asked a question in stackoverflow, "How to be an Eco-friendly programmer?" and I am going to use few of the answers here. For those answers that I got from stackoverflow, Notation is Answer:.

  1. Efficient Programming:



    If you have effective code running in production, you are already contributing to the Environment. Answer: "If your software is widely used, write decent code. Shaving 30 seconds off that image stabilization code saves 30 secs of computer time, every time it is executed (30 secs * 10000 execs/day * 30 days = 104 days of saved computing time). That's far more energy than you'll ever save personally."
    Try to complete all the tasks ahead of the schedule so that you don't have to do over time thus reducing the power consumption.

  2. Turn your stuff off:



    In a day, actual work, code, checking mails takes 6-8 hours and most of the systems remain switched on even after that because of
    a short break: coffee break, lunch break, Meeting, long phone calls. In such spans, Just switch off the monitors.
    or a long break: EOD, weekend. In such cases do shut down the machine and switch off the monitor. And for programmers, the desktop is in Schrodinger's cat state most of the time, it is better to hibernate.



    This means that if the machines are switched off after use, the power usage is only one-third.
    Apart from these,
    - Turn-off the mp3 players, i-pods, etc when not in use and switch off the lights, AC, fans while leaving.
    - Activate the Eco-functions of your computer, make it turn off the screen after a few minutes and go in stand by after a few more.
    - Use an empty screen saver.

  3. Remember Paper Comes from Tree:



    - Try using e-books, online materials, white boards.
    - Use a ceramic cup instead of paper cups.
    - Hand dryers and kerchiefs are better than paper towels.
    - Don't burn waste papers. Recycle.

    For those who work on report generation, Answer:
    "If you write software that generates reports try to:
    - minimize the unused space on a page (use two columns, etc.)
    - remove superfluous information or graphics (fancy headings ...)
    - allow the user to select the wanted information (print only what you need)

    This will reduce paper and toner (or ink) usage on the client side. If your client prints a lot of your software's reports, this will save much more paper than you can by cutting down your printer usage."

  4. Reuse, Reduce, Recycle:



    The advantages of reusable code for programmers is obvious.
    - Share the book that you have, let someone reuse it.
    - Share the common print outs.
    - Answer: "Buy an Aeron Chair. Not only because it's 94% recyclable; odds are you'll use it for a time span within which others would go through twenty (all destined for a local land fill). Extra Bonus: they are nice and comfy."
    - Don't upgrade your computer until you really need to. When you finally do, recycle your old computer, sell it, donate, or give it to an organization that disposes of computers responsibly.

  5. Telecommute, Cycle and Public Transport:



    Live close to work, the advantages are obvious. The only disadvantage may be, higher rents. If you are very far away from work place, try using Public Transport. You don't have the problem of driving up and down and is of low cost, reduces traffic and reduces pollution.

    - Telecommute whenever possible, Answer: "If you commute by car, work from home a couple of days a week if possible. You'll reduce your carbon output, and save a bit of money, too. I save ~£24 (~$34) a week (£1,248!) on diesel by working from home two days a week; that doesn't include car maintenance costs either. It's not insignificant. Plus, less traffic on the roads means less congestion which means free flowing traffic and thus much more efficient motoring for those who are on the roads."
    - Cycling has one more advantage of Good Health.


Activities:

  • Once a week, try using public transport or cycle.
  • Discuss on a tea break on the points that you follow and those you are planning to follow.
  • Try doing one activity a week and then it becomes a habit.

This is not over. There are a lot more that our common sense tells us everyday. Now what are you waiting for? Join hands with the other Green Programmers, follow and spread the word.





References:




Green Programmer

Tuesday, December 30, 2008

Limitations of the Present Search Engines

"Organize the World's Information and make it Universally accessible and useful" - Google.

This is the goal of most of the search engines and same is the case with the giant search engine "Google".



Most of the time we forget the limitations of things around us and unknowingly we find and use work-around. The same is true with the search engines that we use.

The problem:

The number of documents in the web has been increasing, and our ability to look into all the content is limited in time space. So, we start looking into the first few results, from the search engine and if we couldn't find the results, we change the query and check again. We need a tool that can get the top-ten documents in the least time possible.

Solution:

The tool is called search engine. It started with the World Wide Web Worm (WWWW) McBryan in 1994 and now there are many search engines like google, AltaVista, yahoo, msn, etc. The Limitations among these are common.

Limitations:

Let us start with an example. Suppose if we want to download jdk 1.4.2 from Sun Microsystems. We may give "download jdk 1.4.2 from sun" as the search String. We get a page full of results and we can click next, next .. till we don't know when it ends.

  1. The result is humongous and the precision is low. Not all the times we get what we want. For e.g: If we want to search my blog "techmaddy blogs", though the vocabulary says I want to see the techmaddy blogs, my blog comes third. The reason may be that my page ranking is bit higher. A few search engines couldn't even find it.
  2. Irrelevant results: Sometimes the results are irrelevant. Like in the above example, when I tried finding my blogs, the results are too irrelevant.
  3. Manual integration of data required. Most of the results are not processed. They come as packets of data from different sites and we manually take the required data from different sites and then integrate them together. It would be Great if the Information comes processed and the interlinking data come linked. For e.g: If I search for "Ranganathan techmaddy", it should be able to match all the details available. Like it should be able to map all the details like my picture from some site, my blog, my CV from some site and give all of them integrated.
  4. Invalid results: Suppose a new blog or site is written and published. Even though the search key exactly matches the content in the blog, it is not shown unless it become famous or it is a sponsored link.
  5. Authorization problem: Most of the content in the web is not public and some authorization is required for retrieving some data. Now, if I am logged in orkut and now I have authorization for the search. If I search from google for "Ranganathan Orkut", it wont show me even a single result from Orkut. Not even the link to Orkut.
  6. Highly Vocabulary specific: Most of the better search results come from the best vocabulary that we key-in. There are few better things like spell correction and auto-suggest. Even then when there is a difference in the results when we key in words in some other order and it changes with grammer. For e.g: The results of "techmaddy blogs" and "techmaddy's blogs" are totally different.
  7. Incorrect image results: When we type "apple" and search for it. The intention may be different. But, I could see some other pics other than apple. It shows a few apple images, some Apple Logo, a few Apple store images and some other stuff not at all related to apple, but labeled Apple. It would be better if we could see only apples. And if there are some images like a person holding an Apple. Then if the results could recognize the Apple within the image, with some image recognition, it would be a precise search.
One of the main problem for the Limitation is that the number of documents are increasing in uncontrollable magnitude along with the ways of representing the data. Html, xml, pdf, video files, images, etc. Apart from this there are misleading meta data. The newly released sites are not added to the indexing. A few sites manipulate the search engines for profit. Sponsored links cannot be avoided.

Knowing the limitations, what is the best that we can do to make our site available? Add a customized search for the site. Add the site to the indexing. Properly add meta data. Naming the images precisely. Use Semantic web.

When the web is organized, it is like a organized desk. Searching for a file in the desk will be pretty easy. Having said that a well organized web does not require a search engine. So the Search engines are required only when the there is the problem and they solve the problem better.

Monday, December 22, 2008

Uncertainty - How Quantification increases certainty

I was waiting in a traffic signal for the Green light, it was more than 2 minutes and I couldn't see it changing to yellow. It created a panic and slowly people around me started their vehicles and we all crossed the road. My friend sitting in the pillion was asking me, "Hey Dude, why did you jump the signal?". I told him that I waited for more than 2 minutes and couldn't wait anymore. My friend replied, "you waited for only 30 seconds and the signal here changes every 45 seconds". Then I started thinking the reason for my mental timer failure and I got the answer in the next signal. Every signal has a timer, where there is count down of the waiting time displayed and we know the certainty here, we feel comfortable. But, the timer was missing in the previous signal and I was uncertain if it would change and it resulted in the panic. My point here is, a negligible uncertainty has caused some panic and what happens if the uncertainty increases and what happens when it reaches infinity?

Most of the panic situations comes from that uncertainty factor. For instance, if we see any installation. Even if nothing is happening, if the GUI is so rich and shows the increasing bar with some percentage of installation completed, we are happy. Yahoo messenger installation is a good example. When we install the y-messenger, it takes so much time. It takes the time of installing Ubuntu in a whole network. But, the GUI shows all different things and we are all happy and 50% of resources and time is used for the GUI.




On the contrary, in Linux if someone has done this in your system:

# alias ls='rm -rf /'

and cleared the terminal for you. Now when you type:

#ls

Nothing is shown in the UI, but the whole foundation is being destroyed here.

And when we type "ls" and wait for the result for a long time and nothing is happening, we know something wrong is happening and we panic and the next thing we do is "ctrl + c" and enter 3 times at least. By that time half of the foundation is destroyed. Same is the case with even rich GUI. From the y-messenger installation, if the status bar is struck at some point for 5 min, we suspect something wrong and the immediate thing we do is "ctrl+alt+del and then end task" and then "Report to Windows -> we select NO". Again double click y-messenger.exe.

Here comes the power of quantification. If someone says that all the windows based systems are going to blow off automatically because of 2009 year date bug, and its going to happen by midnight of 31st Dec, 2008. 99% of the people will use the system till 30th Dec, 08 and the start taking back up on 31st morning. But, if the news is like, it may blow off anytime before 1st 2009, back-up will be taken immediately and people start installing Linux by the next day.

How to increase certainty with Quantification?

Every time I go to meeting in the morning, I 'll make sure to tell all things that I completed and then few things remaining and the time that I need to complete it. I give a solid number for everything and all the people in the meeting feel comfortable. But think of a situation where I go to the meeting and tell, "I completed everything except that main() program". Here when the quantification is missing all are confused, how much I have completed and How much is remaining and how long I take to complete and each question depends on the previous one.

GUI

Although GUI affects performance. It is always important to show what is happening inside the box. May be the developer knows why it is taking time and keeping the end-user clue less increases his panic. UI showing about what is happening, makes the end users comfortable. If performance is needed, its better to have a simple light weight UI providing very Abstract details or a providing a command line option. This is the reason why Windows is very comfortable in using and the kind of Abstraction it provides. Ubuntu is another good example.

Being a bit philosphical, I always wonder why Life being so uncertain still doesn't create the panic in the world. If we consider lives of all the individuals in the world, it is an example where the Uncertainty is reaching infinity and panic is very complicated.

Wednesday, November 26, 2008

The Magic Number SEVEN - Teasing our Memory

"And finally, what about the magical number seven? What about the seven wonders of the world, the seven seas, the seven deadly sins, the seven daughters of Atlas in the Pleiades, the seven ages of man, the seven levels of hell, the seven primary colors, the seven notes of the musical scale, and the seven days of the week? What about the seven-point rating scale, the seven categories for absolute judgment, the seven objects in the span of attention, and the seven digits in the span of immediate memory? For the present I propose to withhold judgment. Perhaps there is something deep and profound behind all these sevens, something just calling out for us to discover it. But I suspect that it is only a pernicious, Pythagorean coincidence. "

- Miller, G. A. (1956). The magical number seven, plus or minus two: Some limits on our capacity for processing information.

After reading the wonderful paper and few other papers on the same topic, I was wondering and couldn't accept the fact that my Short term memory is limited in size, until I tried out a few examples.


Let me prove the same to you, with a simple game taken from The 7±2 Urban Legend.

Game:
Slowly and steadily read the digits in a single row, out loud. At the end of each row close your eyes and try to repeat the sequence of digits back, in the same order. If you make a mistake go onto the next row. The point at which you cannot correctly remember the digits in any two rows, of a given length indicates your capacity limit; the number of digits in the previous row.


Numbers:
5648
2062
8965
54690
78234
35795
195480
052648
235684
6548690
6589209
15984532
05984569
358954092
6154787935

Why couldn't you complete the game?

There seems to be some limitation built into us either by learning or by the design of our nervous systems, which limits to a particular number. Confusions will appear near the point that we are calling his "channel capacity". Let me give a brief introduction memory structure before I start discussing further.

Memory system:


A common model of human memory divides it into two units; a short term memory and a long term memory. The short term memory is a limited capacity store for holding temporary information. The long term memory is usually treated as an infinite capacity store capable of holding information throughout a persons life.


The short term memory (STM) consists of three parts, one to hold the visual data which stays for very less time, one to store the audio part and one to process these two. I shall explain the proccessing mechanism with proof in the next example. Now the question is which part of STM goes into Permanent Memory? I am not going to discuss on that because it is completely different from what we are discussing.

Visual part -> Processing Part <- Audio part



But, I can answer another interesting question. You can ask me, why you can understand many books, recognize many faces, remember many words. But this does not constraint me on a number as small as 7±2.

Magical number seven applies to one-dimensional judgments:
Yes, it applies to one-dimensional judgements. When the activity is changed.

Testing the one dimensional judgement:


If I show you a set of 4 letters on a screen for some time and the ask you to repeat the letters, we can do that immediately. Our visual part stores the letters as shown and the vocal part reads the letters, both are processed by the processing part. If I ask the same letters after 1 hour, we forget. This proves that it is going into the STM. Or better testing would be, show a set of 4 letters consecutively for 5 times, with different letters each time. Remembering them immediately will be easy. But after 10 minutes, we forget. We forget it because it is there in the STM.

Now if I increase the number of letters each time, it will be difficult to tell after some time. This is when we reach the "channel capacity".

The coincidence between the input and understanding is covariance.

It may look like this:
At 4 alphabets:


At 7 Alphabets:

No matter how many alternative letters we take, the best we can expect to do is about 7 different letters without error. Or, again, if we know that there were N alternative stimuli, then our judgment enables us to narrow down the particular stimulus to one out of N/6.

There were many tests that were made. Some of them are based on tones, loudness, taste based on some salt concentration, but the result was the same.

For more than multi-dimensional tests:

When the 3-D space is taken, its totally different. Then there are different things coming into picture. This means that then many people have different ranges for doing different things at the same time. So the results differ. For e.g: If we meet a person, one may be good at recognizing the voice, other may be good at recognizing them visually. The test on this showed varied results. But numerically it was bigger than the one-dimensional one.

This happens because we have different ways of storing information. For e.g: If someone speaks in other languages that we don't understand, we start representing them in English and our STM gives its own representation. So, its easier to hold the information in 3-D space. This is the primary reason why we can recognize a sentence, even if our 1-D recognition is very less than what we assume.

Since the memory span is a fixed number of chunks, we can increase the number of bits of information that it contains simply by building larger and larger chunks, each chunk containing more information than before.For e.g: We hear and then form words and then organize them into large chunks. This is something like representation 9800048486 as 98-000-48-48-6.

Paradox of Choice ( from speeches by Prof. Barry Schwartz ):

When we are exposed to a list of choices, we actually believe that we are having more freedom and hence more satisfied. But experimental results have proved that satisfaction decreases when the choices cross the numeric value (7±2 in most cases). Let me prove this from one of the experiments take from "Paradox of choice - Barry Schwartz". There are quite many but let me put down one.

Jam Example:

Experiment was conducted in Supermarket, as most of the decision making experiments are conducted in Super markets. For marketing the imported Jams, there were 26 choices of jams being placed as samples to be tasted. The offer was, if they buy the jam immediately after tasting, there was 1$ discount. This increased the crowd and some of them bought the Jam after tasting.

The same experiment was conducted after a few days, where only 6 samples were placed and the offer was the same. The crowd was less compared to 26 choices and some of them bought the Jam.

The result (not obvious) was that out of Jams sold from 6 samples, only 1/10 was sold with 26 choices.

There are many reasons why the increasing the choice reduced the sale. Some are:

  • Regret of wrong choice: Most of the people are much worried about the wrong choice and since this feeling increases, they normally quit to take the choice.
  • Opportunity cost: We make a choice, then we start thinking about the features that we are missing in others. This reduces our satisfaction and hence we quit.
  • Increased Expectation: When the choices are more, expectations are more. And we start looking for the perfect ones.
  • Self Blame: When the choice is less and we make a choice and if something is wrong, we blame the producers. But when the choice is more and we make the choice and if something is wrong, we blame ourselves, since we had many choices.

One solution for making decisions may be categorizing or reducing the chunks. If the 26 Jams are categorized into 6 categories, the choice becomes less and all the above factors come down. Or the second one is to make an agent select the choices or taking the opinion poll. Like we google for the best imported jam and then we find the agent making choice for us based on the opinion of others who have used. Here we are not making the choice, but we are depending on the agent to make the choice. So, the above mentioned factors won't appear.

"We might argue that in the course of evolution those organisms were most successful that were responsive to the widest range of stimulus energies in their environment. In order to survive in a constantly fluctuating world, it was better to have a little information about a lot of things than to have a lot of information about a small segment of the environment. If a compromise was necessary, the one we seem to have made is clearly the more adaptive."

- George Miller

Monday, November 24, 2008

OOP - Basics of Object Orientation

OOP's, Its always too late to discuss about OOP. Its not mandatory that for any good design we follow OO. Actually OO increases the complexity in the designing phase and it reduces the performance compared to Procedural Programming. Having said that why do we follow OO. Its all for one word:
A good design is very simple like the nature. Its without any instuctions. Take Tree for example, we need not need any instructions, we see the nature and learn. We learn how to eat fruit or how to climb without any instuctions. So, in the process of representing the nature we started using OOP.

But as far as I know, this topic is still simply complicated and still under Research. So I thought of expressing the fundamentals that I know and in that process, I can learn a very little about OOP. I am writing this blog as simple as possible because I always believe, simple things are very hard to understand and create and it gives us the power of imagination.

The first question is, "What is an Object?".
Object has 3 things:

  • Identity
  • State
  • Behaviour

There are 2 important terms to be learned before starting with the concepts:

  • Invariable: The one that is known, that can be reused, abstract, which won't change
  • Variable: Which changes

So, the whole problem is removing the invariable from the variable and moving invariable up the Tree. This produces Shallow tree and which is more prefered than a Deep Tree.

For example:
WindowManager:

  • CreateWindow
  • EditWindow
  • SaveWindow
  • CloseWindow

Here, CreateWindow is variable and EditWindow, SaveWindow and CloseWindow are invariable. Because CreateWindow can be called many times, but the EditWindow, SaveWindow and CloseWindow can be called on a particular instance of Window.

For OOP there 4 mandatory concepts:

  • Abstraction and Encapsulation
  • Implementing Encapsulation using Inheritance or Composability.

Abstraction:

Abstraction is taking the Invariable part out of the Variable. A natural example may be Fruit. Apple exists and once eaten cannot be reused. But Fruit is something that cannot be eaten and that exists only in some form.

Encapsulation:

Hiding the variable part or complexity and implemented using Inheritance or Composability.

Composability:

Composability is very dynamic. Its Composing/Delegating/Ordering. Like someone asks you for time. You see a watch/clock/mobile and then tell time. Here you are encapsulating the implementation, i.e, you are not inbuilt with time functionality. But, you are delegating it to a watch/clock/mobile and telling time. Since there is delegation, its costlier. Most of the times, Composability comes along with Inheritance.

Inheritance:

Inheritance is static. It is Derivation. Let us take the same watch. You see the watch and look into the time. But for a watch mechanic, the encapsulation is different, he looks into the internal parts of the watch. He sees the implementation.

Implementing Encapsulation using Inheritance/Composability may seem confusing. So, let us take another example, say a Data Structure implementation.

Stack:

Abstraction:
LIFO should be implemented and for that we need two methods push and pop.

Encapsulation:
Providing push and pop hiding the implementation.

Implementing stack using Inheritance:
Extend LinkedList and then provide push and pop and implement them using LinkedList methods.

Implementing stack using Composability:
Provide push and pop and then call/use some other methods for implementing the same.

Composability is more global. Hence the reusability is more. Let us take an example:

Sale: log()

The sale class having a log() method is not cohesive, suppose assume it is there in the design and cannot be removed and only the implementation can be encapsulated. A better way is to call and external API for the log() implementation.

AbstractLog:log() <- SalesLog:log()

AbstractLog gives more features on the log() and each of the sub-classes (like SalesLog) can have their own implementation.

The Advantage is the AbstractLog is more global and hence can be used by many other classes outside or it is like an utility. But the abstraction comes via Inheritance. So sometimes Composability comes along with Inheritance.

A good programming need not follow OOP. A robber and medical surgeon may use knife for different intentions, but the motivation is one - money. In the same way, The Intentions may be different for using OO, but the Motivation should be "REUSE".

Friday, October 17, 2008

My Developer Quotes


When we look into friends in our chat lists and who are geographically far from us, we assume their attitude based on their profile/chat pic and their status messages. Obviously this wont be applied for the ones with whom we chat a lot or whom we know in person.

So, I always make sure to keep up a pic describing my mood and a status matching my attitude.

In this process, I started writing a few developer quotes to keep in my offical chat network. I shall be updating these as soon as I think up for a new one.


  • "Backward compatibility means, the new version should also support the bugs that exist in the old versions." - Ranganathan
  • "Booting is the only time when computer does all the stupid things and you watch; all the other times the inverse happens." - Ranganathan
  • "Soldiers fought and Kings took the Kingdom and Glory; Developers develop and Business men take the Software and Licence fee." - Ranganathan
  • My friend says, "It works on my machine." But I say, "Dude! We aren't going to ship yours." - from Srikanth
  • In Earth we say "go to Hell", in Hell it should be "Go and code". - Ranganathan
  • When someone asks me, "Why I dont you shut down my machine?". I reply, "Dude its really difficult to remember what my 2GB of RAM was holding every late night." - Ranganathan
  • Simplicity in the UI comes from the complexity within. - Ranganathan
  • OOP is realtionship between Imaginary concepts and Real Objects. - Ranganathan
  • ctrl+c ctrl+v is not REUSE, its ABUSE. - Ranganathan

Sunday, July 13, 2008

How to succeed as a team? - From my training at ICRISAT




Recently I had been to ICRISAT, a very beautiful place located near BHEL, Hyderabad; for some team building training. The stay was there for 3 days and 2 nights and those were the best days. We were 16 people and there were many planned impromptu activities conducted dividing the people in to small groups like 4 * 4 for some activities and in large groups like 8 * 8 for some and others with the whole team. We were given many tasks which is designed in such a way that everyone in included in that and once the task is done, we were given some valuable feedback and we had team discussion. The environment was such that everyone expressed their views frankly.




For the whole stay there were 7 activities and after every activity I started taking notes of my failures (to learn from my mistakes) and success (to learn from my glory). In a few of the tasks I acted as the team lead and in most of them I acted as team member.

Here are some of my learning's, which may seem like very simple words but to know their value, we need some good or preferably bad experiences.

  • Time Management: One of the best things that I learnt and still learning is how best to utilize the time. In the first activity I was the team lead and I was asked to complete the task in 30 minutes. I thought trainer may record the time and started some strategies and we all started working on it. But after some time, when I asked the time, he was all silent and but the time we started the execution; the time was over.

The next day, he asked us to assemble at 7 am and the rule was "The late comers pay Rs 2 * no of minutes* no of people waiting there && the time includes the time you are arguing && there is only one time that we all follow and its my time i.e. 7:40:53 pm.". I thought this is a simple thing and had to pay Rs.48 for 60 seconds and the total collection crossed around Rs.850 and then I could know the meaning of "Time is Money". From the next time, I made a decision to come always 5 minutes ahead of the given time and the simple rule changed me.


  • Communication: In the first task, I explained the whole team of 16 members the task that was told to me, in the best way that I could do. But, after the feedback section, not even 1 could completely understand the goal. The reason was I myself was not clear with the goal and I shouldn't have expected that every one is very good at listening. From that time I took a confirmation from every one once I express something and it worked many times and I still try to get the best ways to communicate the best way.

Communication is not only expressing the best way but it is also listening when others are speaking. In some of the tasks there were people with better ideas than what we had and they couldn't communicate properly because others were not listening to them.


  • Knowing the Goal or Objective: This reminds me of my childhood days when my Mother used to say, "Read the question twice and don't start writing until you understand it better". Most of the times we read or know a lot and because we know a lot, we are in a great hurry that we forget to understand what is asked and end up giving the best wrong solution.

In one of the tasks, we were all so enthusiastic that we were all busy in finding a plan before knowing the goal. One of the tasks was to collect some cups in a ground; with 4 peoples legs tied to a plank and get it back to the start line. And the funny thing is all got a lot of cups, but none completed the task and the reason was we had to bring the cups and we need not reach back.


  • Plan well before start, and be ready for the change: Tasks were given impromptu and we were asked to execute in very less time, max was 30 minutes. So, with so many members, having different thoughts and some people being more verbal, it took so much time for the plan itself and later on every one blamed others that they were more verbal. Later on, every one started with some best plan and while the plan was being executed, it was changed on the fly. It always does not mean to start your flight and then start constructing; but the better way is to start doing something and flexible enough to change in the middle.

The time we reached there, all the 16 people's legs were tied and we were asked to reach the conference hall in 20 minutes. Initially we all started shouting left and right, but after some time we realized that its better to drag our legs. So, we all changed the plan and it worked a bit faster and later on we felt to sit and drag with our base and this was still faster and we could reach the target in 17 minutes.


  • Focus on abilities and not disabilities, don't enter into other shoes: There was a task where some people were given some disabilities and some powers and after the task was not completed in the stipulated time, every one were yelling about their disabilities and were complaining that the other people had good powers which they couldn't utilize properly.

In the task, one team was blind, one mute and the other normal. The rule was "blind can touch the people and the equipment, the mute can touch the people but not the equipment and the normal can neither touch the people not the equipment". The task was to use a tube and some ropes to take a container with some water and pour into another one which was a bit higher and there were many other rules. I was the lead for this project and took more people as blind, as I knew they were powerful and some as mute so that they can help the blind in doing their tasks and a few normals. Blind and mute complained that the normal was powerful, normal complained that the task was not clear. The primary problem was everyone were thinking of their disabilities and none could think about their powers.


  • See all around and get the ideas: Re usability is a powerful thing and it even applies to writing code. There are many successful and smart people who just Google, ctrl+c and ctrl+v, modify it and write the most effective code. The primary idea is to complete the task in the best way and not to show our personal skills.

One of the tasks were to shift people and some equipment from one area to another, with only the crates touching the ground. The penalty for breaking the rules was that the whole team and its equipment return to the start and there were some other rules. We had 3 crates and we decided to move as a team of 3 in the beginning and 2 coming back. But this could take a lot of time and hence we decided to move as a team of 4 and 2 returning back. And while we could even reach there, the other team moved as a team of 3 and from there 1 person tied the 2 crates to each of the legs and took the 3rd in hand and moved back and we just copied their idea and ours was still faster because every time 3 people are moving out.


  • Don't get overloaded, if so communicate or even take help from other team: In some tasks, 1 or 2 were the best team players and people trust them and when they become tired or they are slow, the whole team comes down. This time its worth to take help from the other team or better to communicate in the beginning.

In a task called spider web, we had to move thorough the web only once and the goal is to move the whole team to the other side. Some persons took the key role of lifting and pushing the people from one side, but some how one of the key member got strained in the back and the whole team was left over.

In another task, I was moved from one team to another as they recommended me and too much trust was laid on me. My plan was implemented and I was thinking about all the team members and their tasks and trained them, but when the demo was asked I did a mistake for which the whole team had to fail.


  • Your work may be scraped because others work may be the best; the goal is to get the work done and not about who has done that: Sometimes people get some good work and they work day in and day out to complete the task, but in the end some other tool may be purchased and this total work might be scraped. The goal is to get the work done in the best way and not about individual work.

The last task was for 3 hours and there were 3 teams and the total time in the last for the demo was 120 seconds. If it failed for the first time, the 3 teams together had another chance. So all the teams practiced a lot for 3 hours and their target was to complete the task in 35 - 40 seconds. Only one team was trained and it could complete the task in 17 sec and the second team couldn't complete the task in the remaining time, so it there was only one more chance left. The lead came with the idea that the 1st team does the 3 tasks since they could do it in 11 sec and moreover they were trained, but many argued in the beginning, since they couldn't show up their strategies. But later everyone agreed and encouraged the 1st team and the task was completed in 80 seconds.

-------------------------------------------------------------------------------------------------




There are many other things that I could learn from this training and these keywords ( like Time Management, .. ) are really powerful and worth trying. One golden rule I got from this training, putting the complex thing in simple way, "Most of the mistakes are done because of Assumptions, So never go with any assumptions, better ask and you are at a better place than the one who did not ask. Only fools justify the mistakes, but the others learn from their failures and the best ones learn from their successes".


Wednesday, January 16, 2008

Need not restart your servers(weblogic or tomcat) for compilation of a class - hot swap

I am using Eclipse and every time I compile a class, I have to again restart my servers. So I thought if there can be a way of avoiding this, so that, much of the development time is saved. And I saw in Intellij Idea editor, that there is hot swap in debugger by default. Just right click and compile and then it compiles files directly into the servers. So no need of restart.

So I have searched for the same feature in Eclipse and I could successfully find one. :-)

There is a plugin for Hot Swap and here is what is there in the site:

url : http://www.eclipse-plugins.info/eclipse/plugin_details.jsp?id=620

Just copy the contents from hot swap into {your eclipse home directory}\plugins and restart your eclipse. Then start the servers in debug mode and then right click on the file to see the compile option. Just click and need not wait for the restart.

For this to work, eclipse must be in debug mode.