Monday, December 24, 2007

How to write maintainable code

On the contrary, do you really want to write a maintainable code ?? Which can be maintained by anyone - that makes you eligible for being jobless !!

So better be safe and write the code which can be maintained by YOU so that it helps you to save your job :D But don't go too far which can cause the complete program to be rewritten . (and you will not get second chance to do it !!)

Don't take that seriously, I hope you understand what should be DOs and DONTs. !!!

I remember, we had a teacher for AI (Artificial Intelligence) who has different style for teaching. He starts with a wrong statement and convince everyone that he is correct. Finally when every one is with him, he tells that he was bluffing and tell you the points that you missed to prove him wrong.

In one of such class, he made a statement that every question can be answered as "yes" or "No". But by that time student understands his style !! So one of the student question him asked whether he can answer his question in "Yes" or "No.
Question was simple- "Have you stopped beaten your wife ??"

On the same note, here is a nice article on "How to write maintainable code" which teaches DONTs by saying it as "DO it".

Saturday, December 15, 2007

NP and Weirdness!

I just feel very weird about this whole NP class of problem. They are so many problems belonging to this class of NP and yet there are all the same. I can take one NP complete problem and can reduce that problem to another NP Complete problem in polynomial time. To quote that in plain words, If I have the algorithm to solve one problem, I can use that algorithm to solve the other NP problems. I just have to convert one NP problem to other in polynomial time! Even more weird is this thing: There is no known best solution for this problem. And to make things even more weirder, though there is no known best algorithm to solve this problem, but given a solution we can verify its correctness in polynomial time. That is, If you give me a solution to this problem, I can verify if the solution given is really a solution to this problem. That too, I can do this verification in polynomial time.

These are not the only weird things about NP class of problems. There are lot more. There is no known proof which either proves or disproves NP is equal to P or NP is not equal to P. But still any computer engineer will say that NP is not equal to P. If you ask the reason, then he will say if NP is equal to P then there should be a way to solve the NP problems in the order of polynomial time. What does this mean? It just means that a computer engineer's ego wont let him accept that he doesn't know how to solve these problem. So, he just says there is no best solution for this class of problem because he can't find one!

Isn't it really very weird?