Tuesday, November 30, 2010

31.WicketKatas


Overview

Code katas are exercises in programming that help you to refine your skills.  The goal of this assignment is to:
  • Improve your comfort level with Wicket by performing a number of small changes to existing Wicket systems.
Each Kata involves a modification to one of the example systems in the ICS Wicket Examples project.   To start,
I downloaded all the .zip distribution of all examples but example05 to your local system.  I edited the build.xml
file so that the project name is no longer exampleNN, but rather exampleNN-kteichma. I then ran "verify.build.xml"
using Eclipse.

These example files were modified in the following ways:

The Eleven Wicket Katas

Example 01:

Kata 1A:  Add a new line to the page that says, "In one week, the time will be <time>", where <time> is replaced
by a timestamp one week later than the timestamp that now appears on the page.

Kata 1B: Add a button to the page labelled "Refresh".  After pushing the button, the times update themselves.

Kata 1C:  Wicket, by default, runs in "Development" mode, but production systems should run in "Deployment"
mode.  Override the getConfigurationType() method so that Example01 now runs in Deployment mode.  See
this page for details. 

This particular example was finished by my partner and I during our class period. It took about 40 minutes. Professor
Johnson gave some nice hints on how to you the java Date constructor to make a date from a timestamp. I was able
to review form usage in this particular kata and discover the development mode.


Example 02:



Kata 2A:  Add an additional link on the home page that says, "Go to image
page".   Create this page, which should display an embedded image.  This
image should be G-rated.  It should be in a .jpg file stored with the
system, not retrieved from the web.

Kata 2B:  Add a button on the home page with the label, "Make font bold". 
After the user pushes it, all the text on the page should become bold, and the
button label should change to "Make font italic".  When the user pushes that
button, all of the text should change to italic and the button label should
change to "Make font normal".  Pushing that button changes the text back to
its original state and the button label should now say "Make font bold".

Kata 2A was finished in class. Estimated time it taken to complete was
around 40 minutes. I can't remember too much about this one other than it
took us a while to figure out that there was an Image object we could use
to add pictures stored on the system to the webpage.

Kata 2B was a little harder, and I'm not quite pleased with the solution I implemented. I ended up making separate
form pages for italicized and bold lettering. There is obviously a better way to do this, such has make bold and
other style labels, but this was the only solution that occurred to me in my lack of time.

Example 03:

Kata 3A: Add a new tab called "Image" that takes the user to a page containing an embedded image (your choice,
G-rated).  It should be in a .jpg file stored with the system, not retrieved from the web.

This particular example took about 10 minutes as it was very simular to example 2a. It was almost a no brainer as
I was able to copy and paste most of the code used in kata 2A.

Example 04:

Kata 4A:  Add a new cheese called "Velveeta", which costs $0.25/lb.

Kata 4B:  Add a "country" field to the billing address that appears when checking out.   The country field should
provide a drop-down menu with a selection of 5 countries.

This particular example took 40 minutes. I had some issues with this particular kata in that it took a while to figure
out how the data was stored. It will be interesting to eventually see how this front end will end up working with
DB back end. As of now, all of the entries are hard coded into the java source.

Example 06:

Record how long it took you to accomplish each of these katas.

Kata 6A:  Get rid of the blue columns that appear when displaying the website. These are for development, not
deployment purposes.

Kata 6B:  Place the image underneath the form, not to the right.

Kata 6C:  It is often convenient for web applications to consult a properties file when starting up in order to get
configuration values.  An easy way to do this is with the standard Java Properties mechanism.  (See Java in a
Nutshell for details on properties file manipulation.)   For this Kata, modify your Example06 system to read in
a file (if present) located in ~/.example06/configuration.properties.   (Note that ~ means "the user's home
directory", and that there is a System property in Java that provides this value.)  This property file should
contain a line like the following:

deployment = true

In other words, it contains a property called "deployment" whose value is true if the Wicket application should
run in deployment mode, otherwise the application should run in development mode (see Kata 1C).

Your application should read in the properties file and set the System property wicket.configuration before
starting up Wicket. The Jetty class is a convenient place to do this processing.

Finally, your application should write out a message on startup indicating whether or not it found the file, and
what the resulting configuration mode will be.  If the file is not found, or the property is not present in the file,
then the application should run in development mode.
 This particular example took me another 40 minutes. I still was not able to finish Kata 6C as I have been
running out of time juggling ICS311 and ICS413 and ICS321 these past 2 days. Big projects all due at the
same time. Kata 6A was a fairly easy change as turning off the grid doesn't require much. As for kata 6B, 
this just required some basic knowledge on how grids work and making more area.

Overall, I enjoyed the process of experimenting with Wicket and I look forward to using it more extensively
in the future. However, I do recommend keeping our options open as
http://oodt.jpl.nasa.gov/better-web-app.mov provided by Professor Chin in my 215 scripting class, shows that
there are great alternatives out there. Here is a link to my distribution file 

No comments:

Post a Comment