Archive for April, 2004

Would a filesharing cooperative be legal?

Thursday, April 22nd, 2004

If two people split the cost of buying a CD, do they both have the right to listen to it? Do they both have the right to make a back-up copy of the CD for their own purposes? Do they both have the right to download the songs onto their computers and MP3 players to listen to? What if three people split the cost of a CD? What about four.. or five.. or two-thousand people?

Wouldn’t it be legal to create a cooperative where each person pays for a fraction of the cost of a song that they want, and then they would be granted the right to have ownership of a copy of that song? Has this ever been tried before? Is there any precedence for a legal judgement on an entity of this sort?

With software, you are typically paying for a license, so it makes sense that you wouldn’t be able to do something like this. If you buy a song online, they may make you agree to a contract that limits the number of copies that you can make of a song. But what if you actually buy a tangible CD from a store?

Does anybody have any insight on this? I’d definitely appreciate some comments or trackbacks.

Clustering WebSphere Servers

Monday, April 19th, 2004

My new article is now available here on the JavaPro Website. I believe that the article should be published in the printed version of JavaPro in the next month or so.

Here is an excerpt:

“Two major problems that can occur when running applications on an application server are performance degradation (because of high load) and downtime (because of hardware or software failure). Both problems can be remedied by using the clustering features provided by WebSphere Application Server (WAS) 5.X. Clustering provides scalability through load balancing and high availability through failover, which combat high-load performance degradation and downtime, respectively. “

Putting RuntimeExceptions in the Throws Clause

Friday, April 16th, 2004

Many people (including myself) advocate using only RuntimeExceptions (unchecked exceptions) in Java. Many people tend to dislike checked exceptions because they can cause problems with coupling, they clutter code with try-catch blocks, and they are often wrapped and forgotten (when a developer doesn’t do anything with the exception besides catching it).

I’ve been involved in many debates discussing the pros and cons of using only unchecked exceptions. The strongest argument that I’ve heard against using unchecked exceptions goes something like this:

“Java advocates using checked exceptions for recoverable exceptions and unchecked exceptions for unrecoverable exceptions. Using this approach, I don’t mind letting unrecoverable, unchecked exceptions propogate up to a top-level exception handler, because I can’t recover from them anyways. But, I would need to know when a recoverable unchecked exception is thrown so that I can decide if and how to handle it from the calling method. Its not fair for me to have to look up the documentation for a method every time I want to find out if it throws a recoverable unchecked exception, thus I’ll stick with checked exceptions.”

This is a very valid point. It would be very helpful if a developer had an easier way to see what the error handling “contract” is so that he can make the correct decision on where and how to handle it. So how can one make it easier for somebody using an API to see the exception handling contract for a method. One technique I’ve been trying is including all recoverable RuntimeExceptions that a method throws in its throws clause.

What is the benefit of this? Well for one, it prevents the developer from having to look up the JavaDoc for a method just to see if there is a recoverable RuntimeException that is thrown by the method that they call. Second, an IDE could (in the future) provide support to show a user what exceptions are in the throws clause of a method call using a hover-over dialog box and/or by highlighting methods that have RuntimeExceptions in their throws clauses but that are not wrapped in a try-catch block.

I am still just experimenting with this idea, and I have yet to get feedback on it from other developers. I’d be interested in hearing what other people have to say about it.

Here is an example:

public class ExceptionExample
{
  public class MyRecoverableException
     extends RuntimeException { }
  public class MyUnrecoverableException
     extends RuntimeException { }

  public static void main(String[] args)
  {
    ExceptionExample example = new ExceptionExample();

    try {
      example.methodA();
    }
    catch (MyRecoverableException e) {
      System.out.println(
        “Good thing I saw that throws clause!” );
    }

    example.methodB();
    System.out.println( “I won’t get here!” );
  }

  public void methodA()
      throws MyRecoverableException {
    throw new MyRecoverableException();
  }

  public void methodB() {
    throw new MyUnrecoverableException();
  }
}

XDoclet article

Thursday, April 1st, 2004

My new article, XDoclet Meets Eclipse: Code Generation Made Easy, is available on www.devx.com. This article is a followup to my last devx article: JBoss Meets Eclipse: Introducing the JBoss-IDE.

“In an earlier article, you learned how to use an Eclipse plugin that supports XDoclet to administer a JBoss application server. Now, take it to the next level: Learn how to use the XDoclet plugin to generate code via a simple servlet-driven, EJB-based example. “