Wednesday, September 26, 2007

WebSpider Improvement

Thanks to the two days extension, now I am finally able to finish this assignment. I improved my program so that now it can perform all the tasks, although I am not sure is it performing it correctly since there is no official correct answer. My source code can be found in here.

My external resources were mostly from my classmates’ codes and the discussion from google group, especially the ones from Jared Sunouchi and Ka Yee Leung. Also, the test website created by Randy Cox was very helpful. I could have a general idea of whether I am doing the correct things or not.

During the time I tried to accomplish task 2, I found out that finding the most popular page and finding the total number links share a lot of same code. I tried to merge these two methods together, but these methods return two different types of values, which is troublesome to fix. Therefore, I kept them separated. For the task 3, the java logging package turned out to be easier to use than I expected. It is like a more sophisticated System.out.println. I think I will start using it more for the later programs in this class.

The QA tools’ testing was ok. However, findbugs and PMD sometimes will report error that is counterpart for each other, which took me a while to figure out a solution. For the Emma, I only got the 100% coverage for classes and methods level, but I think that should be sufficient since the JUnit tests were mostly written to satisfy the coverage in Emma, they did not guarantee high quality codes anyways.

Overall, this assignment is very challenging. I feel lucky that I could have the extension to finish it, also thanks to my smart classmates. Their clever ideas have helped me a lot in this assignment.

Monday, September 24, 2007

WebSpider

This assignment is the first ICS class assignment that I could not finish. It is so difficult that I could only finished task 0, and I only partially finished the task 1 such that it could find out the number of links found in the crawling, and this was heavily inspired by Jared Sunouchi's code. The link to my code can be found in here. There are several problems that prevented me from accomplishing the tasks.

The first problem was the JUnit test for the main method. Since there is no test that works for type "void", I had to construct some dummy tests to just satisfy the JUnit and Emma. Although I got 100% coverage, I obviously do not consider them as effective testing. I think I still need to learn more about JUnit to write high quality testing.

The second problem was invoking the program using command line arguments. This really threw me off because the hyphen of some arguments, such as the one for "totallinks". I thought it would be a parameter to invoke the program to perform a specific task, which I totally did not expect it to be an arguments for the main method.

The last problem, which was also the most difficult problem for me to finish this assignment, was the implementation of a web crawler using httpunit. I never write a web crawler program before, thus it takes me a long time to try to figure out a recursive method to find the total links. Disappointedly, I still ended up using an iterative method. The usage of httpunit added more harshness to this task. The relationship among the classes, such as the WebConversation, WebResponse, and WebRequest is still confusing for me.

Since I am not able to completely finish the task 1, my attempt for task 2 was not successful. I could have done task 3 using System.out.println, but I did not do it since it is not efficient and not elegant.

The most important lesson I learn from this assignment was not to procrastinate. It would be much better that if I could start this assignment early, and it also would be more helpful that I could post question early on the discussion page. I could not even get to this far without the help from my classmates.

Monday, September 17, 2007

Stack Program with QA Tools

I have completed the five assigned tasks successfully. The program zip file is hosting in here, and I also uploaded the reports for the different QA tools: Checkstyle, FindBugs, PMD, JUnit, SCLC, Javadoc, JavaNCSS, Emma.

There are several problems that I ran into during this assignment. First is the installation of the QA tools. Without the easy setup.exe or install.exe files, it took me a while to figure out how to correctly setup the environmental variables to install these tools. Luckily these tools all have good documentations, so this problem was not a big issue. Second problem is the confusion caused by the shared output directory of eclipse and Ant. It bothered me for quite a while, but Professor Johnson helped me solve it very quickly. It was not that bad either. Last problem is the XML build file for the JavaNCSS, which I still not fully satisfied with my current compromising solution.

The XML format used by the Ant is quite confusing to me, since this is the first time I encountered the XML scripting. Although there are some tutorials available online and I got some helps from my classmates, I have not found enough information to solve my problem elegantly. More specifically, there is one checking that I wanted to make sure the presence of JavaNCSS in the system, but it involved of checking multiple files. The checking that I know how to use can only check one file at a time, so I ended up with doing three checking, which I believed is not the best solution. However, due to the knowledge I have for XML and Ant, as well as the time limitation for the assignment, I could not come up with a better solution.

In terms of my impression to Ant, I think it is a really powerful build tool for Java and it is not terribly hard to learn. Although it would be much nicer that Ant can provide a better GUI for novice user like me. The motivation of using all these QA tools seems to be very reasonable and convincing, and I even think there should be a more universal standard for these QA tools to help programmers to focus on coding rather than focusing on problems like integrating different modules from different platforms, which sometimes consume a lot of time. As for the counting tools SCLC and JavaNCSS, I personally like JavaNCSS more simply because it provides a very friendly GUI mode, which is easy to use. Also I know more about JavaNCSS now since I spent quite a bit of time writing its build file.

In a word, this assignment provided me a broad overview of some popular Java QA tools, and it is very beneficial to build up my knowledge of software engineering.

Wednesday, September 5, 2007

Code Ruler Redux

We have made several improvements to our Code Ruler program. The result turned out to be quite well, and our ruler now stands a higher chance against the Split Up Ruler. The source code can be found here.

The first improvement is the movement of the peasants. After several modifications of the code, we are finally able to move the peasants in a more effective way: now it will not move into the already-captured square whenever is possible. This is the same idea we had before, but the old code did not work correctly. Also, we got rid of the center-moving of the early peasant movement, since it is only a compromise strategy for the old incorrect code and it is no longer needed.

The second improvement is the strategy we used for the knights. Since we found out that capturing castles does not give points, and our knights would only end up trying to capture the castle, we decided to change the targets. We assign the knight with an arbitrary target, which is not necessarily a castle, and we make the knight tries to capture anything that is on its way. This is a much more aggressive strategy, and it seems working well.

The last improvement is the coding style. We changed indentation to two spaces, added spaces and curly braces for readability, etc. we have tried our best to match the standard Java style.

Saturday, September 1, 2007

Code Ruler Review

I am assigned to review Marcius and Ka Yee’s code. Their code does not have many violations of the Java standard, and I am a little surprised that they are actually using the two spaces indentation. Here is a table of the violation of their code:
FileLinesViolationComments
MyRuler.java92,152,158, *EJS-76The “if” should always has curly brace
MyRuler.java106,136EJS-5The “else if” should be on the next line
MyRuler.java124EJS-61Avoid the use of end-line comment
MyRuler.java9,149EJS-6Comment longer than 100 characters
MyRuler.java79,97,129ICS-SE-JAVA-9Prefer using for/in structure

I like the idea how they split up the knights into two groups, which is similar to the built-in split up ruler. Also from the result of their testing, it seems this strategy has worked quite nicely against the built-in ruler. Overall this is a nicely written code.