Thursday, November 15, 2007


Group viewed: MyIsern-Purple

Installation Review:
The installation is not as smooth as previous projects. First failure is from the String.isEmpty() which is not supported in Java 5. I will have to keep fighting with this problem untill Java 6 for Macintonsh released. Then when I importing it into Eclipse, the buildpath fails. However, it is not difficult to fix and get the isEmpty thing fixed for me too.
Then PMD and Checkstyle run successfully. But the JUnit test fail. The first problem for its failure is because their working directory's name is different from project distribution directory's, which included the "purple", and the project then is deployed with the name myisernweb-purple. Therefore, the test get a 404 when accessing the page. After fixing this, 4 tests still fail, HTTP 500 are reported. In tomcat there are 2 exceptions pop out when tests fail. These may be some real bugs, but I did not see into the code to find out what is happening.
The installation clear enough for me to get the software run.

Code Convention Review:
Some unused private variables and methods are reported in Eclipse, which might be historical remaining.
Some class share a same java doc, which is probably copy-pasted.
The most important violation is that the class Id implements a raw type Comparable, which is highly not recommended in Java 5. The right interface should be Comparable. and then the compareTo method will take a String as parameter rather than an Object.

Test Case Review:
First I notice that the EMMA's setting is not correct that takes jaxb class into coverage comptation.
The test cases are far from enough. As reported in EMMA, most methods in ActionBean are not tested, and only 66% methods in model are tested. I am not sure if the coverage is effected by the failures in JUnit test.
One bug I meet is when click save with name field empty, the system will end up to an exception.

User Interface Review:
The user interface is pretty good! Not only the functionality, but the appearance. In researchers page, there are picture in front of each person. When adding/editing new researcher, I can easily choose an existed organization from a drop down list, or create a new one. In collaboration editing page, years and organizations can be selected from multi-select field.
However, one important function is missed: delete objects. Objects cannot be remove once being added.
The affiliate researchers field is missed in organization editing window. Maybe authors thought that is should be determine by researchers' organization. But there are no view page available, so I cannot see an organization's affiliate researchers by any means.
Though using multi-select field to deal with multi-value field is really a good idea, it will become hard for user when selections become numerous. When using last assignment's data as input, there will be tens of organizations in collaboration's selecting window. However, I don't have much idea of how to do it good, and this approach is actually the best I have seen so far. But I think it is necessary to figure out some better way to do it.

MyIsern-Purple's 1.3.1114 distribution is overall amazing, in consideration of such a short develop time for it. I do see many things useful for my project in it. I am more convinced that user interface is significantly important. This application's functionality is better than mine. But when looking at its nice pages, I do feel that my application is not comparable to this one.

Saturday, November 3, 2007


1. Explain in your own words the meaning of the web "request-response cycle".
A: User request a page by clicking or some other means. The brower prepare the request and send it to the server, then receive the response from server and show in to the user.

2. Explain how servlets facilitate processing of the request-response cycle.
A: Servlets are able to generate page dynamically, so that the server can return much more different pages accordingly, without storing them beforehand.

3. How do you login to the Tomcat Manager?
A: I access my Tomcat page from http://localhost:8080/, then click the Tomcat Manager on the left to login, with username and password.

4. What is the Tomcat Manager used for in the StackStripes application?
A: Through Tomcat Manager, we are able to deploy our StackStripes without stopping the server.

5. What is the directory and file layout of an installed web application like StackStripes? (This is NOT the same as the directory and file layout of the StackStripes distribution!)
A: the web applications are installed in $CATALINA_HOME/webapps. Inside each application's directory, there is a directory called WEB-INF, where stored the code of the application.

6. How do you build a war directory structure in Ant? Where is this accomplished in the StackStripes application?
A: We build it using war task in an Ant target. It is done in build.xml, in the target "war".

7. How do you install a war directory in a running Tomcat server? What information does the Ant task need to accomplish this?
A: By getting this page: http://localhost:8080/manager/deploy, with argument path and war.
Ant need the host's address, the system name to generate the path, and the war file's location.

8. What is the "Model2" architecture? What are its advantages?
A: MVC contains 3 part: Model, which run web application, access database and generate the response page; View: whatever you see in your browser; Control: connector between Model and View, process user's request from view, interact with Model, and return the page to be shown next.
Its advantage is separated program logic from user view, so that it is much easier to modify and maintain the web application.

9. What are JSP pages? How are they related to servlets?
A: JSP is a page that contain static text data such as HTML, and dynamic content such as scriptlets or stripes elements. It can generate the proper page according to user's interaction. JSP will be compiled into servlet when first time it is requested, and recompile later when needed.

10. Why is there a delay when retrieving a JSP page for the first time? Where is the Java code for that page stored?
A: Because JSP will be compile into servlet for the first time retrieving. The Java code is stored in server.

11. What are JSTL tags? Why are they useful? What is an example JSTL tag from the StackStripes system?
A: JSTL tags are a kind of xml tag in HTML to implement some kinds of functionalities. They are useful because of their simplicity, which enables people other than Java programmers to modify the code. Example JSTL tags in StackStripes system are:

< c:foreach var="element" items="${actionBean.stackIterator}">

12. What are Stripes tags? Why are they useful? What is an example Stripes tag from the StackStripes system?
A: Stripes tags are tags that present functional framework that defined by Stripes. With Stripes tags, we are able to separate the Java control codes from JSP pages. All Java codes can be put in Java classes and called by Stripes tags.
Example Stripes tags in StackStripes system include:

< stripes:form id="PushForm" action="/Stack.action">
< stripes:select size="1" name="numToPush">
< stripes:option value="1">1
< stripes:submit value="push" name="push">

13. What is HttpUnit? How is it different from JUnit? Why is it useful? What is an example use of HttpUnit from the StackStripes system?
A: HttpUnit is a testing framework that emulates behavior of browser to test the function of web sites or web applications. Unlike JUnit which is a unit testing framework for all java programs, HttpUnit is focus in testing web applications. It makes it possible to verify web applications or web sites by automated testing.
An example in StackStripes system is :

WebConversation conversation = new WebConversation();
String Url = testHost + "stackstripes";
WebResponse response = conversation.getResponse(Url);
assertEquals("Checking index.jsp retrieval", pageTitle, response.getTitle());

which check if the page is retrieved correctly.

14. What needed to be changed in order to implement the Double It button? What didn't need to be changed? What did you learn about the MVC design pattern from this exercise?
A: I need to add a stripes:form for the Double It button, and all other things remain unchanged. MVC is very facilitated to use, as simple as to add a method in a class.

15. What are the equivalence classes that need to be tested for the Double It button?
A: empty stack and stack with some elements.

16. Provide two screen images of your new StackStripes application with the Double It button, one showing the page before and one showing the page after hitting the "Double It" button.
A: before:


17. What is the singleton design pattern? What is an example of its use in StackStripes? Why is it needed?
A: singleton design pattern is a design pattern that ensure there is only one object of the class in runtime. In StackStripes, a static instance is defined, And the construction method is private so that users can not call it to create a new instance. Also, there is a getInstance method serve as the function as constructor, which always return this static singleton instance.
We use it because we need to ensure that users are interacting with the same instance wherever the open the page.

18. Some of the StackStripes tests exercise code on the "server side", while others exercise code on the "client" side. Which test classes exercise code on the "server", and which exercise code on the "client"? How does Emma deal with this to create appropriate coverage data?
A: Tests in TestStackModel exercise codes on the "client" side, and tests in TestStackActionBean exercise codes on the "server side". Emma track the running code in server side and put those data in However, emma has to stop the server to make that file finalized onto disk so that it can be read to create appropriate coverage data.

19. Running 'ant -f' results in the following target invocations: tomcat.check, tomcat.undeploy, compile, war, tomcat.deploy, junit.tool,, junit. Explain what each of these targets do.
A: First, tomcat.check target checks if tomcat is running and can be access properly. Then, tomcat.undeploy target undeploys the existed web application in the server. After that, compile target compiles the java codes and war target packs all web files into a war package. Then tomcat.deploy target is called to unwar the war package and deploy the web application onto server. After deploying, junit target awoke junit.tool and targets to run the unit tests in the web application and generate an HTML report of the JUnit tests.


Source code:

Thanks to the reading pages and the lectures in class, I did not encounter much problems in this assignment. The only one problem I faced is emma failed at the beginning. This problem is discussed in our google group. I finally found out that it is because the default directory where the will be save is relative to the directory where you launch the tomcat. So there seems no universal environment independent approach to this problem. Even if we change the output directory to an absolute path, it will still need to do different setting in different environment, at least in different OS such as Mac and Windows. As I am used to launch my tomcat from HOME directory, I modified the to look for in HOME directory.

EMMA coverage:
[concat] Emma Coverage summary
[concat] class: 100% (2/2)
[concat] method: 100% (18/18)
[concat] block: 98% (141/144)
[concat] line: 96% (46/48)

The only 2 lines that are not tested is the statement that catch EmptyStackException in doubleIt when calling in action bean. However, these 2 lines will never been reach because the the empty stack is checked in doubleIt method in stackModel. But I still what to keep these 2 lines of code in case the program will break down in the future, and keep it that way rather than just throws it because "nothing should go wrong in the view".