Strategy Design Pattern applied to hashCode() and equals()

The latest issue of the JavaSpecialists newsletter (by Dr. Heinz Kabutz) features a lengthy look at possibility of applying the Strategy design pattern to the equals() and hashCode() methods commonly used in Java. In it he concludes that the equals and hashCode methods autogenerated by IntelliJ Idea are better from a performance standpoint.

If your IDE of choice doesn’t include the ability to autogenerate the bodies of the above mentioned methods, you might also check out the EqualsBuilder, HashCodeBuilder and ToStringBuilder classes in the Jakarta Commons Lang library.

Wildlife of Buzzards Bay

It’s getting warmer here in Mattapoisett, not warm enough walk on the beach in the evening without a jacket, but warmer nonetheless. Tonight I walked down to Brandt Island Cove with Jazz and took a couple snapshots of the things I’ve been coming across on our walks lately.

First, for the last couple weeks there have been at least two American Oyster Catcher (also here) birds on our small stretch of beach. They don’t let you get very close to them and I don’t have a great zoom lens, but they’re a distinctive breed: the large orange beak makes it stand out from every bird I’ve seen on our walks and it seems to prefer hopping to flying (it hops until Jazz spots it and chases it away). I’m only a novice birdwatcher, but apparently there are only about 7,500 of these birds left in North America, so I guess it’s a privilege. Here’s a quick snapshot I got of one of them:

america_oyster_catcher.jpg

Second, Jazz pulled either an Atlantic Stingray (Dasyatus sabina) or a skate (Raja eglanteria) out of the water yesterday, luckily she didn’t try to chew it up like she does everything else she finds on the shore.

atlantic_stingray.jpg

Finally, the sun was shining brilliantly on the water and I’m still no good at taking pictures, but maybe someone in a landlocked state will appreciate the view of the ocean:

brand_cove_in_may.jpg

and of this amazing tree that reminds me of a something you’d see under an electron microscope:

trees.jpg

Showing Google’s Web Accelerator the door using Java / ServletFilter

The guys over at 37 Signals posted an explanation of why they think the Google Web Accelerator is a bad idea and a link to a page which shows how you can disable the Google Web Accelerator by analyzing HTTP headers using Ruby. I’m don’t really care to discuss why you think the GWA is good or bad, but in case you think it’s bad, here’s the same thing implemented as a ServletFilter (here’s the same thing for ColdFusion):

public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
  throws IOException, ServletException {
  HttpServletRequest httpreq = (HttpServletRequest)req;
  HttpServletResponse httpres = (HttpServletResponse)res;
  if (httpreq.getHeader("X-moz") != null &&
    httpreq.getHeader("X-moz").equalsIgnoreCase("prefetch")) {
    httpres.sendError(HttpServletResponse.SC_FORBIDDEN);
  } else {
    chain.doFilter(req, res);
  }
}

Add the following to your web.xml:

<filter>
  <filter-name>gwa</filter-name>
  <filter-class>com.mycompany.web.filters.GWAFilter</filter-class>
</filter>
<filter-mapping>
  <filter-name>gwa</filter-name>
  <url-pattern>/</url-pattern>
</filter-mapping>

and you’re good.

Paper Review: Two Case Studies of Open Source Software

The term paper for the class I’m taking (Paradigmatic Software Development) required that we write a review of a article that has appeared in a software engineering journal. I spent about 45 minutes trying to poke around the journal locator that UMass Dartmouth outsourced before giving up (they don’t let you search by topic, how lame is that?) and then remembering that Google has an academic focused search. Scholar.google.com found a bunch of articles about ‘open source’ and ‘software engineering’, I chose one entitled “Two Case Studies of Open Source Software
Development: Apache and Mozilla
“. My review of the paper is over 7 pages long, you can download the entire thing in MS Word format or read the extended entry below.
Continue reading Paper Review: Two Case Studies of Open Source Software