Thursday, January 24, 2008

Easy solution on complex problem.

We call this "elegant solution". It is obviously very hard to achieve. One example of "Do things easy way" will be a book "The C programming Language by Ritchie and Kernighan." Reading this book several times is recommended. This thin book brought me new things each of three readings so far.
I admit that I used to be a spoiled programmer. "Jump on to the code without thorough thinking, busy in applying modern buzz worded technologies, proud of solving problems harder way than it supposed to be. Threaded, J2EE chasing, Fancy message passing methodology over MQ systems, Application Servers,.." Name it! I have tried many things on a lot of topics. Right, buzz words make my solution look fancier.
I remember a team when I was in AOL. It was my favorite team in my career so far. The team was handling 5000 servers directly, more than 15000 indirectly. To tell the truth, the best people that I remember are all them. Their solutions were very elegant. Berkeley DB was used for distributed storage. Socket was used, but home grown message router is involved in. No wonder that message router does not use any buzz word. Non-blocking IO is essential because of massive data size. But, most technical topics were pretty simple and basic. Only exception was Java WebStart. Grapher for analyzing data was written in Java Swing and it is distributed by webstart. That was convenient.

Elegant solution comes from thorough understanding of 1)nature of the problem, and 2)considering permutation of many possible subsolutions. Sloppy engineer doesn't have room to think alternatives. But, real guru can draw a complete solution in brain without touching a keyboard. And he enjoys several pictures of solutions and choose what will be the best. In this case, when he is using "global variable" (ah.. inevitable evil...), this really brings more convenience than complexity, with complete control. One example will be main() and PostmasterMain() of postgresql. It is beautiful piece of code.

Again, architecture is the key thing to make solution elegant. Do not just rush for a solution. Prepare a big chunk of brain for a complete solution. Key capability will be memory... Yeah. This is the train that I need to go for near future. Either I become a code monkey or I grow up as an architect. Things are not impossible. The best people that I remember are also 'human beings'.

No comments: