December 3, 2010

Wicket installation

Update: I finally got around to writing the second part, about setting Wicket up with Tomcat instead of relying solely on the embedded Jetty server. See it here.


Downloaded JDK 6_22
Downloaded Maven 3.01
Installed JDK to C:\Program Files\Java\jdk1.6.0_22
Unzipped maven to C:\Program Files\apache-maven-3.0.1
Updated system environment variables:

- M2
C:\Program Files\apache-maven-3.0.1
- M2_HOME
%M2_HOME%\bin = C:\Program Files\apache-maven-3.0.1\bin
- JAVA_HOME
C:\Program Files\Java\jdk1.6.0_22
- M2_REPO
C:\Users\Programmer\.m2\repository

Followed instructions at Wicket quickstart
Generated this Maven command from quickstart:

mvn archetype:create -DarchetypeGroupId=org.apache.wicket -DarchetypeArtifactId=wicket-archetype-quickstart -DarchetypeVersion=1.4.1 -DgroupId=com.mycompany -DartifactId=projName

Ran above Maven command from command line
Relevant files, including Wicket source, were downloaded automatically (based on POM?)
Ran mvn eclipse:eclipse to create an Eclipse project based on above
Imported project into Eclipse with File > Import..., Existing Projects

Ran Start.java in the test folder and went to http://localhost:8080 — success.

Wanted to add Wicket Extensions support.
Manually adding JAR file to to M2_REPO directory didn't work.

Current status:
Adding a dependency to the POM is probably right (there's even a similar dependency in there but commented out), but how will Maven understand that the new dependency needs to be added? Merely uncommenting and running Start does nothing.

Resolved: Just run mvn clean dependency:copy-dependencies after updating the POM. There's probably a better way to do this, though. Then configure the build path by using Add Variables... (not Add JARs), select M2_REPO, press Extend, find the desired JAR (in this case, Wicket Extensions).

Current status:
Need to figure out how to make this worth with Tomcat instead of relying on the embedded Jetty server all the time.

August 23, 2010

Why arrow code is bad

I, like Jeff Atwood, don't like arrow code.

But is arrow code actually bad, or just unsightly? It's bad. Jeff mentions cyclomatic complexity but doesn't describe it; so see Wikipedia.

In particular,

[Most of the relevant] studies find a strong positive correlation between cyclomatic complexity and defects: modules that have the highest complexity tend to also contain the most defects.

August 10, 2010

How Ryan Tomayko explained REST to his wife

The web is built on an architectural style called REST. REST provides a definition of a resource, which is what [URLs] point to.

A web page is a representation of a resource. Resources are just concepts. [URLs] tell the browser that there’s a concept somewhere. A browser can then go ask for a specific representation of the concept. Specifically, the browser asks for the web page representation of the concept.

Full post on Ryan's blog

July 13, 2010

Vista fonts compared to older fonts

The "Vista fonts" are Cambria, Calibri, Candara, Consolas, Constantia and Corbel. A good piece on them is provided by hunlock.com here.

July 12, 2010

Package becomes unrecognized in Eclipse

Error:
Saving a Java source file in Eclipse causes the errors "[class] cannot be resolved to a type" and "The import org.oasis_open.docs.[whatever] cannot be resolved" for classes in a package that was previously recognized.

Solution:
Open the context menu for the affected package in Package Explorer, select Build Path > Configure Build Path... and go to the "Order and Export" tab. Make sure custom classes are at the top, third-party files are in the middle and the JRE is at the bottom of the list. Select OK and refresh the affected files/packages.

July 8, 2010

Putting a head tag below a body tag

It is possible to put <head> tags underneath <body> tags. Why do this? One reason is to make cache instructions work better, as described by Microsoft here.

Another is described in High Performance Web Sites: Rule 6 – Move Scripts to the Bottom by Steve Souders, Yahoo!'s Chief Performance Yahoo!

With stylesheets, progressive rendering is blocked until all stylesheets have been downloaded. That’s why it’s best to move stylesheets to the document HEAD, so they get downloaded first and rendering isn’t blocked. With scripts, progressive rendering is blocked for all content below the script. Moving scripts as low in the page as possible means there's more content above the script that is rendered sooner.

The second problem caused by scripts is blocking parallel downloads.