Friday, October 10, 2008
No More Heroes 2
Trailer for No More Heroes: Desperate Struggle.
Wednesday, September 24, 2008
First Android Device Fails to Impress
- No desktop application for syncing. Google is positioning everything to sync from the cloud, gmail, google calendar etc. Yeah, this is just going to be such a joy for organizing your music and other media files on your device.
- No iTunes support. The largest music retailer in the world will not function with Android.
- Sim locked to T-Mobile. 2 year contract with a retail price tag of $175. OK, so the device costs a lot more than $175 hence the contract, so why can't we just buy the full version? So much for this open thing.
- The device is bulky, favoring a full pull out keyboard instead of a touch keyboard similar to the iPhone. I think this is more of a problem with HTC than the Android platform itself. However, now that I think about it, I haven't seen a touch keyboard on this platform period. The emulators don't have it.
- Limited Bluetooth support and APIs. Google has pledge that future versions of the software will expand on these services.
- Google Android Market is a good thing but are these devices actually upgradable? Can we upgrade from Android 1.0 to future Android releases?
- For the relatively small price difference, that 8 GB flash drive found in the iPhone is looking very attractive. Honestly, dump the SD cards already.
- Tooling support is still sub par. No visual designer is available but the latest Eclipse plugin has visual preview so this may be in the works. However, DroidDraw is available and is pretty good.
Friday, September 5, 2008
Recipient Address Rejected with PostFix and JavaMail
JavaMail has way too many parameters that are just strings, with methods that take a lot of strings, it becomes way too easy to mix up one string parameter with another.
Folders in a Database
Using recursion with a database like this is usually pretty bad performance wise, consider using a token instead. A token could be, for example, a folder id string field that keeps the path of the folder using the identifiers of all its parents.
So, if you had folders "a/b/c", the folder id string for the "c" object could be "/100/101/" representing the path to this folder.
In application code, you should obviously never manipulate this string directly, the string should be completely private to your inner most classes that represent your data model.
Using this technique however, it becomes very simple to answer some very basic questions like:
- Can I drop this folder into this other folder? Simple, just check if the string starts with the same path or is equal. So "c" can be dropped into "a" or "b", but "a" cannot be dropped in "a" or "b" because the path for "c" contains "a".
- How many items are contained in this folder? Just check how many items have a matching string.
- Makes it easy to find siblings, all the items found in the same folder have the same folder id/path.
Thursday, September 4, 2008
Push vs. Poll
It seems pretty obvious at first but this is no simple matter. For years, I have been in the poll camp. The idea was that if you had long running processes that would poll for updates every 20 to 60 minutes, the cost of setting up, performing requests and tearing down a connection would be less than the cost of maintaining a connection on the server.
Well, there are several problems with this scenario. The first one being that under such conditions, the total number of bytes needed to perform the requests on the server usually ends up being a higher number than the total bytes needed to produce responses to indicate that no new data is available since the last poll. The second is that it is much harder to limit incoming requests to the capacity of your servers. Namely, given n number of client processes out in the field, entropy sets in and will cause your clients to poll at different times. However, as the number of client processes gets bigger and bigger, the number of simultaneous polls that hit the server at the same time grows at the same rate. Using push, we can feed updates to clients at a rate that the server can handle. Since the server is responsible for contacting the clients, it can do so at its own pace completely sidestepping the “Thundering Herd” problem. Third is that not all bytes are of equal cost. In this ever heterogeneous computing landscape, e.g., the cost of a byte on a high speed DSL line isn’t the same than the cost of a byte on a cellular edge network. In the scenario above, sending requests that have empty responses should be a no cost operation on a domestic high speed link but this doesn’t hold true for a user on the cellular network. Fourth, given an update that needs to be pushed, that single piece of information is completely independent of any updates that came before it and will come after it, meaning that it is easy to distribute this work to a farm. For example, we can imagine that for a poll, we would need to query the database for each and every poll. For a push, we would push the result of running a single query to multiple clients. The fourth argument is much more domain specific since your data might not allow for this at all but it’s still perfectly possible on some data sets. Fifth, web applications are not kiosks, they can't be polling only once every hour. However, even for kiosks, push is still superior since it allows for instant monitoring of every client in the field.
The term coined for server side push is comet, or reverse Ajax, and you use this to get to your clients, be it a web application or not, to achieve a server side push. However, the problem is that too often the solutions ends up looking something like this:
but this is not the most optimal solution. First, it does not get rid of the extra request traffic that we are trying to avoid. This is not really server side push but more of a constant poll where the response timeout is extremely high. With comet, the idea is to get to a point where you're shaping your traffic like this:
Not only does this get rid of our unwanted traffic, it truly does provide a scalable way for the server to publish change sets to clients without having to exert itself.
Now the bad news, achieving comet isn't just about behaving in a certain way at the network level. Reaching this level of sophistication means that the server is maintaining work queues of the data that it needs to send to clients. This isn't too bad but remember that not every client will be synchronized to the latest updates when sending out new updates. Your clients will still need to get to the synchronized state using regular requests before they can get updates via comet.
Finally, I would like to mention that there are several tools and kits and what not to add comet support to your application, you don't need to do it yourself. However, I have found that Grizzly, the http web server that ships by default in Glassfish, to be an excellent choice for all my comet needs. Grizzly is really an impressive piece of code, using non-blocking I/O everywhere with a minimal amount of threads to achieve maximum throughput. You'll still need to handle things like dropped connections and other exceptional conditions but the hard part of getting a scalable comet implementation going in the first place will be done at least. Furthermore the plan for Grizzly 2 calls for enhancing the server with the new asynchronous I/O facilities being introduced in Java SE 7, which should make this already impressive beast scale to new heights.
Sunday, August 17, 2008
NetBeans Exception Reporting
I've talked before on how this is really a shame especially considering that Google produces breakpad, certainly good enough for the C and C++ community to start improving the quality of their software thanks to good crash reporting and some projects definitely are, albeit, again, using their own servers.
To this day, Microsoft is the only company that is hosting an error reporting service that it makes available to all developers in the form of Windows Error Reporting. Kudos to Microsoft for this effort.
I've been very enthusiastic about my jump from C++ to the Java platform, or to a much lesser extent the .Net (Compact) platform. The reasons for this aren't related to language features, C++ armed with smart pointers and modern libraries and idioms can easily compete with the Java 5 language and C#.
No, the reason is how much richness is kept in the compiled binary format representation of these platforms. Of course, the massive advantage of Java over, well, pretty much everything else, in the number of high quality libraries that are available certainly helps too. The point being if you've had to deal with post-mortem debugging before, the rich and high quality stack traces you can get from a Java exception versus the information you get from a minidump file is night and day. You can't get this from a C or C++ program even if you do all your symbol generation correctly because a lot of good and necessary information is optimized away. While with the other two, the non optimized version is still available on disk since it's compiled just in time.
Taking a step back here for a second to talk about ahead of time versus just in time compilation. I'm not too familiar with .Net outside of the compact edition but the performance of Java SE 6 is simply amazing, I've done enough high level C++ to know that Java SE 6 beats it hands down performance wise. Forgetting the ton of adaptive optimizations that the HotSpot virtual machine can do here for a moment, one of the major reason for this is the heap. Heap implementations in C++ are still based on C's malloc which isn't exactly good at dealing with tons of little polymorphic object allocations. C's malloc is still geared toward the C program, you allocate a bunch of memory at start up and you use that as a pool until your program ends. Not exactly friendly to a high level C++ program nor a multi-threaded one.
Getting back on track here, the lack of error reporting services unfortunately extend to the Java world. Even the tree major Java hubs out there, in addition to the tree named at the start of this post, namely java.net, Apache and Codehaus do not provide crash reporting services. I guess Apache is off the hook since they provide mostly libraries and server software, but still, much could be done in the area of crash reporting.
All of this brings me to how NetBeans handles unhandled exceptions that occur in the wild. NetBeans pops up this little dialog and asks you to send in your report. Once you do send it, it's almost magical, reports are queued, analyzed, associated to either a new report or an existing report and finally the generic reports are associated to an issue in IssueZilla and it does it all automatically. If the issue is fixed, it even tells you in which, upcoming or not, version it has been fixed.
This is how it should be done. I don't know what license this system is under, but how about getting this into the greater community? Let's get this system moved from being NetBeans specific to all projects hosted at java.net for example. And what's really nice about this is that it doesn't have to be limited to Java SE/EE, this can work just fine with Java ME too. Now, wouldn't that be something?
Friday, July 25, 2008
BlackBerry + WiFi
If you have a BlackBerry that also happens to support WI-FI, you might be surprised to find out that your favorite networked application doesn't favor WI-FI over APN when you're in range.
In fact, these applications will never favor WI-FI over your regular data network link. This is because the BlackBerry operating system does not abstract this for the application programmer. In other words, unless the application programmer knows about this and explicitly codes support for WI-FI in his application, the application will never use WI-FI.
So how do you get WI-FI support in there? You have to append the magical string ";interface=wifi" to any URL that you want to open. So, assuming standard Java ME/CLDC network programming here, you would do something like:
String uri = "http://www.spectrumdt.com;interface=wifi";
HttpConnection c = (HttpConnection) Connector.open(uri);
Otherwise, your application will inform you that "Could not open tunnel - Max time out" or go over your regular data link.
And that's about it. Oh, and by the way, if you don't have WI-FI or you're out of range, the OS won't do you any favors and fall back to your regular data link, so you have to make sure to try out the regular data link in case of errors too.
Finally, I would like to say that this feature is mostly impossible to find in the BlackBerry documentation. I found it in a beta version of an upcoming manual. The only reason I noticed this is that my development BlackBerry doesn't have a sim card, the browser worked, but my application didn't. Also of interest, almost all non first party applications I tested couldn't use WI-FI either. I'm guessing quite a few people don't know about this.
Sunday, July 13, 2008
GWT + j_security_check
I went out looking for a solution to this recently and found very little information. A lot of questions unanswered led me to believe I was not the only one who wanted to do this. I present here a small sample on how to accomplish this.
Before presenting the sample, let's go over a few things first on why you would want to do this and more importantly why you still need an Ajax style security token for all your GWT services even after this is implemented.
The reasons you would want to do this? One is automatic single sign-on (SSO) if supported by your container, e.g., Glassfish supports SSO out of the box for its web, EJB and web services tiers. If you use j_security_check, you're in; you're into all these services. Furthermore, if you use a J2EE authorization agent like OpenSSO inside Glassfish, you're into any services or sites provided by that federation. So even if you’re fronting your application with GWT, your back end might be composed of all these elements and more.
This also allows you to use any standard security annotations in your EJBs or, if you're orchestrating like me, in OpenESB. You can do this because you now have a Java security principal setup inside the container.
This also allows you to leverage the clustering features, if any, of your application server. Glassfish, again, contains great out of the box support for clustering. Session replication and expiration is managed for you and it just works. One call can proceed on one server while the other can proceed on another while the caller remains completely oblivious to where its work is actually being executed.
What you can’t do however is assume that you should no longer have an object representing your logged in user in your GWT client code. GWT RPC calls are still out in the open with this technique, you should pass in at the very least your session id value as a parameter to the GWT remote call so that the RCP service can do validations.
You still need SSL. Use SSL to make sure your password is transmitted securely over the wire. Hashing on the client side is completely useless. First, because MD5 is usually about the only thing available in JavaScript and that is easily broken. Second, because you should be counting on SSL to do its job correctly. Third, once on the server, you should hash your password with something that is secure, i.e., not MD5 and throw away the clear text representation of the password.
I use NetBeans 6.1 and release candidate 1 of GWT 1.5 for this example. The idea is to use the RequestBuilder class to touch a resource that has been marked off limits by the container. We do this because the j_security_check, in Java EE 5 at least, cannot be invoked directly in a portable manner. When the server sees the access to the protected resource by an unknown, it redirects you to the login page. When this occurs, the method “onResponseReceived” is called. We ignore the redirect and submit our own form. The form just needs to have at least 3 named elements present:
- The form name, j_security_check
- The user name field, j_username
- The password field, j_password
If you don’t touch a protected resource first and simply submit your form immediately, you will find that you still don’t have a security principal since no login actually occurred in the container.
You would apply the same rules for defining a protected area than you would for a normal non-GWT application. You can see on how to do this in Glassfish and Tomcat by following the tutorial here.
Here is some sample code that fulfills a login on Java application server. I originally had more here in terms of error handling but it seemed it got to be too large for presentation purposes.
|
|
Wednesday, July 9, 2008
Upcoming
I'm so busy I don't know when I'll have time to write any of these but hopefully they will be up before long.
Wednesday, June 11, 2008
Just How Bad is Windows CE?
The real problem with Windows Mobile is that it isn't trying to be a really good phone, it's trying to be a pocket PC which not so coincidentally was its original brand. It just doesn't have the screen real estate to pull that off.
At WWDC 2008, Apple announced 3G iPhones that are actually cheaper than the current models. This is bad news for every smart phone vendor out there. I see really two segments now, the people who just want a basic phone, and the people who want an iPhone. The iPhone is really just that disruptive of a technology. I can't explain in words just how horrible it is to start using another smart phone again. Furthermore, it's the only phone that I have encountered that makes mobile web browsing viable.
So what is everybody else doing? Well, you have things like Android and the Samsung Instinct which are clearly heavily influenced by the iPhone but neither are yet available. The iPhone 3G, with its 7 Mbps Internet access, goes on sale early July of this year.
All is not lost for other vendors however. Let's face it, even with its new focus on the enterprise with the iPhone, Apple is really not very good at dealing with businesses and developers at this scale. Those users won't put up with half the things the regular Apple fan boy puts up with. If you're in the iPhone developer program right now, you probably don't like Apple very much. The things they make you do to actually deploy an application to real hardware is pretty obscene. At this point, I think it's Apple's market to lose. We'll see if Apple will learn a bit of humility here and open up this platform instead of imposing their will on everything closely related to the iPhone. This is really where the door is open for something like Android to come in and really give iPhone a run for its money.
We'll only know for sure over time but Google, now more than ever, needs to get real hardware out into the wild and at the very least refresh the Android public SDK. The Android SDK drop is still the one from last March and, thanks to controlled leaks, doesn't look or feel anything like the Android of today.
So just how bad is Windows CE? Well, it's so bad I don't even think it's a contender anymore. Let's face it, convergence is still ever creeping in. In a few years, your primary computer will probably be your phone that you cradle to get a full sized screen and keyboard. This is already happening, just have a look at the Celio REDFLY. I would think this makes Microsoft pretty nervous.

