My take on a Recent Interview…

I have seen a lot of interesting characters in both interviewers and interviewees. However, few weeks back I came across a conversation which forced me to write this. All this started with a very a simple/routine question

1. What is MVC?

Interviewee explained his understanding ( From my personal opinion, he was right and that’s what you can expect from average 4-5 yrs experienced guy in an ITES Industry). I’m not going to discuss this answer here because that’s not the intention of this post.

2. Interviewer took note of what he said and asked why do we need to all this, can’t I write everything in JSP itself and leave that?

Now, Interviewee explained JSP’s intent was not to write java code and it should just have HTML and other data should come from business classes, so writing all in JSP is not the rightway.

3. Interviewer doesn’t worry about the answer, he still went on what if I don’t bother about rightway’s, can’t I right them in JSP and work?

Interviewee thought for few minutes and asked this question back, If you start having all your BL’s in JSP’s, Don’t you think you repeat your code all around and also you are putting too much effort on client side which is not good.

4. I don’t know what made interviewer angry now, he said in a harsh tone that I will write an include.jsp and put all my code in that. What’s your answer for that?

Now, interviewee got angry and said that I won’t do that because that’s not a good practice from my as well as others point but if you want you can do that stupidity.

Then interview went for few more questions and candidate was rejected by interviewer as we all know.

I just tried to understand what was in Interviewers mind when he asked that question

1. He doesn’t want to select the candidate – Which is very remote given the time and effort taken by us to do the interview

2. He doesn’t know what is MVC or got lost in translation – Yes, there is a 50 – 50 chance for this but not always and from the way he asked the other questions, I think he is not lost at all.

3. He was thinking of a point for that question and expecting interviewee to say that as he knows – I would say this has a 90 – 10 probability. From my experience, this is what happens a when a half cooked guy takes interview.

Here, the problem is the Interviewer might know a valid point but he is not good in asking a direct question to get that answer. He took a longer router and finally annoyed the interviewee because from the outset almost all the answers given by interviewee is correct.

As the saying goes, all good programmers or not good Leaders, same will apply to interviewers as well.

Posted in Uncategorized | Tagged , , , | 2 Comments

Spring Security – JBOSS Compatability Issue

I have been working on a project which uses Spring 3.0 for all middle tier activities and JBOSS App. Server for deployment. In that, we encountered a weird issue while using Spring’s Security Implementation, everything works fine in the customer end where as in vendor place the site was not at all working if we include this security implementation, when we remove that and launch the application everything works fine. Since this is a intranet web app and used only for testing a huge data transfer we revoked the security implementation in vendor end and they were doing their job without any issue.

Last week when myself and on-site person decided to work on this to find out at the root cause of this issue. After around 4 hrs of head ache, we found that the entire issue was due to JBOSS Server, both of us are using 5.0 GA Release but the only difference vendor launched it in a Community edition (open source) where as customer launch from Enterprise edition. As soon as we change the server, everything works fine in both end.

I found this a weird issue from JBOSS. No where in JBOSS site, it has been mentioned that community and enterprise edition has different implementation and even the error message JBOSS throws doesn’t say anything about these things, instead it states some error in Spring’s Security XSD Schema. From this, we learn a lesson that whenever a tested piece of code doesn’t work on other end always check the entire software list used on the other end w.r.t every minute detail and then look into your deployment steps.

Posted in Java | Tagged , , , | Leave a comment

Value Round off in MYSQL…

For years, I have been working with number of SQL Databases where if u pass a value to a column which is more than what it can hold. Then, all we expect is to throw an SQL error message..

But this seem to break in MYSQL. I mistakenly created a session_id column with integer and passed System.currentTimeMillis() as its value. Whatever the value from time in milli secs call, session_id always will always this one value “2147483647”. I debugged my code for hours to check where this conversion happens and found it is not happening there.

Suddenly, I remembered that db column is of int datatype and System.currentTimeMillis() will return a long which could be the source of problem. Hence, I changed the column datatype to BIGINT, everything started working fine. After some exploration, I found that when a int column value exceeds it acceptable limit MYSQL will downcast the value to max possible allowed. I don’t know why it has been designed this way but whatever the reason is I call this as a strange behavior when compared to other databases.

If I got an SQL error or at least warning in the beginning, the mistake would have been corrected in the first call itself and saved hell a lot of time. Hope others will remember the issue when working with MYSQL.

Posted in Database | Tagged , , , , | 2 Comments

Casesensitive Issue in MYSQL

I bumped into a weird issue that my java web application is working perfectly in Windows box where as when I deploy that in linux it throws following error “dbuser1.table1” doesn’t exist.

After scratching our head for couple of hours I found that I created table with name as “Table1” in Mysql database where as in the code I called it as “table1” and that’s the problem. The weird thing is that it everything works fine if the database is deployed in Windows and all this problem will arise only with Linux.

After that I changed the code to access the table with proper name everything works fine. As I used this table name in more than one place it took more than 30 mins to search and replace all entries. So, whenever you have a possibility of linux deployment make sure you use a DBObjectConstants class for holding all database related object names and use that constant through out your application. In this way fixing these kind of issues will be more easier.

Posted in Database, Java | Tagged , , | Leave a comment

Nationalized Bank Norms

Last week I thought of buying gold coins for Akshaya Trithy. I spoke to a private bank and nationalized bank through phone about their pricing and found that its almost 500Rs lesser in nationalized bank due to various reasons. So, I decided to purchase from them and went to one of their branch around 3 PM, that’s where the shock came to me about their ridiculous procedures.

1. There is no one available in reception to guide me where I can find details.
2. After I found the appropriate section, the person in charge told they wont sell to credit card. How strange, I believe they still do business in 1970’s.
3. Now, the funniest part – I asked him whether I can purchase it by cash, for that he told bank official hours closed by 2 PM. So, he can’t help that way too.
4. Finally he said cheque would be ok but I should have account in his bank :). Isn’t it stupid?

Only good thing through out the discussion is that the person who explained all this to me is very polite in his replies and I believes he itself laughs inside on this stupid rules.

Finally, I’m forced to purchase from private bank and incur loss of 500+ Rs. I damn sure this would have happened to at least 100+ persons like me. Lets assume if they all purchase an average of 5 gms, then bank would have made a sale of around Rs.8L. From consumer point of view each of us might have saved 500 Rs there by 50k in total. I don’t know when the top mgmt of nationalized banks understand this and make appropriate changes in their norms to increase additional revenue. This would also make private banks to reduce their rates to become more competitive…

Posted in General | Tagged , , , | Leave a comment

Commonsense Prevailed

Everyone in India know what was the talking point for last 2 weeks. IPL, Should it happen in India or not. Almost all the papers and news channels had a coverage on this during their prime time. At times, they gone overboard too. During this period, I read an article in one of the leading English daily which is just upto the point. Its written in a manner that no one can feel offensive about it. The message it conveyed was “IPL Should be either played later or Out of the country, It should not be allowed to clash with the General Elections, As it is the top priority for the country”. I read some other articles too that conveyed the same message but they unnecessarily try to tarnish the image of few individuals linked with IPL. We all know there is nothing called “Free Lunch” in this world, then why unnecessarily pointing fingers to IPL stating they care only about Money and all. Why don’t we understand that IPL is a business run by entrepreneurs, all they look for is balance sheet at the end of the year to view its profit/loss. If they don’t do that, other stake holders will hold them responsible for all the mishandling. For them, staging IPL is much more important than anything else. This is pure commonsense, I don’t understand why most of the article writers or chatters in talk show don’t understand this…

I had a feeling right from the beginning of this episode that IPL will not be staged in April-May because government was pretty clear on its message that it cannot share para military forces for security because of general elections. So, all this unnecessary barking has just increased the ratings for prime time shows rather than anything else.

I felt really happy that at least one writer’s Commonsense has prevailed and kept his writing just to the point and not to anything else.

Posted in General | Tagged , , | Leave a comment

String Concatenation

How many times you heard reviewer saying that stringbuffer should be used for all string Concatenations. I did this everytime when I use to review others code because I feel that will improve performance. Couple of weeks back I read an article which totally changed my thought on this, I never believed what it said initially but I tested that by myself and found thats really true..

Lets take this example

Code 1
String a = “Test Concat” + “Test Concat” + “Test Concat” + “Test Concat” ;

When somebody reviews this code they will say it should be change like this

Code 2
StringBuffer buf = new StringBuffer(50);
buf.append("Test Concat").append("Test Concat").append("Test Concat").append("Test Concat");

Because, this will redunce the no. of internal string object creations and that is quite true.. However, today’s Compilers are really smart they will internally change the line mentioned in code 1 to code 2 during execution. So, even if the developer does this mistake it will be corrected by the Compiler.

Only place where Compiler will fail to this, if the Concatenation happens in loops like this

Code 3
long stTime = System.currentTimeMillis();
String str = "";
for (int i=0; i<5000; i++){
str = str + " Test Concat";
System.out.println("Time taken -->" + (System.currentTimeMillis() - stTime) + " loop concat " + str);

Here ‘n’ no of internal string objects will get created and then appended to the base string. Hence this piece of code must get changed to

Code 4
stTime = System.currentTimeMillis();
StringBuffer strBuf = new StringBuffer(10000);
for (int i=0; i<5000; i++){
strBuf.append(" Test Concat");
System.out.println("Time taken -->" + (System.currentTimeMillis() - stTime) + " loop append" + strBuf.toString());

This will significantly improve the performace… This is what the time it took on my local machine

For Loop value 5000
Code 3 : Time taken –>594 ms
Code 4 : Time taken –>0 ms

For Loop Value 10000
Code 3 : Time taken –>3266 ms
Code 4 : Time taken –>15 ms

Points to remember:
1. Whenever there is a string conactnation in loops change that to Stringbuffer/StringBuilder, because here it will improve performance
2. Always write String Concatenation code using StringBuffer or StringBuilder classes, because they fall into good coding practices and we are not depending on Compiler’s Intelligence level to cover up our mistakes…
3. Being said that, there is no point taking up a excercise of clearing all general String Concatenations done so far in 10000 line code base maintanence project and changing that to Stringbuffer. This will not add any major improvement to your performance issues. This can be taken as a excercise but not a high priority one as some might think.

Posted in Java | Tagged , , , , | 1 Comment