You are currently browsing the tag archive for the ‘Java’ tag.

We narrowed down the reason causing our app to be really really slow to one of the methods where it extracts and returns contents of files under a directory. After some printlns of how long each step is taking, it turns out the culprit is Java I/O. The previous co-op used RandomAccessFile to read the file content. Why? I am not sure. He was checking if the file has the correct number of lines, then going back to the beginning of the file and reading the content. Without RandomAccessFile, the file pointer can only move forward. Hence it’s can’t go back to the beginning of the file after it reaches the end.

So I changed the program to use BufferedReader, and check the number of lines as the content is read. The result? 1 second to read ~70 files instead of 40 seconds with RandomAccessFile.

While I respect the students in other Engineering programs applying for Software jobs, but the employer should be very careful in their selection. I still remember the mess I was going through to refactor the spaghetti code at the beginning of the term. In fact, this shouldn’t be targeted at non SE/CS applicants, it should be applicants who have no idea what they’re doing. It’s much more destructive to have crappy code than have no code at all. At least the next person can start fresh.



Flickr Photos