Understanding of problem

This topic came to my mind in meantime of resolving linking problem on Linux. When I build dynamic library my app missed some of the symbols. 

And no I didn't forget to compile *.cpp file which contain it. If it was so easy I wouldn't spend hours on resolving it. But this won't be topic of this post. The topic is about understanding of problem that we try resolve. I talking especially about this weird situations when something happening and we don't know why.

I know different schools how to deal with this hard problems :] 

Conclusion 1: It's for sure not in my code. 

And this issue wasn't in my code :]  I didn't believed that this code was wrong from start. It was my fault for sure. Question only where. 

Of course I'm not always was this way. In my younger days very often after hour of searching I were deciding it's for sure not my fault. Of course in 99% of time I was finding out later that I was wrong. Well privilege of being young.

Conclusion 2: Let's shuffle code and it will work.

Not literally but point of this is to do some change which we think will fix issue but we don't understand why. After this we run application if it work we are happy. To give example we have crash in application because of NULL value so we add check if it is null.

Sadly this way of resolving problems is one of the worse I can imagine. There is nothing worse than changing randomly code because we try to resolve some issue. This is just bad idea because very often this "fix" hide real problem. With time passing finding steps to reproduce it became harder and harder.

Conclusion 3: Let's understand what happening.

I think is the best solution but have one bottleneck: it consume time. But I will add from my experience: that very often it save time later. Issue is resolved properly, we understand what we done to make it work and finally if it will reported again most of the time it's some other problem.

Conclusion 4: I understand what happening but don't know why.

This is my current situation where I know that my issue is because of linking of static libraries (*.a) inside dynamic (*.so). Static library missing virtual table symbols because one of virtual function is not in the same *.cpp. So I know why this issue happen I expect that there are some missing flags of linking to resolve it. I just need to find which one :]

Summary

Of course all this sound easy :] but its not. There are situation where you need to do null check because there is no time. You need to ship something in hour and there is no choice. Of course good approach is to look into the problem deeper after sending build to find real issue.

Other thing is that life showing that sometimes problem is really in some external library or not your code. This happening but still safer is to assume that you done something wrong. And if you really don't know what you could do wrong prepare some solid test case and contact person responsible for this piece of code.

Finally, approach to understand problem is not something we are born with (in most cases). This is for sure not the easiest way of dealing with problem and we need to put a lot of effort into it. But with time it start to being natural approach which bring only benefits.

Greg

Comments

Popular posts from this blog

Query commands execution

W.U. 0x20

Lets play : Good code / Bad code