I've started coding on my zwave cell phone "controller." I spent most of the day getting things setup. I decided to use Java as the driver for my cell phone application. The main reason is that the phone I have now happens to only run java apps, but the other reason is that Java will have the farthest reach should I ever change my cell phone or switch providers.
I downloaded Netbeans and started researching where to start. I found out rather quickly that Sun has a J2ME specifically for cell phones. I put together a quick Hello World app and uploaded it to my Helio Ocean just to make sure the Ocean would really let me program custom apps. I was in luck, it worked great!
I need to make sure this application screams. The bottle neck is going to be the communication with my home server so I've spent a lot of time playing around and trying to determine the fastest communication method.
My first test was to simply use good old fashioned sockets. I set up a mini server on my computer to listen for a connection and then I did a quick test app on the phone. It looked promising, but as I started hashing out the communications I found that though quick and simple, this way would ultimately have a somewhat large maintenance overhead because of all the string parsing I'd have to do.
To simplify the maintenace, I started looking for ways to easily serialize an object in .NET then de-serialize it in java. I knew this concept would work well at least on the server-side (since it was .NET) - it takes about 3 lines of code to serialize then 3 more lines to de-serialize back into an object. However, Java is another story all together. There's simply no easy way to get an XML string back into an object without writting many, many lines of code. Even with 3rd party libraries it takes major setup for each type of object just to make it happen...
So I stopped that line of thinking and moved on to the Web-service idea. Perhaps I could use SOAP to get my serialized object and use that to build my objects again in java. It only took a few minutes to find a 3rd party class that should have worked well. I was on my own about implementing it though as there was very little on the internet in terms of samples or documentation. After 2 or 3 hours I gave up trying to make it work. It seems something on my phone was preventing me from consuming a web-service. I'll have to dig into this more later...
I moved back to the idea of making my own protocol using sockets and by the end of the day was able to display a "hello world" on my phone (which was sent to it from my home's zwave server).
All in all I learned (or re-learned) a few things about java...
1) If java had a gender, it would be female (it's so picky and insists on doing things the hard way)
2) I was reminded of why I removed Java from my resume (I love the simply nature of .NET, and hate the crap you have to go through for Java to perform the simplest of tasks)
3) I was amazed at the quality (or lack of really) of the java samples and examples that exist on the internet. Compared to .NET, which abounds in great quality, java is hugely lacking.
In the end I had a lot of fun. I learned a lot, stretched my mind more than usually and found out some new tricks. I'm excited to see what I can do tomorrow. :)
I'm out -
No comments:
Post a Comment