Saturday, April 2, 2011

Top Ten Errors Java Programmers Make

I found a wonderful article while I was tracing an error in my code. Here is the article Top Ten Errors Java Programmers Make. Can you believe, I did the number one error among the listed top ten errors!!! :(

According to the author, Below are the top ten mistakes that java programmer do while they do coding. So look at them and stop doing the same error again and again :)

10. Accessing non-static member variables from static methods (such as main)
9. Mistyping the name of a method when overriding
8. Comparison assignment ( = rather than == )
7. Comparing two objects ( == instead of .equals)
6. Confusion over passing by value, and passing by reference
5. Writing blank exception handlers
4. Forgetting that Java is zero-indexed
3. Preventing concurrent access to shared variables by threads
2. Capitalization errors
1. Null pointers!

For details, please visit the original article.

Happy programming!

Thursday, March 3, 2011

Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack

Suddenly I am getting the error "Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack" from my asp.net application. After spending sometimes online, I found the following cause and solution for the error. Hope the solution might help you, if you are facing the same problem.

Error: Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack

Cause: If you use either Response.Redirect or Server.Transfer method, you may face this problem. I was calling Response.Redirect method inside the Try...Catch block. This happens because both methods call Response.End internally.

Solution: Pass "false" to endResponse parameter of Response.Redirect method

Response.Redirect ("xyz.aspx", false);

Thats it. Simple.

Happy programming!