June 23, 2006

Bacteria is Delicious

Who would have thought sun tea could be bad for you? Very, very bad. It's all fun and games until someone slurps bacteria. I remember drinking this stuff all the time when I was young.

Posted by enigma at 08:59 AM | Comments (1)

June 19, 2006

A Bit O' Carbonation

Nothing like bit of carbonation for the easily entertained. Just consider the Diet Coke and Mentos frenzy we've seen. Sure, there's lots of videos to choose from on Google Video or YouTube, but you haven't seen anything until you've checked out the video at eepybird.com. According to this article, Mentos is thrilled over the publicity and might even hire the eepybird.com guys. How about Coke? Coke doesn't think it fits the "image" of Diet Coke. I guess Diet Coke is too boring. ;-)

Posted by enigma at 10:47 AM | Comments (1)

June 13, 2006

To Check or Not to Check

In an email thread, David Castro brought up the question: When should one use checked exceptions in Java? On that note, check out this paper and then read below. It think the paper is well written and helpful: Exception Handling: Common Problems and Best Practice with Java 1.4

On that note, I don't entirely agree with the article. Let me elaborate.

A checked exception mechanism is a way for the compiler to force the programmer to provide code blocks for any number of named possibilities. Presumably, the compiler needs to enforce this because the programmer is: 1) lazy, 2) forgetful or 3) uninformed. Personally, I've seen all three traits in programmers (including myself), so I think it's a reasonable assumption.

A problem arises when the programmer is none of the three. Take the following example (which I'm stealing from the paper):

  DateFormat format = DateFormat.getDateInstance(SHORT);
  private final static String DEFAULT_DATE_STRING=”01.01.1900”;
  try {
      Date defaultDate=format.parse(DEFAULT_DATE_STRING);
  } catch( ParseException pexc ) {
      // Cannot happen: if it works once, it will always work!
  }

As the author of the paper points out, even though the format is initialized by a constant, it might be possible for that exception to be thrown in some unusual circumstances: code maintenance affects the constant or there a configuration issue with localization code. Both of those cases are candidates for what the author says are "untreatable situations", however the author of the DateFormat class decided that because the exception *might* be treatable, the exception should be checked. In this case, the programmer is forced to do something with an exception will almost never happen and if the exception occurs, it should probably should just propagate to the top of the application.

Due to the aforementioned problem, I would revise the rule to state that checked exceptions should be used in the case where the options are always treatable. When is something always treatable? Good question. It seems a bit hard to make that assumption. So I tend to favor unchecked exceptions unless you really have good reason to assume all the exceptional cases should be dealt with.

Now, for a completely different line of reasoning. The guiding idea for checked exceptions is that the compiler should force the programmer to deal with the exception, but if it really makes sense to leave it alone, the programmer can just add a "throws" clause and be done with it. Aside from the annoying implication that you have to modify all the calling functions to have the "throws" clause until you get to the place where you are finally ready to deal with the error, there is still the problem that the exception might have to traverse ground that is not controlled by you. For example, suppose you open a file in response to the user pressing a button. You might get a "FileNotFoundException". Well, here, just try the following code out:

  public class EventException {
      public static void main ( String [] args ) {
          (new JButton()).addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                  throw new FileNotFoundException("Oops");
              }
          });
      }
  }

The complier complains that you didn't declare the checked exception, but if you try and declare it then the code won't link because the event handler class that calls the "actionPerformed" method doesn't declare the exception.

So, we are left with a modified version of the ideal: if it makes sense for the programmer to leave the exception alone, the programmer can just define the a "throws" clause unless the programmer doesn't control all the methods up the calling stack. Contrast this with the idea of code reusability where we don't want to have to control the code for everything because we want other people to write code that we can use. Put those together and we have a problem.

Now of course, you can wrap the "FileNotFound" exception up in a so-called "evil" unchecked exception, and that's where we started from in the beginning of this conversation.

In summary, you should use checked exceptions if you can guarantee the programmer can deal with all exceptional conditions in the immediate context and will not have a reason to handle the exception further up the calling stack.

Wow, this post ended up being really long. If you are still reading this email at this point in time you should just give up and admit you are a serious programming geek. ;-)

Posted by enigma at 12:58 PM | Comments (0)

June 12, 2006

Education

Dave's blog post got me thinking about education. Since I'm a graduate student, I've been thinking about my own education quite a bit. I also have the opportunity to work with undergraduates, so I get to think about their education too.

Ideally the process of learning is something one engages in for their own personal benefit. Either one is internally motivated to learn because they recognize the benefits of learning, or one is externally motivated to learn because another (in authority) had decided what is "good" for that one. I think every educator's ideal is internal motivation because the student recognizes the need to learn and is actively participating, but external motivation is not necessarily a bad thing.

For a particular subject matter, there are two cases that require external motivation: 1) lack of awareness of the need to be educated and 2) disagreement with the asserted need to be educated. If the need to be educated, in a particular subject matter, is a valid need, the first case amounts to individual ignorance and the second case amounts to personal rebellion. The ignorance may be overcome by demonstrating the validity of the need, and presumably, one can win over the individual into the "self motivated" camp. If one understands why he should be educated but just doesn't want to be, one in authority can force the individual to engage in the activity because it is good for him whether the individual likes it or not. Likewise, as a parent, I compel my children to do certain things to help them grow and establish good habits. This is a proper role for me since I am in authority over my children and I seek the best for them.

The issue gets thorny when considering a perceived but invalid need for education in a particular subject matter. In this instance, both case #1 and #2 unfairly characterize the individual as ignorant or rebellious even though the individual is neither. Instead, the individual is making a good decision.

This leads us to the strategy for educational lobbying. First, assert that one can "never get enough education" and therefore "education is always good for you." This creates a penultimate need for education--the need is never invalid. In that context, anyone who disagrees with you is either ignorant (case #1) or some kind of rebellious social dissident (case #2). And you and all the other "educated" people can pal around and feel good about yourselves since you aren't ignorant or anarchists like the people who just don't "get it."

Of course, this discussion begs the question of *what* one *needs* to be educated in. I think everyone agrees that some form of education is absolutely necessary, but everyone has their own opinion on what that form should be. And, fundamentally, no one is able to determine some kind of optimum level of education that everyone should receive--one can only aim for baselines and not optimums.

Since the need is clearly a difficult thing to establish, this brings us to the question: Who establishes the need? Should it be parents? the kids themselves? the government? a panel of HR representatives from the strongest American corporations? And so we fight and fight and fight.

Personally, I like the idea of fundamental to advanced levels of education in all sorts of subject matters being attainable for all Americans. It sounds so egalitarian--it's very "American" in that sense. I'm not sure how economically sound it is, but I like the idea. I don't like the idea of forcing individuals to get education they don't want. So, I see education as a smorgasboard of opportunity for those who want to dine. If you are full, go away happy. Once education no longer serves to benefit you, but you are subject to it for the sake of itself, who is it helping?

Posted by enigma at 09:22 AM | Comments (2)

June 06, 2006

Defense of the Masters

Yup. That's right. I defended my masters this last Friday from 2:30-4:30 PM. Why am I writing about it today and not on Friday. I've just been *that* busy.

I was pretty nervous about my masters defense all the way up until I started talking. The room was packed--literally. All the seats were filled and some chairs had to be borrowed from the room next door. I estimate there were 25-30 people there. A couple of people were teasing me about bribing grad students to come to the defense by offering free food. (Of course, everyone has food at their defense. It's just one of the things you do.)

On the matter of food, I had donuts, bananas, orange juice and apple juice--a kind of afternoon breakfast. In better words, you could call it "second breakfast." Breakfast is one of my favorite occasions for eating and my defense being my shindig, I had to have breakfast food.

My committee was made of: Ronald Metoyer (my adviser), Margaret Burnett, Rajeev Pandey, and Jimmy Yang (Grad Council Rep, professor in the School of Business.) I'm very thankful for their feedback and willingness to be on my committee.

The defense was structured like so: I presented my research (which I had written up in my masters), I fielded questions from the audience, the audience was kicked out, I answered questions from my committee about my thesis (and presentation), and then I was grilled on anything the committee members wanted to ask that was relevant to my coursework. After all that, I was kicked out while my committee came to a pass/fail decision. Happily, I passed.

I really enjoyed the challenge of presenting my research. I found the Q/A session with my committee challenging and exhilarating. It was satisfying to realize how much I have learned in grad school.

I was relieved to find out my committee really liked my thesis. I received several fine compliments about it. After reading my committee's comments, it looks like I don't have to much editing to do before I can turn the final version. Mostly I feel like I have accomplished something and very relieved that it went well.

Posted by enigma at 10:50 PM | Comments (3)