LarryRoth.net

Just my thoughts

FindBugs helps you fix your code

July 19, 2006
There is a good article at IBM Developer Works about using the FindBugs static code analysis tool. Test cases are important, but when you inherit code, a good static analysis code tool can really help you out. The article is a couple years old, but still quite relevant. I thought this comment summed it up nicely. From the article:
Much of the knowledge of how a class works (or is supposed to work) evaporates shortly after it is written, in the form of implicit assumptions, invariants, and expected use cases that are clear in the developer's head but never get written down in the form of design notes, comments, or documentation. Existing code is always harder to work with than new code.1
Even with strong test cases, you can still miss more complex bug patterns. FindBugs can help you out.
[1] Java theory and practice: Kill bugs dead, http://www-128.ibm.com/developerworks/java/library/j-jtp06294.html, posted June 29, 2004, viewed July 20, 2006

FindBugs helps you fix your code

Braingate--a new way of interacting with your computer

July 19, 2006

This article at StreetFish provides a summary of the ongoing research with brain implants at Brown university. It shows some (early) exciting results for enabling people with disabilities and perhaps increased HCI for everyone.

From the article:

Braingate it its name, and it was created by scientists at Brown university and already it has been used to give computer control to a 25-year-old Massachusetts paraplegic, allowing such functions as controlling the tv, his prosthetic arm and drawing shapes using the cursor. The system requires an implant of a 4mm square chip into the motor cortex, connected to the brain by 100 electrodes, each measuring the electrical signals of the cells they connect to. The signals are then calibrated by thinking of particular movements, and the computer works out the rest.

I found additional information about this project on the Brown Web site.


Braingate--a new way of interacting with your computer

Web services in Java 6

July 18, 2006

Eyal Lupu has a nice (short) primer on Web service support in Java 6. It's an easy read, and it really gets you excited about the possibilities of Web services. Since the concept of Web services was first mentioned, it seemed like an ideal way to foster code reuse and componentization (in the Web domain)—ideas that are core to Java development.

However, in the Java space, there has always been a fairly steep learning curve and/or a significant amount of code and configuration that went along with using Web services. But now, thanks to the power of annotations and Sun listening to the Java community, it is now quite simple.

Here is a before and after snippet. See if you can spot the difference:
Before

package ws;
public class CalcWS {
   public int add(int a, int b) {
     return a+b;
   }
   public float div (int a, int b) {
     return a/b;
   }
}
After (from the article)
package ws;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
@WebService
@SOAPBinding(style=SOAPBinding.Style.RPC)
public class CalcWS {
   public int add(int a, int b) {
     return a+b;
   }
   public float div (int a, int b) {
     return a/b;
   }
}

See the difference? Just 4 lines of code two imports and two annotations. Pretty cool! Now if we can just get Tor Norbye to abandon Creator and Project Semplice and focus on enabling the following annotation:
@TurnThisObjectIntoACoolWebAppLikeRailsDoes
That's not too much to ask, is it?
Web services in Java 6

Easier account management w/ Apache

July 16, 2006

If you manage an Apache based Web site that requires user authentication you may be familiar with using htaccess and the following in your site configuration file.
<Location /private >
   AuthType Basic
   AuthName "Realm name"
   AuthUserFile /etc/apache2/users
   Require valid-user
</Location>

If you are not familiar with this nomenclature, it will cause a pop-up username/password box to appear and grant access only if the username and password exist in the htaccess file. The downside to this approach is user management. Each user needs to be entered via command line or through one of a few available Web apps that help automate the process. In addition, you don't have any information about the user except a name.

You can of course use application layer authentication and authorization, but it requires lots of extra code, you need to manage the data yourself, and can't easily protect all your Web assets such as images.

I have been using a third approach—authentication against an LDAP server. The benefits are:

  • More available options and application for account management
  • More information available about users
  • Standardized account information can be shared with other apps
It was easy to setup. All I had to do was enable the Apache mod_auth_ldap module, and add the following to my configuration file:
<Location /private >
   AuthType Basic
   AuthName "Realm name"
   AuthLDAPURL ldaps://www.foo.com:636/cn=users,dc=foo,dc=com?uid
   Require valid-user
</Location>
Actually, you can see it's only a one line change over the htaccess approach. I should mention that the above ldap url format works with Open Directory running on Mac OS X server. The ldap url you use will depend on your particular LDAP server and setup. The uid is used by Apache to map to the server variable: username.

For my use—in-house Web apps—it's been great to start authenticating users against the internal LDAP we use for our mail server. It's not exactly a single sign-on solution like Kerberos or NTLM—the user still has to enter their username and password for each site—but at least they don't have to have a separate username for each site.

The hardest part is getting the ldap connection string correct. Once you have that figured out, the rest is easy!


Easier account management w/ Apache

Put your mac to sleep fast

July 5, 2006
I found this tip: (Two seconds to sleep) on the Apple site. As my new MacBook Pro doesn't go to sleep when I shut the cover, it is very helpful. Here is the tip:
Want the fastest way to put your Mac right into a deep, sleepy-bear hibernation-like sleep (no whirling fan, no dialogs, no sound — nuthin’ — just fast, glorious sleep). Just press Command-Option and then hold the Eject button for about 2 seconds and Zzzzzzzzzzzzzz. It doesn’t get much faster than that.[1]
meta-footnote-1= Apple - Pro - Tips - Two Seconds to Sleep, http://www.apple.com/pro/tips/quicksleep.html, viewed July 5, 2006
Put your mac to sleep fast