Video Voice Mail

Yes, I waited in line yesterday morning for my iPhone 4. And again in the evening to get my wife’s iPhone 4. Was it worth it? Absolutely!

The display is stunning. I know you have probably heard this a million times by now, but really you have to see it. It is immediately obvious. The text renders amazingly crisp and sharp. It’s really beautiful.

Another feature that some people are excited about is FaceTime, which is basically videoconferencing over WiFi. After playing with FaceTime for a bit, it struck me that this would be a really cool thing to integrate into Visual Voicemail. What if you could leave a video message for someone rather than just voice? What if the video appeared right alongside the other messages in your Visual Voicemail screen?

I think we will probably see something like this in the not-too-distant future. What do you think? Is this something you would use?

Word Count

I have been playing with Apache’s Hadoop over the last couple of days. One of the code examples is a simple word count routine, and I thought it would be fun to find a large book and do a word count on it.

I choose Ulysses by James Joyce, and downloaded the Project Gutenberg version of the text. After removing the extra text related to licensing etc., I uploaded it to my Hadoop distributed file system and ran the word counter against it. The initial results were obviously not very accurate, so I tweaked the word count MapReduce job to remove extra punctuation and convert all the words to lowercase. Much better.

It turned out that the most used word was “the”, at 14,932 times. However, according to one of my Twitter contacts, “a,” “and,” and “the,” are not supposed to be counted as words. That would make “of” the most used word (if it can be counted), at 8,138. She was curious about the number of times “yes” is used in the text: It turns up only 360 times.

Here are the top-25 most used words in Ulysses:
1134 she
1187 as
1208 said
1269 by
1288 at
1320 all
1435 is
1524 him
1786 her
1889 you
1936 for
2109 on
2133 was
2357 it
2514 with
2606 that
2698 i
3333 his
4031 he
4924 in
4962 to
6500 a
7214 and
8138 of
14932 the

If you are curious about the word counts in Ulysses, you can download this file and see for yourself. The download is a zip file containing two text files, one sorted alphabetically by word and the other sorted by the number of occurrences of each word. If you come up with any interesting visualizations or other analysis of the files, please leave a comment. I would like to see what you do with the data.

iPhone 4.0 Wishlist

If you follow any tech blogs, you have probably seen the news that Apple is hosting an event on Thursday that is billed as “a sneak peek into the future of iPhone OS”. Of course, there is much wild speculation about what this might mean, with predictions of multi-tasking abounding.

First, please stop saying that the iPhone OS does not multi-task. Yes, it does. It has from the beginning. Ever wondered why your phone can check mail and play music and sync your calendars while you are playing a game? Ah, I see the light of realization dawning in your eyes! “But, why can’t I listen to Pandora while I am in Safari then?”, you ask. Simple. The ability to run apps in the background (multi-task), is not available to third party developers.

The non-ability of apps to run in the background has probably been the number one criticized point about the iPhone, and now the iPad. But why is this? Personally, this is not one of the things that really bothers me about the iPhone. It would be nice to have the option to listen to Pandora when doing other things, and to set alarms in my own iPhone app, but it’s not my number one most wanted feature.

My number one, most wanted, must have feature for the iPhone is:

Allow me to set custom sounds for incoming SMS messages!

I follow a lot of people on Twitter. I get literally hundreds of SMS messages every day. Because of this high volume, I keep my phone on silent mode. It would be very, very helpful to be able to set SMS messages from Twitter to vibrate, but messages from other people to use an audio alert. And not just those same old alerts that we have had since OS 1.0. Those have become stale. I want to use my own sounds for SMS alerts.

So Apple, if you are listening, how about it? Can we please get custom, assignable SMS alerts for iPhone OS 4.0? Pretty please?

How about you, readers? What is your number one most wanted feature for the iPhone?

Commenting Is Not An Option

Commenting code is a part of development and engineering that is overlooked all too often. It might be that developers are simply under so much pressure that they feel there is no time for commenting. It might be viewed as a hassle. And, it is not something that is required for the code to compile and execute.

The compiler sees comments as optional, but that does not mean that developers should see them the same way.

Commenting is a vital, I would even go as far as to say critical, part of any software engineering effort. If you have been in the business for any length of time, you have undoubtedly come across code that is missing meaningful comments. You probably spent a significant amount of time trying to figure out not only what the code was doing, but what the original author was intending to do. Perhaps you have even experienced this with your own code!

Try to get in the habit of adding meaningful comments while you are coding, and do not consider the project finished until the comments are in place. Often, the comments in code are the most up-to-date documentation that a project will have. Requirements and technical specs may be out of date once the coding actually starts, and keeping documentation up to date which is separate from the code is a much more complex task than keeping comments up to date. If you use Java, take a look at the article How to Write Doc Comments for the Javadoc Tool. Look at the Java source and see how the comments are formatted. With a little practice, commenting will become second nature.

What if you do not use Java? That’s ok — every language has some way to leave comments, and the principles apply just the same.

Here are five ways to make commenting work for you:

1) Comment the method signature before you write any code inside the method. Then write the code implementing the described behavior.

2) Comment private methods and fields, not just public ones. You can then tell the javadoc tool to include private classes in the generated documentation. The resulting javadocs will be invaluable for anybody that needs to maintain the program in the future. You can easily generate two sets of documents if needed, one for public use and one for private, internal use.

3) Update comments when you modify the code. Comments that do not match what the code is doing are not helpful.

4) Take advantage of version control keyword expansion in your comments. For example, including the CVS keyword $Id$ in your comment will tell you who checked in the file last, the date, the RCS filename, and the revision number.

5) Let your IDE do the work. Modern IDE’s understand javadoc comment format, and can often generate the boilerplate of the comment for you, including @param, @return, and @throws tags. You just have to fill in the blanks.

What other ways do you make comments in code work for you? Feel free to leave a comment below, and tell us about it!

Old Media, Social Media, and Developers

I recently attended the Twitter developer meetup, and one of the subjects that came up quite often was the question of how to get “old” media companies to understand social media. A couple of days after the meeting, I read this article from 1995, where the author predicts that no online database can ever replace your daily newspaper, electronic books will never catch on, and e-commerce is a joke. The article actually made me laugh out loud, but the confluence of the article and the questions raised at the developer meeting made me think.

True, it was 1995, and the internet was nothing like we have today. But what the author of that article lacked was vision. What else happened in 1995? Sun launched Java. The Yahoo! domain was created. RealAudio gave us audio streaming over our dial-up connections. People who were willing to look for the potential of this new technology found it, and many of them made a lot of money along the way.

Fast forward to 2010. Everybody has a web site. Most companies understand that commerce over the Internet is a viable business model. But social media is something new. Many companies, including media companies, are still struggling to understand how to fit social networking into their business. They are lacking the vision to see how to make this new technology, this new avenue of interacting with customers, fit in to their old ways of thinking.

Part of the problem is that social media is about community, more than marketing, and this is a change of thinking that is difficult for old media to embrace. Community implies an openness that many companies are not comfortable with. But this is a shift that will need to be made to make social media work for a company. Social media companies can make a big difference here by providing education, helping management and marketing teams understand how to use social media to create communities around their brands.

Another problem is that developer resources are required, and these resources are often stretched thin. Social media companies can make a big difference here by building tools and providing documentation to assist in rapid integration of social network features into a companies’ existing workflow and systems. This will also create an environment where companies that specialize in social media integration to thrive.

It will be interesting to see how social media companies tackle this challenge, and it is something that we, as developers, should be thinking about.

Java Network Proxies

Have you ever spent hours lovingly coding your Next Great Program, only to discover that part of your audience cannot use it because they are behind a proxy server? If you are going to be using the network, it pays to plan ahead for this situation. Adding proxy capability to your program is not very difficult. Here’s a quick code snippet that does just that:

public static void enableProxy(String host, int port, final String username, final char[] password) {
    System.setProperty("http.proxyHost", host);
    System.setProperty("http.proxyPort", String.valueOf(port));

    if (username != null && !username.isEmpty()) {
        Authenticator.setDefault(new Authenticator() {

        protected PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication(username, password);


Calling this method with a host and port will set up the system properties necessary for proxy access to work. If the username is not null, it will also set up a PasswordAuthentication object to perform authentication as needed. To disable the proxy, call this method:

public static void clearProxy() {

Now, all you have to do is provide a way for the user to enter the proxy settings, persist the settings, and call the enableProxy method. At application startup, you can read the settings from where you have stored them and enable the proxy.

Another option is to tell the JVM to use your system proxy settings. However, I have had problems with this detecting the system properties in some cases on some operating systems:

System.setProperty("", "true");

Adding proxy support to your code is easy! Taking the time to add proxy support to your application will save you headaches later on down the road. Happy coding!

Blocking User Input In A Swing GUI

When developing a desktop application, there are times when you want to prevent the user from interacting with the GUI. For example, you may be doing work in the background, and want to make sure you finish before allowing the user to continue. Perhaps the most obvious way to do this is to disable each component in the GUI. This works, but is not a very elegant or maintainable solution. The appearance of each GUI component changes when disabled, and if you add a new component to the window in the future, you will have to remember to disable it as well.

Fortunantly, Swing provides a better way to do this: The glass pane. The glass pane is one of the layers of a JRootPane. It is transparent and normally not visible. However, if you set it as visible, you can effectively block all user interaction with the contents of the window.

Carrying this one step further, it is possible to set the glass pane to be a panel of your own design. By doing this, you can effectively overlay anything you want on top of the current window, including messages to the user, animated progress icons, etc. The screen shot below shows the BlockerPanel in action. The icon and text are on the glass pane, which intercepts all user interaction with the window.

BlockerPanel Demo

The code to implement a BlockerPanel is straightforward, and the resulting class is easy to use. You can download my BlockerPanel class along with a simple demonstration program and use it in any of your projects. The source code is released with no restrictions, so feel free to improve upon it. There are many useful features that could be added, and there are parts of the code that could be improved. I’ll leave this as an exercise for the reader.

BlockerDemo source code and test program.

Further reading:

How to use Root Panes on