Friday, November 16, 2007

MyISERN 1.3 Review

The code I reviewed is from team blue.

1. Installation
I can download and install the code without any problem. There is a jar command to create a jar file, but I believe that is what is left from the last group since the file is named as "myisern-1-green.jar". All the QA tests are passed except for the Emma, which complains about the missing of the coverage.xml file. I would recommend the team to model their program after the StackStripes, which should easily fix this problem. There is a readme.html file comes with the package, but again, it is something from the last group.

2. Code format and conventions
The code do not violate much rules, however, there are some private variables are not commented in both the model and action bean. Other than this, there is no big problem.

3. Test case
Black box perspective: Only the listing functionality seems to be working correctly. Everything other than that seems incomplete. Adding or editing buttons would cause the program to crush.

White box perspective: Since Emma did not pass and there is currently no JUnit testing written, there is not much white box testing are being done.

Break da buggah: Clicking on the adding or editing button can crush the program.

4. User interface
The interface of website is very straight forward. The screen estate is well preserved since the program is still usable with only half of the monitor size. Although I would prefer some "Back" buttons that allows the users to navigate back to the previous page, as well as a link back to the homepage.

5. Summary and lesson learned
Overall, team blue's code still has a lot of work to be done in order to complete all the core functionalities. Consider this is only a work-in-progress result, it is acceptable. Besides that, the team seems to be on track and working towards the correct way.

Monday, November 5, 2007

Stack Stripes Extension

Source code

This assignment is very straight forward, and I have completed all the tasks. However, there are some obstacles I encountered during the process.

The first problem was the Emma error. It showed error on missing the coverage.ec file on the first time I ran verify test with the fresh code from the downloaded package. However, this error disappears after I try to run the junit test. According to the discussion on the class website, it might be caused by launching the Tomcat server besides the project’s directory. I tried to reproduce the error by launching Tomcat on the root directory, but it did not work somehow.

The second problem was the concurrent exception when I tried to create the action for the Double It button. Since this is a web application, we can only run it over the browser. The error message page was a blast for me when the first time it showed up. I was a little clueless at the beginning because I was expecting some error message in the console from eclipse. Then very soon I notice the error message was showed in the error page like they would in the console. With those messages, I was able to fix my bug very quickly.

There were also many minor problems while I tried to go through all the tasks, such as how to launch Tomcat server in different ways, or create new forms in the JSP page. However, they are very minor and got fixed very fast.

Overall, this assignment is quite easy, which is what it supposes to be. From this assignment, I have gained a rough image how the client-server application should work. Also, I learned many new concepts, such as servlets, JSP, JSTL, etc. This assignment only reflects a tiny portion of the web application, and I believe as the semester go on, I will learn a lot more about it.

WebAppQuestions

Questions:

1. Explain in your own words the meaning of the web "request-response cycle".
This is the cycle where the client, usually represented as a user, sends out a request to the server, usually represented as a website, and then the server gathers the necessary information to construct a response, and sends back the response the client and waits for the next request to complete the cycle.

2. Explain how servlets facilitate processing of the request-response cycle.
The servlets use the ServletRequest interface to define methods for getting information from the requests, which contains the data passed between a client and the servlet; and it uses the ServletResponse interface to defind methods for constructing responses, which contain data passed between a server and the client.

3. How do you login to the Tomcat Manager?
In order to login to the Tomcat Manager, the user must first start up the Tomcat server, then open the browser and type in http://localhost:8080, click on the Tomcat Manager link, where the user will be asked for user name and password for login. The information is defined in the file $CATALINA_HOME/conf/tomcat-user.xml.

4.What is the Tomcat Manager used for in the StackStripes application?
In the StackStripes application, the Tomcat Manager is used to deploy and undeploy the application and maintain the sessions for the application.

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!)
The directory will be named after the application, for instance, StackStripes. Then inside the directory, there are META-INF and WEB-INF folders, and some jsp files which might be under some subfolders. The jsp files define how the web application will look like in the browser. The META-INF folder contains the manifest file for the application, and the WEB-INF folder contains the classes files for the application, and the library used in the application, which usually are jar files. The WEB-INF folder also contains a web.xml file, which is the configuration for the Stripes.

6. How do you build a war directory structure in Ant? Where is this accomplished in the StackStripes application?
To build a war directory structure in Ant, a target must be created. This target must invoke the Ant task “war” to create a war file and specifies a configuration file usually named web.xml. In the StackStripe application, this is done inside the war taget in the build.xml file.

7. How do you install a war directory in a running Tomcat server? What information does the Ant task need to accomplish this?
One way to deploy the application in a running Tomcat server is to set the autoDeploy attribute to “true”. Alternative way is to do it via an Ant task. The necessary information for the task include: the war file, and the deploy parameters and the install URL.

8. What is the "Model2" architecture? What are its advantages?
Model2 is an architectural pattern used in software engineering. It separates the data (model) and user interfaces (view), and uses a controller to connect the two components, so that they do not affect each other when modified. It has the greater scalability and modularity.

9. What are JSP pages? How are they related to servlets?
JSP pages are used to create web content that has both static and dynamic components. It relates to the servlets by accepting the dynamic request.

10. Why is there a delay when retrieving a JSP page for the first time? Where is the Java code for that page stored?
This is because the JSP page must be compiled into a Java Servlet, which is a piece of pure Java code to go through, and it does not require this process after the first time access. It is store under the $J2EE_HOME directory.

11. What are JSTL tags? Why are they useful? What is an example JSTL tag from the StackStripes system?
JSTL tags are a collection of tag libraries that provide common functionality while writing JSP pages. They are useful because they fit in HTML better than Java code, and provide reusability as well as Expression Language, which is very convenient. In the StackStripes system, the
JSTL tag is used.

12. What are Stripes tags? Why are they useful? What is an example Stripes tag from the StackStripes system?
Stripes tags are the ones start with the prefix “stripe:” They are useful because they link the JSP pages to the Java classes automatically and provide very powerful functionality. In the StackStripes system, the
Stripes tags are used.

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?
HttpUnit is open source software that can provide automated testing by emulate the browser behavior. It is different from JUnit because it provides easy way to write tests that can simulate the user behavior on a web, such as clicking a link. It is very useful for testing web application. In the StackStripes system, it is used to test the task of user clicking the buttons on the web.

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?
To implement the Double It button, a new JavaBean method for the double operation must be created, also a new form must be created in the JSP page. Everything else that worked before do not have to be changed. This is the advantage of MVC design, it separate the data, which is the Stack model, with the view, which is the JSP page. So when we change the JSP page, it does not affect the data.

15. What are the equivalence classes that need to be tested for the Double It button?
The class needed to be tested for the Double It button is StackActionBean because it is related to the user interface (view). The StackModel class has nothing to do with it, thus it does not require testing.

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.
Before:

After:

17. What is the singleton design pattern? What is an example of its use in StackStripes? Why is it needed?
The singleton design pattern enforce there is always only one instance exists for the class. In the StackStipes system, the stack is implemented in this way. This is needed because it prevent multiple stack is being used by different users.

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?
The StackModel is tested on the client side, and the StackActionBean is tested on the server side. Emma combines the coverage from both side to create appropriate coverage data.

19. Running 'ant -f junit.build.xml' results in the following target invocations: tomcat.check, tomcat.undeploy, compile, war, tomcat.deploy, junit.tool, junit.report, junit. Explain what each of these targets do.
tomcat.check – check if Tomcat server is running
tomcat.undeploy – undepoly the application if there is one running on the server
compile – compile the source code
war – create the new war file using the web files
tomcat.deploy – deploy the application on the server
junit.tool – runs the JUnit tests
junit.report – report the JUnit results by creating HTML report file
junit – ensure the junit.tool and junit.report has been run

20. (Optional) If you have experience using one or more other web application frameworks, discuss your initial reactions to Stripes. How is it similar, or different, or better, or worse than your previous experience?
I have used a little ColdFusion framework before, but I only set up the database on the server side and it is a local server as well. Many things are quite similar in the two frameworks, they both have their own tags to do specific tasks that are more powerful than normal HTML tags, and they both have a manager-like feather to maintain the sessions.