Friday, November 16, 2007

29.MyIsern-1.3-review

For this code review I looked at the MyIsern 1.3 project from the Green group.

1. Installation Review

Were you able to download the system as a distribution .zip file? Yes.

Were you able to run the system without having to use Ant or Eclipse? (In other words, was there a 'java -jar' interface to the system?) Since it is a WAR file, no. However, a WAR file could be built and compiled and put into the Tomcat manager.

How difficult was it for you to figure out how to run your classmate's software? Not very in this case, since it doesn't use any new libraries. Also, the script format was generally the same as our group's.

Were there JUnit, Checkstyle, PMD, and FindBugs tasks, and did they execute successfully without any errors or warnings? Verify passes for all of the above.

Was the InstallationGuide clear and concise? There is no such wiki page.


2. Code format and conventions review

The code looked good; the only thing I could note is that most back-end code is stored in a package named edu.hawaii.myisern.example, which isn't an appropriate name since this isn't an example.


3. Testing

Black Box: All the existing code from the previous test cases is kept intact; aside from this, no test classes exist for the JavaBeans or Model classes. Thus, one black box test missing would be a basic log in and log out test case.

White Box: Emma reports <80% coverage for all code; this is largely due to no test classes written for the classes.

Break da buggah: Trying to log in fails, basically since the page the system starts at is not the login page.


4. User Interface

How easy to use and intuitive is the user interface?
It is really nice. I am envious! The mechanism to display individual entries is very creative.

How well does the interface utilize screen real estate? Does it function well when using only (say) a third of the available monitor space?
The navigation bar at the top is pretty wide, and doesn't like being less than half of the screen. (My screen resolution is 1280x800) I think those buttons can be made to be less wide. The same applies to the left navigation pane, for the most part.

What opportunities for improvement do you notice?
The XML files seem to still be read in from the application folder - this is fine, although Dr. Johnson did mention the issue of upgrading the system.

For the sanity check, it may be helpful to add quotes. e.g.
[Warning] Researcher does not exist in the database.
would probably be
[Warning] Researcher "" does not exist in the database.

which would be more informative. Also, mentioning which record it occurs in may help the user in resolving these issues.

One other issue I have involves the editing of entries. In order to edit an entry you need to know the EXACT NAME of the person you are editing, which can be a pain to recall. A dropdown box to select the user may have been useful. Also, once the entry is being edited, the fields are the same size regardless of how much data is in it - this probably should be adjusted.

Finally, the real estate issues mentioned in the previous question apply here.


5. Summary and Lessons Learned

In summary I'd say I am pretty impressed with the overall design of the web app.

I learned an interesting way to incorporate AJAX into the web app - I probably would not have intuitively thought of clicking a person's name to view their entry.

Monday, November 5, 2007

25. WebAppQuestions

1. Explain in your own words the meaning of the web "request-response cycle".
Two computers want to talk to each other. One computer (the one 'requesting' data) sends a request to the other computer. The other computer sends their 'response', and the first computer receives the data they requested.

2. Explain how servlets facilitate processing of the request-response cycle.
A servlet is a class that runs within a web server. It handles the response part of the request-response cycle.

3. How do you login to the Tomcat Manager?
Go to the root page (http://localhost:8080) and use the login you configured in the box on the left.

4. What is the Tomcat Manager used for in the StackStripes application?
Nothing, because it is all done in the Ant task.

Actually, it is used for managing various different web apps that were developed for the server. Whenever an application is added or removed to the manager, it is done so using this interface (unless done via an ant task)

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!)
It is contained as a .war file, much like a .jar file for java applications. It is more or less the same as a .jar file, with the exception that .jsp pages in the archive are stored in the root directory of the archive, which would correspond to the root folder of the web app.

6. How do you build a war directory structure in Ant? Where is this accomplished in the StackStripes application?
You type 'ant war'. This is done after compilation is done:

- copy all the files needed for the war (preserving directory structure) to a temporary folder. This is done by copying it to ./build/war. Class files are actually not copied here; but all the metadata is stored here.
- create the archive, preserving directories.

7. How do you install a war directory in a running Tomcat server? What information does the Ant task need to accomplish this?
Go to Tomcat manager, and on the bottom there is a deploy option. It can also be done in an Ant task by accessing the interface via the Ant task.

8. What is the "Model2" architecture? What are its advantages?
It is a method of representing data on a web application - Model, View, Controller. The model contains the data, the view accesses the model, and the controller sends requests to the view. The main benefit is abstraction - the controller doesn't need to know any of the internals of the model to do anything.

This sounds a lot like a database system, though, which I would guess is where the idea came from.

9. What are JSP pages? How are they related to servlets?
A JSP page is basically HTML code with special tags that allow them to access Java classes. They are related in the sense that the JSP accesses data that could be contained in a servlet.

10. Why is there a delay when retrieving a JSP page for the first time? Where is the Java code for that page stored?
For the first time, a client needs to instantiate a session with the server. The Java code for the JSP page is stored in the class.

11. What are JSTL tags? Why are they useful? What is an example JSTL tag from the StackStripes system?
Java Server Standard Tags Library - they are a common set of JSP tags that can be used among various web app frameworks. They are useful since they can be used amongst different frameworks - if you learn one, learning another isn't as difficult since it would (in theory at least) be similar to the first.

Example of JSTL tag:

since this would be independent of the framework.

12. What are Stripes tags? Why are they useful? What is an example Stripes tag from the StackStripes system?
Stripes are similar to JSTL tags except they start with "stripes:" and are only used on the Stripes framework. They are useful since it tells the framework information about the web app and the information that is passed between the controller and model.

Example Stripes tag:


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 a testing framework for accessing applications via a web interface. It is different since JUnit usually accesses the objects directly; but HttpUnit tests what the user would see. It is useful since sometimes the interface is broken while the model is OK.

Example use:

// Get welcome.jsp page and check for successful retrieval
String Url = testHost + "stackstripes";
WebResponse response = conversation.getResponse(Url);
assertEquals("Checking index.jsp retrieval", pageTitle, response.getTitle());


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 button, I added a Response function, as well as a function to the model. Most of the model could be left intact, as well as the underlying stack implementation. I learned that the response functions and model functions can correspond.

15. What are the equivalence classes that need to be tested for the Double It button?
Empty stack, 1 element in stack, more than 1 element in stack. This isn't too bad since the stack must be valid prior to the Double It button being pressed.

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.




17. What is the singleton design pattern? What is an example of its use in StackStripes? Why is it needed?

It is the pattern that only one operation can be executing on the model at any given time - this is needed to deal with concurrency issues if multiple users are accessing the model at any given time. The example of its use is in the 'synchronized' keyword on each public function.

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?
TestStackActionBean: client
TestStackModel: server

Emma deals with this by testing each class's test cases, and treating each class separately.

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: Checks if tomcat is running
tomcat.undeploy: Undeploys web app from tomcat manager if it is currently running
compile: compiles code
war: makes war archive
tomcat.deploy: Uploads web app to tomcat manager.
junit.tool: runs JUnit tests
junit.report: creates JUnit report
junit: wrapper for junit.tool and junit.report

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 no prior experience.

26. StackStripesExtension

For this assignment we were given an existing Stripes web application system and were asked to do some modifications to it.

What was difficult about this assignment? What problems were encountered in carrying out the work, and how did you resolve them? (grouped together since they are similar)

I think the main difficulty was that it is a new framework and I haven't touched web apps, so it was new territory for me. More specifically...

The first difficulty was getting verify to run. Apparently there is some issue with Eclipse that causes the running directory to not necessarily equal the directory the script was run from. Because of this, coverage.ac would get dumped into tomcat's directory rather than the project directory, and that would mess up the script. I thus had to run everything from the command line rather than Eclipse.

Next, data persists between JUnit tests - something I did not realize until the second time I ran it. It wouldn't be obvious at first since only one test was provided - but once the second test was added, you could start to notice it as being an issue.

Lastly, thinking of a good way to implement Double It was an issue. Initially I wanted to have all the code for it reside in the Response handler, but it turned out to be difficult since without access to the private Stack, it adds about 10x more code to do so. I was writing a function that did popping manually until I realized I'd have to handle an exception that never gets thrown. So in the end, I wrote a new static member for the StackModel object.

Were all of the assigned tasks completed? If not, which ones weren't, and why didn't you finish them?

Yes.

Concluding remarks:

I don't think the build files were perfect - they do get the job done, but they could certainly be improved. If I spent more time on this (which I probably will be for the next project), I probably would have modified them to do two things:

- work in Eclipse, and
- automatically start the Tomcat server if it isn't running, rather than spit out an error message