31 January 2011

Can't Find a Better Leader, Be one

Often we complain that we are not able to find a perfect leader. The word perfect is the word that denotes excellence and such a leader cannot be found. Even found, the perfect leader never accepts that she is perfect as the excellence is not a destination. Let us come to the complain part. We generally tend to have a lower expectations and want the benchmarks to be lowered, tweaked until we get in. Once we get on board, we generally argue in favor of excellence and raise the bars. We clearly eliminate our roadblocks in the name of eliminating inefficiencies [that creates double standards]. Pretty weak way of looking either life or work.

How many times we thought that we have to be a better leader? We stop our thinking just with wanting to have a perfect leader. If you can't find a perfect leader, it doesn't mean that it can't be made, it just means that nobody has guts or conviction to be a perfect leader. Because, trying to be a perfect leaders hurts a lot and pains a lot as we need to work a lot and sacrifice a lot. The building cannot be raised without foundations and the leadership cannot be built without sacrifices. Sacrifice and see what happens. That is why people say, "the leadership starts with self".

If you haven't found any perfect leader in front you, go ahead and try to make yourself a perfect leader. The leadership is nothing to do with power/positions/designations and it is more to do with your virtue of thinking & action.

If Mahatma Gandhiji said, "Be the change you want to see", there has to be some reasons. :-)

30 January 2011

Java Threads - Why you can't start a thread twice?

Assume the following code
class Mythread extends Thread {
          }


          Mythead thread = new Mythread(); 
          thread.start(); thread.start();

Why you cannot start the thread (i.e calling thread.start()) twice? Why JVM panics when you do that?

26 January 2011

Why Loose Coupling is Strong Coupling?

Often, senior programmers insist us to have a loose coupling. In order to appreciate those words - "go for loose coupling", we need to understand what does it mean by loose coupling.

There is another good practice encouraged by senior developers which is modularity. Often, they want us to write function or methods which is just a screen's length (by the way for 14 inch monitor :-)). How can loose coupling be possible when you have modularity? When your application is highly modularized, you heavily depends on many modules to accomplish things.

The concept of modularity in fact leads to loose coupling. By modularity, we make a part of the code to do one critical thing. We don't want any part (or technically a unit) of the code to do two things. We want to restrict to a critical thing and by modularity we also want to hide the gory details underneath. When modularity is practiced in a structural programming, we tend to get loose coupling in a structural language/programming and when we follow right abstraction in object oriented paradigm, we get right loose coupling in object orientation. The modularity mean do one thing that is appropriate to the level of abstraction.

The loose coupling is not restricted to a specific programming types but rather has to be seen as a concept. The application of concept can be different in different programming language types like modularity, abstraction (having hierarchies of abstraction, each level of abstraction marries to a same level of abstraction to realize the functionality).

So, loose coupling helps us to realize strong coupling between objects but avoids tight coupling (which is a code smell).

What do you think?

21 January 2011

Paradigm Shifts - Function of Potential, Action and Time

Who is responsible for transforming an organization? Is it God, the organization itself, the CEO, the strategy that is penned by business leaders or who else? I don't think neither the God nor the CEO can bring about the change. The God or the CEO can only give you direction and can minimize intrusion. 

Before reading further, i would like you to watch the following video by Prof. C K Prahalad on leadership and my frequently viewed video.


What will you think when you see an egg? Will you think that there is a potential hen which again has the potential of creating billions of hens? Or will you just think about having the breakfast? Assume that a fresher stands before you. What will you think? Will you ever think that he is a potential CEO of your company and create so many transformation? Will you think that the guy who stands before you is manifestation of many paradigm shifts?

Paradigm shift is gradual, it takes time. It is zillions of consistent tiny improvements. All such tiny improvements make a transformation. Transformation is a function (product) of potential, action and time. When any of these is zero, the total transformation will be zero. There won't be any paradigm shifts without potential or action and there is no instant transformation (without time factor).

The guys who undergo transformation should keep an eye/heart on "potential and action" part of transformation and the guys who facilitate the transformation should keep an eye/heart on the "time" factor.



18 January 2011

On God and Religion

The belief of God has to be a personal thing - you follow one or don't believe it. For those who believe that there exists a God - you never saw Him, you never heard Him and you never follow what you believe He said you to follow. You will continue to preach irrespective whether or not God appears before you. God has to prove that he is God even if he appears before them. Quite materialistic. They just believe what they believe but not believe enough. If they learn to simply recognize Him, they will simply recognize God in them, you, me and anyone who stand before them.

Another view is the view of believers world. Believers believe that their portion of elephant is real elephant and they didn't explore other areas of elephant. The religion they portray is their perception. They are atheist with respect to other religions. The man has transformed this world a mess, even if God appears he would think to destroy this world rather than brining in order. The entropy is so huge now and tomorrow it will little more than today.

The state of non-believers is more pathetic. They never saw God and they tend to believe there isn't a God. They have a stigma that they are rational and they are so much glued to it like the believers. They may be rational but not rational enough. The rational thinking doesn't help to reduce the entropy rather adds to its growth. My three old nephew is so intelligent to believe that there exists a country called Canada and he believes that one day he will travel (just for sight seeing) to see places and in order to do that he has to study well and conduct well. It is the same belief that astronauts have on an alternate earthlike planet. If a belief gives you a good feeling, put you on the ethical orbit, makes you to find an inner piece, make you progressive and make you to handle uncertainty, you got to believe that it exists even if your cognition says the other way. The thing can be God or love or something else. Belief is superior than the fact. 

The belief shouldn't be a blind one and rational shouldn't too rational. The believers should learn rational thinking from rational thinkers and the atheists should learn the importance of belief.

The very argument whether or not God exists is insane and inappropriate.

16 January 2011

Emergent Behavior & its Role in Big Picture

A football team wins FIFA world cup, a society that is progressive, a complex software system that fails in field utterly, a strategic group fail to deliver a good strategy, a promising youth later turns out be a pathetic failure at later stage of his life due to his tiny compromises, a kid by continuous practice turns out to be a distinguished performer in arts by being passionate everyday. 

Let us see a software perspective.

Few years back, having a personal computer with 2GB of RAM is very rare and today it is common thing and so is parallel processing (particularly after multi-cores becoming a common thing). The sheer performance of the hardware has increased at least few folds. However, Microsoft Windows froze few years back and it continues to freeze even now. BTW, the freezing is little to do with MS Windows (but it plays a role). Most of the damage is done by the application developers.

Few years back, the developers used to think that we have 512 MB RAM and the part of it is ours (may be half of it). Today, we tend to think that 2 GB RAM is available in the system (as we give minimum requirements in our user guide or release note) and half of it ours. Our thinking doesn't change over a period of time. When we develop applications, we think that there will be few applications that will coexists with ours.

Let us assume that for a 2 GB RAM and 2 GB of swap, we think that at least four applications can run with each  consuming 1 GB of RAM. The math works perfectly well on paper and for the first few days until the processes grows up to 2GB (put together). Beyond 2 GB, the operating system has to swap some portion of RAM to disk. Once few pages are swapped, a method call or access to heap may lead to page miss and the operating system has to fetch the page from swap - an interesting complexity gets added. Due to this complexity, the time to execute an intended operation takes little longer which again may increase the time and memory footprint (as delayed execution delays reclaim of memory which will become eligible for reclaim if the program runs as per plan). This complexity grows exponentially until few process crashes or the system crawls and you decide to give a rebirth by rebooting the system.

But mathematically, we think that there is no problem with the parts (each process) but the entire issue is with the whole (the operating system and the processes put together). This is called emergent behavior. The whole exhibits a behavior that cannot be explicitly attributed to the parts and each part thinks that none of its behavior is responsible for the whole behavior. There is inherent complexity due to movement of parts, the environment and the processing of events that are external to the parts (and no way related to any of the parts).

This emergent behavior affects the operating systems, make climate change a failure or reason for human stupidity. Emergent Behavior proves that the software can be made with the same process that is used to make this universe and the same process can be used to attain spiritual enlightenment.

Think about how an image is formed. The image are formed using pixels. Does removing a pixel lead to disfigured image? No. The disfigure is almost negligible. So, the whole has a power than its parts due to the emergent behavior. People who talk about "the bigger picture" should focus more on studying "emergent behavior". Generalizing things from individual events can be done well by understanding this emergent behavior (and it actually helps not to generalize the exceptions).

15 January 2011

Importance of Expressiveness in Programming Languages

It is a while i had a post here and in fact this is my first post in 2011. I happy to have my first post of the year on the topic that is of huge interest to me these days.

Why aren't we still programming in assembly languages? The threads, inter-process communication mechanisms can be done in assembly language but not easily though. With assembly language, there is only level of abstraction - ability to see the requirements as sequence of bits that are comprehensible by the machine. When you want make your program to run in another target platform, you may need to change both the abstraction and implementation. The assembly language is not as expressive as procedural language. In order to increment a number, you have locate the address, move it to accumulator, add it by one and store back to the same memory location. There is no clear division of responsibility. You have more number of steps to do in assembly but that is very primitive in procedural language.

Why aren't we writing program with procedural language alone? Procedural language is less expressive than object oriented program. The amount of code that a developer should write to accomplish a logic is more in the case of procedural language. While the level of abstraction is moved a level up from the bare machine, still the abstraction is not efficient to solve a problem in application domain. As far as the application is concerned (and in imperative languages), a task is accomplished with side effects. You call a method and it changes the state of few objects. The data and operation have to cohesive. So, in application development it is highly essential that we glue the data together with operations because these operations are specialized over the data.

There are other types of programming languages like functional programming inspired by lambda calculus and one can write their own language for a particular domain. There is one basic commonality in all types of programming languages - they try to be more expressive to make the life of developers easier. For example, today many developers are thinking about writing concurrent programs not only due to multi-cores being prevalent but also due to modern languages that made multi-threading highly expressive. It is easier to write multi-threaded in Java than in C or assembly.

As we move on, we will see many more expressive language, expressive than Java world and it is part of evolution of programming languages.

The article was written after reading Grady Booch's "OOAD with Application" and first chapter of "Programming Paradigms". Hoping to bring few posts on the subject this year. Watch out this space.