|
|
||
Inderjeet Singh's BlogMay 2007 ArchivesPet peeve with the Java 1.5 enhanced for loopPosted by inder on May 24, 2007 at 04:15 PM | Permalink | Comments (14)I love the enhanced for loop construct introduced in Java 1.5. It makes the code look clean, and saves us from dealing with iterators or array indices. But since it is essentially syntactic sugar, it does create iterators behind the scenes as necessary. This can result in insidious bugs since if the passed collection or the array is null, your for loop will throw a NullPointerException. Here is an example:
When this program is run, it will throw a null pointer exception. I think it would have been better if the for loop did a null pointer check on the collection before trying to iterate over it. Granted, it will have a little bit of overhead, but I think the cost is justified because it is really common for people to not check for null values before invoking the for loop. I dont expect the semantics to get changed now because of backward compatibility concerns, so dont hold your breath expecting a change. But still, what do you think? Did the language designers make a mistake? Share your thoughts as comments to the blog. Using Google Checkout SDK with GlassfishPosted by inder on May 21, 2007 at 11:28 PM | Permalink | Comments (0)
The Checkout SDK provides a library jar and an XML configuration file that you will need to embed in your Web application. You can then configure your action handlers that will receive notification of various order processing events from Google as a user places an order. Here are the steps that you will need to follow:
That is it! Try it out today, and share your experiences as comments to this blog. We will be try our best to improve the checkout SDK to enable easy implementation by your Web applications. Thanks for reading. JavaOne sessions on Java EE 5 puzzlers and Google CheckoutPosted by inder on May 02, 2007 at 09:14 AM | Permalink | Comments (0)![]() JavaOne 2007 is right around the corner, and I am participating in two sessions there. The first one is based on my work at my previous employer, Sun Microsystems. This session will present tips and tricks on using Java EE 5, and is patterned after the popular Java Puzzler sessions by Josh Bloch. My other session is related to using Google Checkout API in Java applications. In this session, we will describe how Java developers can use this API to enable payments for selling products on their websites. The integration can be as simple as an HTML FORM post, or a heavy duty one for integration with order processing systems using a REST based API. We will also demonstrate how the popular Web 2.0 Pet Store application can be modified to use Google Checkout. When neither presenting or attending other sessions, I will be handing out goodies at the Google booth in the pavillion! So if you are coming to the conference and would like to meet up, drop by the booth or at either of the sessions. If there are any specific topics you would like us to cover in the sessions, you are welcome to share them as comments to this blog. Thanks for reading.
| ||
|
|